public string Create(WorkingDays mast) { try { var salarymast = new MonthlySalaryMast(); var salarydetails = new List<MonthlySalaryDetail>(); salarymast.Branchid = mast.Branchid; salarymast.Month = mast.Month; salarymast.Year = mast.Year; salarymast.Totaldaysinmonth = mast.Totaldaysinmonth; var monthlySalaryDetails = mast.WorkingDaysDetails.Select(x => new MonthlySalaryDetail { EmpId = x.EmpId, AttendanceDays = x.AttendanceDays, Holidays = x.Holidays, LeaveDays = x.LeaveDays, AbsentDays = x.AbsentDays, PayDays = x.PayDays, OTHours = x.OTHours } ); salarymast.MonthlySalaryDetails = monthlySalaryDetails.ToList(); Service.Add(salarymast); return "Working Days Saved Successfully"; } catch (Exception ex) { ModelState.AddModelError("Error", ex.Message); return ex.Message; throw new ArgumentException(ex.Message); } }
public ActionResult Edit(MonthlySalaryMast workingDaysEntry) { if (ModelState.IsValid) { Service.Update(workingDaysEntry); return RedirectToAction("Index"); } return View(workingDaysEntry); }