public HolidayDTOs HolidayListbyId(int id) { Holiday Record = _unitOfWork.HolidayRepository.GetById(id); HolidayDTOs Returnreocrd = HolidayRequestFormatter.ConvertRespondentInfoToDTO(Record); return(Returnreocrd); }
public static Holiday ConvertRespondentInfoFromDTO(this HolidayDTOs hld) { try { Mapper.CreateMap <HolidayDTOs, Holiday>().ConvertUsing( m => { return(new Holiday { HolidayDate = m.HolidayDate, HolidayDescription = m.HolidayDescription, HolidayEthnicityId = m.HolidayEthnicityId, HolidayGender = m.HolidayGender, HolidayId = m.HolidayId, HolidayOfficeId = m.HolidayOfficeId, HolidayReligionId = m.HolidayReligionId, HolidayStatus = m.HolidayStatus, HolidayTitle = m.HolidayTitle, HolidayYearlyOccourence = m.HolidayYearlyOccourence }); }); return(Mapper.Map <HolidayDTOs, Holiday>(hld)); } catch (Exception ex) { return(null); } }
public IEnumerable <HolidayDTOs> HolidayList() { IEnumerable <Holiday> modelDatas = _unitOfWork.HolidayRepository.All(); IEnumerable <HolidayDTOs> val = from md in modelDatas select new HolidayDTOs { HolidayId = md.HolidayId, HolidayDate = md.HolidayDate, HolidayDescription = md.HolidayDescription, HolidayReligionId = md.HolidayReligionId, HolidayYearlyOccourence = md.HolidayYearlyOccourence, HolidayOfficeId = md.HolidayOfficeId, HolidayGender = md.HolidayGender, HolidayTitle = md.HolidayTitle, HolidayStatus = md.HolidayStatus, HolidayEthnicityId = md.HolidayEthnicityId, }; List <HolidayDTOs> final = new List <HolidayDTOs>(); foreach (var row in val) { HolidayDTOs holiday = new HolidayDTOs(); string religion, ethnicity; if (row.HolidayReligionId == 0) { religion = "ALL"; } else { religion = _unitOfWork.ReligionRepository.Get().Where(x => x.ReligionId == row.HolidayReligionId).FirstOrDefault().ReligionName.ToString(); } if (row.HolidayEthnicityId == 0) { ethnicity = "All"; } else { ethnicity = _unitOfWork.EthnicityRepository.Get().Where(x => x.EthnicityId == row.HolidayEthnicityId).FirstOrDefault().EthnicityName.ToString(); } holiday.HolidayId = row.HolidayId; holiday.HolidayDate = row.HolidayDate; holiday.HolidayDescription = row.HolidayDescription; holiday.HolidayReligionId = row.HolidayReligionId; holiday.HolidayOfficeId = row.HolidayOfficeId; holiday.HolidayGender = row.HolidayGender; holiday.HolidayTitle = row.HolidayTitle; holiday.HolidayStatus = row.HolidayStatus; holiday.HolidayEthnicityId = row.HolidayEthnicityId; holiday.EthnicityName = ethnicity; holiday.ReligionName = religion; final.Add(holiday); } return(final); }
public int CreateHolidays(HolidayDTOs htd) { Holiday dataToInsert = new Holiday(); dataToInsert = HolidayRequestFormatter.ConvertRespondentInfoFromDTO(htd); HolidayDTOs dt = HolidayRequestFormatter.ConvertRespondentInfoToDTO(_unitOfWork.HolidayRepository.Create(dataToInsert)); int id = dt.HolidayId; return(id); }
public ActionResult Index() { if (!ViewBag.AllowView) { ViewBag.Error = "You are not Authorize to use this Page"; return(PartialView("_partialviewNotFound")); } try { HolidayDTOs htd = new HolidayDTOs(); IEnumerable <HolidayDTOs> holidayList = _holidayServices.HolidayList(); return(View(holidayList)); } catch (Exception ex) { return(null); } }
public void CreateHoliayUpdateAttendnace(HolidayDTOs adt) { var conn = DbConnectHelper.GetConnection(); conn.Open(); SqlCommand cmd = new SqlCommand("sp_UpdateHolidayRecord", conn); cmd.Parameters.AddWithValue("@HolidayId", adt.HolidayId); cmd.Parameters.AddWithValue("@HOfficeId", adt.HolidayOfficeId); cmd.Parameters.AddWithValue("@HReligionId", adt.HolidayReligionId); cmd.Parameters.AddWithValue("@HEthnicityId", adt.HolidayEthnicityId); cmd.Parameters.AddWithValue("@HGender", adt.HolidayGender); cmd.Parameters.AddWithValue("@HolidayDate", adt.HolidayDate); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); da.Dispose(); cmd.Dispose(); conn.Close(); conn.Dispose(); }
public ActionResult CreateHoliday() { HolidayDTOs offieList = new HolidayDTOs(); IEnumerable <OfficeDTOs> officelist = _officeServices.GetClildOfficeListByEmpCode(Convert.ToInt32(ViewBag.EmpCode)); IEnumerable <EthnicityDTO> ethnicity = _ethnicityServices.GetEthnicityList(); IEnumerable <ReligionDTO> religion = _religionServices.GetReligionList(); List <SelectListItem> sl = new List <SelectListItem>(); List <SelectListItem> eth = new List <SelectListItem>(); List <SelectListItem> rel = new List <SelectListItem>(); List <SelectListItem> gender = new List <SelectListItem>(); gender.Add(new SelectListItem { Text = "All", Value = "All" }); gender.Add(new SelectListItem { Text = "Male", Value = "Male" }); gender.Add(new SelectListItem { Text = "Female", Value = "Female" }); rel.Add(new SelectListItem { Text = "All", Value = "0" }); eth.Add(new SelectListItem { Text = "All", Value = "0" }); sl.Add(new SelectListItem { Text = "All", Value = "0" }); foreach (OfficeDTOs str in officelist) { sl.Add(new SelectListItem { Text = str.OfficeName, Value = str.OfficeId.ToString() }); } foreach (EthnicityDTO row in ethnicity) { eth.Add(new SelectListItem { Text = row.EthnicityName, Value = row.EthnicityId.ToString() }); } foreach (ReligionDTO row in religion) { rel.Add(new SelectListItem { Text = row.ReligionName, Value = row.ReligionId.ToString() }); } offieList.BranchSelectList = sl; offieList.EthnicitySelectList = eth; offieList.ReligionSelectList = rel; offieList.GenderList = gender; return(View(offieList)); }
public ActionResult EditHolidy(HolidayDTOs htd, int[] offices) { htd.HolidayDate = !string.IsNullOrEmpty(htd.HolidayDateNP) ? Convert.ToDateTime(NepEngDate.NepToEng(htd.HolidayDateNP)) : htd.HolidayDate; try { HolidayDTOs holidaydata = _holidayServices.HolidayListbyId(htd.HolidayId); IEnumerable <OfficeDTOs> officelist = _officeServices.GetClildOfficeListByEmpCode(Convert.ToInt32(ViewBag.EmpCode)); IEnumerable <EthnicityDTO> ethnicity = _ethnicityServices.GetEthnicityList(); IEnumerable <ReligionDTO> religion = _religionServices.GetReligionList(); IEnumerable <HolidayOfficesViewModel> selectedoffice = _holidayServices.HolidayOfficeById(htd.HolidayId); List <SelectListItem> office = new List <SelectListItem>(); List <SelectListItem> eth = new List <SelectListItem>(); List <SelectListItem> rel = new List <SelectListItem>(); List <SelectListItem> gender = new List <SelectListItem>(); List <SelectListItem> seldoffice = new List <SelectListItem>(); gender.Add(new SelectListItem { Text = "All", Value = "All" }); gender.Add(new SelectListItem { Text = "Male", Value = "Male" }); gender.Add(new SelectListItem { Text = "Female", Value = "Female" }); rel.Add(new SelectListItem { Text = "All", Value = "0" }); eth.Add(new SelectListItem { Text = "All", Value = "0" }); foreach (EthnicityDTO row in ethnicity) { eth.Add(new SelectListItem { Text = row.EthnicityName, Value = row.EthnicityId.ToString() }); } foreach (HolidayOfficesViewModel row in selectedoffice) { seldoffice.Add(new SelectListItem { Text = row.OfficeName.ToString(), Value = row.OfficeId.ToString() }); } foreach (OfficeDTOs row in officelist) { office.Add(new SelectListItem { Text = row.OfficeName.ToString(), Value = row.OfficeId.ToString() }); } foreach (ReligionDTO row in religion) { rel.Add(new SelectListItem { Text = row.ReligionName, Value = row.ReligionId.ToString(), }); } holidaydata.BranchSelectList = office; holidaydata.EthnicitySelectList = eth; holidaydata.GenderList = gender; holidaydata.ReligionSelectList = rel; holidaydata.SelectedOffices = seldoffice; if (ModelState.IsValid) { if (htd.HolidayOfficeId == 0) { _holidayServices.DeleteHolidayOffice(htd.HolidayId); _holidayServices.UpdateHoliday(htd); } else if (htd.HolidayOfficeId == 1) { if (offices == null) { ModelState.AddModelError("SelectList", "Please select some offices form the list !!"); return(View(holidaydata)); } else { _holidayServices.DeleteHolidayOffice(htd.HolidayId); for (int i = 0; i < offices.Length; i++) { int officeId = offices[i]; _holidayServices.InsertholidayOffices(htd.HolidayId, officeId); } _holidayServices.UpdateHoliday(htd); } } Session["UpdateHoliday"] = "Holiday Updated Sucessfully !!"; return(RedirectToAction("Index", "Holiday")); } else { return(View(holidaydata)); } } catch (Exception Ex) { Session["updateerroe"] = "Error While Updating " + Ex.Message; return(RedirectToAction("Index", "Holiday")); } }
public ActionResult EditHolidy(int id) { try { HolidayDTOs holidaydata = _holidayServices.HolidayListbyId(id); IEnumerable <OfficeDTOs> officelist = _officeServices.GetClildOfficeListByEmpCode(Convert.ToInt32(ViewBag.EmpCode)); IEnumerable <EthnicityDTO> ethnicity = _ethnicityServices.GetEthnicityList(); IEnumerable <ReligionDTO> religion = _religionServices.GetReligionList(); IEnumerable <HolidayOfficesViewModel> selectedoffice = _holidayServices.HolidayOfficeById(id); List <SelectListItem> office = new List <SelectListItem>(); List <SelectListItem> eth = new List <SelectListItem>(); List <SelectListItem> rel = new List <SelectListItem>(); List <SelectListItem> gender = new List <SelectListItem>(); List <SelectListItem> seldoffice = new List <SelectListItem>(); gender.Add(new SelectListItem { Text = "All", Value = "All" }); gender.Add(new SelectListItem { Text = "Male", Value = "Male" }); gender.Add(new SelectListItem { Text = "Female", Value = "Female" }); rel.Add(new SelectListItem { Text = "All", Value = "0" }); eth.Add(new SelectListItem { Text = "All", Value = "0" }); foreach (EthnicityDTO row in ethnicity) { eth.Add(new SelectListItem { Text = row.EthnicityName, Value = row.EthnicityId.ToString() }); } foreach (HolidayOfficesViewModel row in selectedoffice) { seldoffice.Add(new SelectListItem { Text = row.OfficeName.ToString(), Value = row.OfficeId.ToString() }); } foreach (OfficeDTOs row in officelist) { office.Add(new SelectListItem { Text = row.OfficeName.ToString(), Value = row.OfficeId.ToString() }); } foreach (ReligionDTO row in religion) { rel.Add(new SelectListItem { Text = row.ReligionName, Value = row.ReligionId.ToString(), }); } holidaydata.BranchSelectList = office; holidaydata.EthnicitySelectList = eth; holidaydata.GenderList = gender; holidaydata.ReligionSelectList = rel; holidaydata.SelectedOffices = seldoffice; return(View(holidaydata)); } catch (Exception Ex) { Session["updateerroe"] = "Error While Updating " + Ex.Message; return(RedirectToAction("Index", "Holiday")); } }
public ActionResult CreateHoliday(HolidayDTOs atd, int[] offices) { atd.HolidayDate = !string.IsNullOrEmpty(atd.HolidayDateNP) ? Convert.ToDateTime(NepEngDate.NepToEng(atd.HolidayDateNP)) : atd.HolidayDate; HolidayDTOs offieList = new HolidayDTOs(); IEnumerable <OfficeDTOs> officelist = _officeServices.GetClildOfficeListByEmpCode(Convert.ToInt32(ViewBag.EmpCode)); IEnumerable <EthnicityDTO> ethnicity = _ethnicityServices.GetEthnicityList(); IEnumerable <ReligionDTO> religion = _religionServices.GetReligionList(); List <SelectListItem> sl = new List <SelectListItem>(); List <SelectListItem> eth = new List <SelectListItem>(); List <SelectListItem> rel = new List <SelectListItem>(); List <SelectListItem> gender = new List <SelectListItem>(); rel.Add(new SelectListItem { Text = "All", Value = "0" }); eth.Add(new SelectListItem { Text = "All", Value = "0" }); sl.Add(new SelectListItem { Text = "All", Value = "0" }); gender.Add(new SelectListItem { Text = "All", Value = "All" }); gender.Add(new SelectListItem { Text = "Male", Value = "Male" }); gender.Add(new SelectListItem { Text = "Female", Value = "Female" }); foreach (OfficeDTOs str in officelist) { sl.Add(new SelectListItem { Text = str.OfficeName, Value = str.OfficeId.ToString() }); } foreach (EthnicityDTO row in ethnicity) { eth.Add(new SelectListItem { Text = row.EthnicityName, Value = row.EthnicityId.ToString() }); } foreach (ReligionDTO row in religion) { rel.Add(new SelectListItem { Text = row.ReligionName, Value = row.ReligionId.ToString() }); } offieList.BranchSelectList = sl; offieList.EthnicitySelectList = eth; offieList.ReligionSelectList = rel; offieList.GenderList = gender; if (ModelState.IsValid) { try { atd.HolidayStatus = true; if (atd.HolidayOfficeId == 1) { if (offices == null) { ModelState.AddModelError("SelectList", "Please select some offices form the list !!"); return(View(offieList)); } else { int id = _holidayServices.CreateHolidays(atd); for (int i = 0; i < offices.Length; i++) { int officeId = offices[i]; _holidayServices.InsertholidayOffices(id, officeId); } } } else { int id = _holidayServices.CreateHolidays(atd); } Session["UpdateHoliday"] = "Holiday Created Sucessfully !!"; return(RedirectToAction("Index", "Holiday")); } catch (Exception Ex) { return(View(Ex.Message)); } } else { return(View(offieList)); } }
public int UpdateHoliday(HolidayDTOs htd) { Holiday att = HolidayRequestFormatter.ConvertRespondentInfoFromDTO(htd); return(_unitOfWork.HolidayRepository.Update(att)); }