public ActionResult CreateHoliday(SystemViewModels.AdmHelgdagViewModel model) { if (ModelState.IsValid) { try { var userName = User.Identity.GetUserName(); AdmHelgdag holiday = new AdmHelgdag() { InformationsId = model.SelectedInformationId, Helgdatum = model.Helgdatum, Helgdag = model.Helgdag }; _portalSosService.SkapaHelgdag(holiday, userName); } catch (Exception e) { Console.WriteLine(e); ErrorManager.WriteToErrorLog("SystemController", "CreateHoliday", e.ToString(), e.HResult, User.Identity.Name); var errorModel = new CustomErrorPageModel { Information = "Ett fel inträffade när ny helgdag skulle läggas till.", ContactEmail = ConfigurationManager.AppSettings["ContactEmail"], }; return(View("CustomError", errorModel)); } return(RedirectToAction("GetHolidays")); } return(View()); }
public void UpdateHoliday(AdmHelgdag holiday) { var holidayDb = DbContext.AdmHelgdag.Where(x => x.Id == holiday.Id).Select(x => x).SingleOrDefault(); holidayDb.Helgdatum = holiday.Helgdatum; holidayDb.Helgdag = holiday.Helgdag; holidayDb.AndradDatum = holiday.AndradDatum; holidayDb.AndradAv = holiday.AndradAv; DbContext.SaveChanges(); }
private AdmHelgdag ConvertViewModelToAdmHelgdag(SystemViewModels.AdmHelgdagViewModel holiday) { var holidayDb = new AdmHelgdag() { Id = holiday.Id, InformationsId = _portalSosService.HamtaInfoText(holiday.Informationstyp).Id, Helgdatum = holiday.Helgdatum, Helgdag = holiday.Helgdag }; return(holidayDb); }
public void CreateHoliday(AdmHelgdag holiday) { DbContext.AdmHelgdag.Add(holiday); DbContext.SaveChanges(); }