public ActionResult KajMaKhateuneEdit(EmployeeKaazViwModel data) { int empCode = data.EmpCode; data.LetterIssueDate = Convert.ToDateTime(NepEngDate.NepToEng(data.LetterIssueDateNP)); data.KajStartDate = Convert.ToDateTime(NepEngDate.NepToEng(data.KajStartDateNP)); data.KajEndDate = Convert.ToDateTime(NepEngDate.NepToEng(data.KajEndDateNP)); if (!ViewBag.AllowView) { ViewBag.Error = "You are not Authorize to use this Page"; return(PartialView("_partialviewNotFound")); } ListOfDatas(empCode); try { if (!ModelState.IsValid) { return(View("../Employee/Kajmakhataune/Edit", data)); } EmployeeJobHistoryDTO dataToInsert = new EmployeeJobHistoryDTO(); EmpAllCodesVIewmodels emp = _employeeService.EmployeesIds(empCode); //mandatory field dataToInsert.HistoryId = data.Id; dataToInsert.EmpCode = empCode; dataToInsert.OfficeId = emp.EmpOfficeId; dataToInsert.DeptId = emp.EmpDeptId; dataToInsert.SectionId = emp.EmpSectionId; dataToInsert.DesgId = emp.EmpDesgId; dataToInsert.RankId = emp.EmpRankId; dataToInsert.LevelId = emp.EmpLevelId; dataToInsert.BusinessGroupId = emp.EmpBgId; dataToInsert.ShiftId = emp.EmpShiftId; dataToInsert.JobTypeId = emp.EmpJobTypeId; // Kazz releated field dataToInsert.LetterIssueDate = data.LetterIssueDate; dataToInsert.LetterRefNo = data.LetterRefNo; dataToInsert.ChalaniNumber = data.LetterChalaniNumber; dataToInsert.KajStartDate = data.KajStartDate; dataToInsert.KajEndDate = data.KajEndDate; dataToInsert.ServiceEventGroupId = 3; int ServiceEventSubGroupId = 0; if (data.KaajType == "U") { ServiceEventSubGroupId = 10; } else { ServiceEventSubGroupId = 11; } dataToInsert.ServiceEventSubGroupId = ServiceEventSubGroupId; dataToInsert.SadarGarneEmployeeCode = data.SadarGarneEmployeeCode; dataToInsert.Remarks = data.Remarks; dataToInsert.Instruction = data.Instruction; dataToInsert.SadarDate = data.LetterIssueDate; dataToInsert.KaajType = data.KaajType; //before updating get start and end date from database EmployeeJobHistoryDTO RecordUpdate = _jobHistoryService.GetJobHistoryById(data.Id); string updaeSdate = RecordUpdate.KajStartDate.ToString(); string updaEdate = RecordUpdate.KajEndDate.ToString(); string type = "onlyupdate"; int att = _attendance.InsertKaajAttendance(empCode, updaeSdate, updaEdate, type); int res = _jobHistoryService.UpdateJobHistoryForKaj(dataToInsert); string sdate = data.KajStartDate.ToString(); string edate = data.KajEndDate.ToString(); type = "Insert"; att = _attendance.InsertKaajAttendance(empCode, sdate, edate, type); Session["sucessMgsKaaz"] = "Kaaj Record of employee " + empCode + " Updated Sucessfully."; return(Redirect("/kajmakhataune/" + data.EmpCode)); } catch (Exception ex) { Session["ErrorMgsKaaz"] = ex.Message; return(View("../Employee/Kajmakhataune/Edit", data)); } }