public int InsertUpdateHolidaySetting(HolidayNAbsenceViewModel Model, bool Insert) { HolidaysNAbsence_Setting model = new HolidaysNAbsence_Setting(); if (Insert) { model = _db.HolidaysNAbsence_Setting.Where(x => x.Id == Model.Id).FirstOrDefault(); } model.WorkingHours = Model.WorkingHours; model.WorkPattern = Model.WorkPattern; model.AnnualLeave = Model.AnnualLeave; model.CarryOverDays = Model.CarryOverDays; model.CarryOverHours = Model.CarryOverHours; model.HolidayYear = Model.HolidayYear; model.PublicHolidayTemplate = Model.PublicHolidayTemplate; model.TotalHolidayEntitlement = Model.TotalHolidayEntitlement; model.HolidayEntitlement = Model.HolidayEntitlement; model.HolidayReturn = Model.HolidayReturn; model.AuthoriseHolidays = Model.AuthoriseHolidays; model.TOILPeriod = Model.TOILPeriod; model.BradfordFactorAlerts = Model.BradfordFactorAlerts; model.CalculationPeriod = Model.CalculationPeriod; if (!Insert) { _db.HolidaysNAbsence_Setting.Add(model); } _db.SaveChanges(); return(model.Id); }
public ActionResult Index() { HolidayNAbsenceViewModel model = new HolidayNAbsenceViewModel(); var HolidayNAbsenceId = _holidayNAbsenceMethod.getAllHolidaysNAbsenceSettingList(); if (HolidayNAbsenceId != null) { model = _holidayNAbsenceMethod.BindHolidaysNAbsenceSettingRecords(HolidayNAbsenceId.Id); } else { var id = 0; model = _holidayNAbsenceMethod.BindHolidaysNAbsenceSettingRecords(id); } return(View(model)); }
public ActionResult Index(string Model) { JavaScriptSerializer js = new JavaScriptSerializer(); HolidayNAbsenceViewModel ValueArray = js.Deserialize <HolidayNAbsenceViewModel>(Model); if (ModelState.IsValid) { if (ValueArray.Id > 0) { int UpdatedCompanySetting = _holidayNAbsenceMethod.InsertUpdateHolidaySetting(ValueArray, true); } else { int InsertCompanySetting = _holidayNAbsenceMethod.InsertUpdateHolidaySetting(ValueArray, false); } return(RedirectToAction("Index")); } else { return(View(Model)); } }
public HolidayNAbsenceViewModel BindHolidaysNAbsenceSettingRecords(int Id) { HolidayNAbsenceViewModel Companysetting = new HolidayNAbsenceViewModel(); var CId = _OtherSettingMethod.getSystemListByName("Calculation Period List"); var HId = _OtherSettingMethod.getSystemListByName("Holiday Year List"); Companysetting.countryList.Add(new SelectListItem() { Text = "-- Select --", Value = "0" }); foreach (var item in getAllCountryList()) { Companysetting.countryList.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } Companysetting.workPatternList.Add(new SelectListItem() { Text = "-- Select --", Value = "0" }); foreach (var item in getAllWorkPattern()) { Companysetting.workPatternList.Add(new SelectListItem() { Text = item.Name, Value = item.Id.ToString() }); } Companysetting.holidayYearList.Add(new SelectListItem() { Text = "-- Select --", Value = "0" }); foreach (var item in _OtherSettingMethod.getAllSystemValueListByNameId(HId.Id)) { Companysetting.holidayYearList.Add(new SelectListItem() { Text = item.Value, Value = item.Id.ToString() }); } Companysetting.calculationPeriodList.Add(new SelectListItem() { Text = "-- Select --", Value = "0" }); foreach (var item in _OtherSettingMethod.getAllSystemValueListByNameId(CId.Id)) { Companysetting.calculationPeriodList.Add(new SelectListItem() { Text = item.Value, Value = item.Id.ToString() }); } Companysetting.BradfordFactor = new BradfordFactorViewModel(); var bradfordFactor = getBradfordFactor(); if (bradfordFactor != null) { Companysetting.BradfordFactor.Id = bradfordFactor.Id; Companysetting.BradfordFactor.LowerValue1 = bradfordFactor.LowerValue1; Companysetting.BradfordFactor.UpperValue1 = bradfordFactor.UpperValue1; Companysetting.BradfordFactor.Alert1 = bradfordFactor.Alert1; Companysetting.BradfordFactor.LowerValue2 = bradfordFactor.LowerValue2; Companysetting.BradfordFactor.UpperValue2 = bradfordFactor.UpperValue2; Companysetting.BradfordFactor.Alert2 = bradfordFactor.Alert2; Companysetting.BradfordFactor.LowerValue3 = bradfordFactor.LowerValue3; Companysetting.BradfordFactor.UpperValue3 = bradfordFactor.UpperValue3; Companysetting.BradfordFactor.Alert3 = bradfordFactor.Alert3; Companysetting.BradfordFactor.LowerValue4 = bradfordFactor.LowerValue4; Companysetting.BradfordFactor.UpperValue4 = bradfordFactor.UpperValue4; Companysetting.BradfordFactor.Alert4 = bradfordFactor.Alert4; } if (Id != 0) { var model = _db.HolidaysNAbsence_Setting.Where(x => x.Id == Id).FirstOrDefault(); var WorkPID = workPatternDetailsById(int.Parse(model.WorkPattern)); var HoliID = _OtherSettingMethod.getSystemListValueById(int.Parse(model.HolidayYear)); var countID = getCountryById(int.Parse(model.PublicHolidayTemplate)); var CalId = _OtherSettingMethod.getSystemListValueById(int.Parse(model.CalculationPeriod)); Companysetting.Id = model.Id; Companysetting.WorkingHours = model.WorkingHours; Companysetting.WorkPattern = model.WorkPattern; if (WorkPID != null) { Companysetting.WorkPatternValue = WorkPID.Name; } Companysetting.AnnualLeave = model.AnnualLeave; Companysetting.CarryOverDays = model.CarryOverDays; Companysetting.CarryOverHours = model.CarryOverHours; Companysetting.HolidayYear = model.HolidayYear; if (HoliID != null) { Companysetting.HolidayYearValue = HoliID.Value; } Companysetting.PublicHolidayTemplate = model.PublicHolidayTemplate; if (countID != null) { Companysetting.PublicHolidayTemplateValue = countID.Name; } Companysetting.TotalHolidayEntitlement = model.TotalHolidayEntitlement; Companysetting.HolidayEntitlement = model.HolidayEntitlement; Companysetting.HolidayReturn = model.HolidayReturn; Companysetting.AuthoriseHolidays = model.AuthoriseHolidays; Companysetting.TOILPeriod = model.TOILPeriod; Companysetting.BradfordFactorAlerts = model.BradfordFactorAlerts; Companysetting.CalculationPeriod = model.CalculationPeriod; Companysetting.CalculationPeriodValue = CalId.Value; } return(Companysetting); }