Exemple #1
0
        public ActionResult CreateSpecialDay(SystemViewModels.AdmSpecialdagViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var userName = User.Identity.GetUserName();

                    AdmSpecialdag specialDay = new AdmSpecialdag()
                    {
                        InformationsId  = model.SelectedInformationId,
                        Specialdagdatum = model.Specialdagdatum,
                        Oppna           = model.Oppna,
                        Stang           = model.Stang,
                        Anledning       = model.Anledning
                    };
                    _portalAdminService.SkapaSpecialdag(specialDay, userName);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    ErrorManager.WriteToErrorLog("SystemController", "CreateSpecialDay", e.ToString(), e.HResult, User.Identity.Name);
                    var errorModel = new CustomErrorPageModel
                    {
                        Information  = "Ett fel inträffade när ny specialdag skulle läggas till.",
                        ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
                    };
                    return(View("CustomError", errorModel));
                }
                return(RedirectToAction("GetSpecialDays"));
            }

            return(View());
        }