public ActionResult Edit(HolidaysViewModel model) { if (ModelState.IsValid) { if (Request["Submit"] == "Save") { var Holidays = HolidaysRepository.GetHolidaysById(model.Id); AutoMapper.Mapper.Map(model, Holidays); Holidays.ModifiedUserId = WebSecurity.CurrentUserId; Holidays.ModifiedDate = DateTime.Now; HolidaysRepository.UpdateHolidays(Holidays); TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess; return(RedirectToAction("Index")); } return(View(model)); } return(View(model)); //if (Request.UrlReferrer != null) // return Redirect(Request.UrlReferrer.AbsoluteUri); //return RedirectToAction("Index"); }
public IActionResult SubmitRequest(HolidaysViewModel holidaysViewModel) { base.CheckForLogin(); if (ModelState.IsValid) { bool approved = false; if (new UserRepository(new UserSQLContext()).GetUser(Convert.ToInt32(HttpContext.Session.GetInt32("id"))).Role.Rights.Any(f => f.Id == 8)) { approved = true; } if (holidaysViewModel.DateStart != DateTime.MinValue && holidaysViewModel.DateEnd != DateTime.MinValue && holidaysViewModel.DateStart < holidaysViewModel.DateEnd && !string.IsNullOrEmpty(holidaysViewModel.Description)) { HolidayRequest holidayRequest = new HolidayRequest(Convert.ToInt32(HttpContext.Session.GetInt32("id")), (DateTime)holidaysViewModel.DateStart, (DateTime)holidaysViewModel.DateEnd, holidaysViewModel.Description, approved); new UserRepository(new UserSQLContext()).AddHolidayRequest(holidayRequest); ConfirmHoliday(); } else { WrongHoliday(); } } UserRepository userRep = new UserRepository(new UserSQLContext()); holidaysViewModel.HasApproveHolidayRight = (userRep.GetUser(Convert.ToInt32(HttpContext.Session.GetInt32("id"))).Role.Rights.Any(f => f.Id == 8) ? true : false); holidaysViewModel.AllholidayRequests = userRep.GetAllHolidayRequests(); holidaysViewModel.UnapprovedholidayRequests = userRep.GetUnapprovedHolidayRequests(); holidaysViewModel.UserholidayRequests = userRep.GetUserHolidayRequests(Convert.ToInt32(HttpContext.Session.GetInt32("id"))); return(View("Holidays", holidaysViewModel)); }
public IActionResult Holidays() { base.CheckForLogin(); UserRepository userRep = new UserRepository(new UserSQLContext()); HolidaysViewModel holidaysViewModel = new HolidaysViewModel((userRep.GetUser(Convert.ToInt32(HttpContext.Session.GetInt32("id"))).Role.Rights.Any(f => f.Id == 8) ? true : false), userRep.GetAllHolidayRequests(), userRep.GetUnapprovedHolidayRequests(), userRep.GetUserHolidayRequests(Convert.ToInt32(HttpContext.Session.GetInt32("id")))); return(View(holidaysViewModel)); }
public IActionResult GetHolidays() { try { var viewModel = new HolidaysViewModel { Holidays = holidayService.GetAll() }; return(PartialView("_GetHolidays", viewModel)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IActionResult Index() { try { var viewModel = new HolidaysViewModel { Holidays = holidayService.GetAll() }; return(View(viewModel)); } catch (Exception e) { return(BadRequest(e.Message)); } }
/// <summary> /// Executes once LoadRequest has executed. Will also happen when deserializing cached data /// </summary> public override object Deserialize(DayLoadContext loadContext, Type objectType, Stream stream) { if (stream == null) throw new ArgumentNullException("stream"); string html = PageParser.GetHtml(stream); var holidays = PageParser.ExtractHolidaysFromHtml(html); var viewModel = new HolidaysViewModel(loadContext); foreach (Entry entry in holidays) { viewModel.Holidays.Add(entry); } return viewModel; }
/// <summary> /// Executes once LoadRequest has executed. Will also happen when deserializing cached data /// </summary> public override object Deserialize(DayLoadContext loadContext, Type objectType, Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } string html = PageParser.GetHtml(stream); var holidays = PageParser.ExtractHolidaysFromHtml(html); var viewModel = new HolidaysViewModel(loadContext); foreach (Entry entry in holidays) { viewModel.Holidays.Add(entry); } return(viewModel); }
public ActionResult Create(HolidaysViewModel model) { if (ModelState.IsValid) { var Holidays = new Domain.Staff.Entities.Holidays(); AutoMapper.Mapper.Map(model, Holidays); Holidays.IsDeleted = false; Holidays.CreatedUserId = WebSecurity.CurrentUserId; Holidays.ModifiedUserId = WebSecurity.CurrentUserId; Holidays.CreatedDate = DateTime.Now; Holidays.ModifiedDate = DateTime.Now; HolidaysRepository.InsertHolidays(Holidays); TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess; return(RedirectToAction("Index")); } return(View(model)); }
public TimeTrackingTabsViewModel(SKDTabItems skdTabItems) { SKDTabItems = skdTabItems; EditFilterCommand = new RelayCommand(OnEditFilter, CanEditFilter); DayIntervalsViewModel = new DayIntervalsViewModel(); ScheduleSchemesViewModel = new ScheduleSchemesViewModel(); HolidaysViewModel = new HolidaysViewModel(); SchedulesViewModel = new SchedulesViewModel(); TimeTrackingViewModel = new TimeTrackingViewModel(); if (CanSelectDayIntervals) IsDayIntervalsSelected = true; else if (CanSelectScheduleSchemes) IsScheduleSchemesSelected = true; else if (CanSelectHolidays) IsHolidaysSelected = true; else if (CanSelectSchedules) IsSchedulesSelected = true; else if (CanSelectTimeTracking) IsTimeTrackingSelected = true; }
public override void CreateViewModels() { SKDManager.UpdateConfiguration(); ServiceFactory.Events.GetEvent<ShowSkudEvent>().Unsubscribe(OnShowSkud); ServiceFactory.Events.GetEvent<ShowSkudEvent>().Subscribe(OnShowSkud); _skudViewModel = new SkudViewModel(); _employeeCardIndexViewModel = new EmployeeCardIndexViewModel(); _employeeDepartmentsViewModel = new EmployeeDepartmentsViewModel(); _employeeGroupsViewModel = new EmployeeGroupsViewModel(); _employeePositionsViewModel = new EmployeePositionsViewModel(); _passCardDesignerViewModel = new PassCardsDesignerViewModel(); DevicesViewModel = new DevicesViewModel(); LibraryViewModel = new LibraryViewModel(); TimeIntervalsViewModel = new TimeIntervalsViewModel(); SlideDayIntervalsViewModel = new SlideDayIntervalsViewModel(); SlideWeekIntervalsViewModel = new SlideWeekIntervalsViewModel(); WeeklyIntervalsViewModel = new WeeklyIntervalsViewModel(); HolidaysViewModel = new HolidaysViewModel(); }
public ActionResult Edit(int?Id) { var Holidays = HolidaysRepository.GetHolidaysById(Id.Value); if (Holidays != null && Holidays.IsDeleted != true) { var model = new HolidaysViewModel(); AutoMapper.Mapper.Map(Holidays, model); //if (model.CreatedUserId != Erp.BackOffice.Helpers.Common.CurrentUser.Id && Erp.BackOffice.Helpers.Common.CurrentUser.UserTypeId != 1) //{ // TempData["FailedMessage"] = "NotOwner"; // return RedirectToAction("Index"); //} return(View(model)); } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.AbsoluteUri)); } return(RedirectToAction("Index")); }
public ViewResult Create() { var model = new HolidaysViewModel(); return(View(model)); }
public HolidaysMenuViewModel(HolidaysViewModel context) { Context = context; }
protected static void CreateViewModel() { viewModel = new HolidaysViewModel(); }