Rohan

Rohan

  • NA
  • 1.4k
  • 115.7k

Record not update

Jan 3 2022 12:19 PM

I have used this code for update record but not record update . Please check what is issue this code

 ResponseModel responseModel = new ResponseModel();
            try
            {
                Employee _temp = GetEmployeeDetailsById(employee.EmployeeId);
                if (_temp!=null)
                {
                    _temp.City=employee.City;
                    _temp.CurrentAddress=employee.CurrentAddress;
                    _temp.PINCode=employee.PINCode;
                    _temp.EmployeeName=employee.EmployeeName;
                    _temp.DateOfBirth=employee.DateOfBirth;
                    _temp.Gender=employee.Gender;
                    _temp.PermanentAddress=employee.PermanentAddress;
                    _temp.Nationality=employee.Nationality;
                    _context.Update(_temp);      -- Not update here            
                    responseModel.IsSuccess=true;
                    responseModel.Messsage="Employee Update Successfully";
                }
                else
                {

                    _context.Add(employee);
                    _context.SaveChanges();
                    responseModel.IsSuccess=true;
                    responseModel.Messsage = "Employee Inserted Successfully";
                }
            }
            catch (Exception ex)
            {
                responseModel.IsSuccess = false;
                responseModel.Messsage = "Error : " + ex.Message;
            }
            return responseModel;
        }


Answers (1)