Exemplo n.º 1
0
        public ActionResult CreateInformationText(SystemViewModels.InfoTextViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var userName = User.Identity.GetUserName();
                    var infoText = new AdmInformation
                    {
                        Informationstyp = model.Informationstyp,
                        Text            = model.Text,
                    };
                    infoText.Text = model.Text;
                    _portalSosService.SkapaInformationsText(infoText, userName);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    ErrorManager.WriteToErrorLog("SystemController", "CreateInfoText", e.ToString(), e.HResult, User.Identity.Name);
                    var errorModel = new CustomErrorPageModel
                    {
                        Information  = "Ett fel inträffade när ny informationstext skulle sparas.",
                        ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
                    };
                    return(View("CustomError", errorModel));
                }
                return(RedirectToAction("GetInformationTexts"));
            }

            return(View());
        }
Exemplo n.º 2
0
        public ActionResult EditSelectedFAQ(SystemViewModels.SystemViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var userName = User.Identity.GetUserName();

                    AdmFAQ faq = new AdmFAQ
                    {
                        Id            = model.SelectedFAQ.Id,
                        FAQkategoriId = model.SelectedFAQ.FAQkategoriId,
                        RegisterId    = model.SelectedFAQ.RegisterId,
                        Fraga         = model.SelectedFAQ.Fraga,
                        Svar          = model.SelectedFAQ.Svar,
                        Sortering     = model.SelectedFAQ.Sortering
                    };
                    _portalSosService.UppdateraFAQ(faq, userName);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    ErrorManager.WriteToErrorLog("SystemController", "EditSelectedFAQ", e.ToString(), e.HResult, User.Identity.Name);
                    var errorModel = new CustomErrorPageModel
                    {
                        Information  = "Ett fel inträffade när faq skulle sparas.",
                        ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
                    };
                    return(View("CustomError", errorModel));
                }
                return(RedirectToAction("GetFAQs", new { faqCatId = model.SelectedFAQ.FAQkategoriId }));
            }

            return(RedirectToAction("GetFAQs", new { faqCatId = model.SelectedFAQ.FAQkategoriId }));
        }
Exemplo n.º 3
0
        public ActionResult UpdateInfoText(SystemViewModels.SystemViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var userName = User.Identity.GetUserName();

                    AdmInformation info = new AdmInformation
                    {
                        Id   = model.SelectedInfoId,
                        Text = model.SelectedInfoText
                    };
                    _portalSosService.UppdateraInformationstext(info, userName);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    ErrorManager.WriteToErrorLog("SystemController", "UpdateInfoText", e.ToString(), e.HResult,
                                                 User.Identity.Name);
                    var errorModel = new CustomErrorPageModel
                    {
                        Information  = "Ett fel inträffade vid uppdatering av informationstext.",
                        ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
                    };
                    return(View("CustomError", errorModel));
                }
            }
            return(RedirectToAction("GetInformationTexts"));
        }
Exemplo n.º 4
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
                    };
                    _portalSosService.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());
        }
Exemplo n.º 5
0
        public ActionResult CreateFAQCategory(AdmFAQKategori faqCategory)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var userName = User.Identity.GetUserName();
                    _portalSosService.SkapaFAQKategori(faqCategory, userName);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    ErrorManager.WriteToErrorLog("SystemController", "CreateFAQCategory", e.ToString(), e.HResult, User.Identity.Name);
                    var errorModel = new CustomErrorPageModel
                    {
                        Information  = "Ett fel inträffade när ny FAQ-kategori skulle sparas.",
                        ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
                    };
                    return(View("CustomError", errorModel));
                }
                return(RedirectToAction("GetFAQCategories"));
            }

            return(View());
        }
Exemplo n.º 6
0
 public ActionResult UpdateSpecialDay(SystemViewModels.AdmSpecialdagViewModel specialDay)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var userName     = User.Identity.GetUserName();
             var specialDayDb = ConvertViewModelToAdmSpecialdag(specialDay);
             _portalSosService.UppdateraSpecialdag(specialDayDb, userName);
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             ErrorManager.WriteToErrorLog("SystemController", "UpdateSpecialDay", e.ToString(), e.HResult,
                                          User.Identity.Name);
             var errorModel = new CustomErrorPageModel
             {
                 Information  = "Ett fel inträffade vid uppdatering av specialdagsinformation.",
                 ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
             };
             return(View("CustomError", errorModel));
         }
     }
     return(RedirectToAction("GetSpecialDays"));
 }
Exemplo n.º 7
0
 public ActionResult UpdateFAQ(SystemViewModels.SystemViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var userName = User.Identity.GetUserName();
             var faqDb    = ConvertViewModelToAdmFAQ(model.SelectedFAQ);
             _portalSosService.UppdateraFAQ(faqDb, userName);
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             ErrorManager.WriteToErrorLog("SystemController", "UpdateFAQ", e.ToString(), e.HResult,
                                          User.Identity.Name);
             var errorModel = new CustomErrorPageModel
             {
                 Information  = "Ett fel inträffade vid uppdatering av FAQ.",
                 ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
             };
             return(View("CustomError", errorModel));
         }
     }
     return(RedirectToAction("GetFAQs", new { faqCatId = model.SelectedFAQ.FAQkategoriId }));
 }
Exemplo n.º 8
0
        public ActionResult GetOpeningHours()
        {
            var model = new SystemViewModels.OpeningHours();

            try
            {
                var admKonf = _portalSosService.HamtaOppettider();
                model.ClosedAnyway   = admKonf.ClosedAnyway;
                model.ClosedDaysList = _portalSosService.MarkeraStangdaDagar(admKonf.ClosedDays);
                //model.OpeningTime = SetTime(admKonf.ClosedToHour, admKonf.ClosedToMin);
                //model.ClosingTime = SetTime(admKonf.ClosedFromHour, admKonf.ClosedFromMin);
                DateTime s  = DateTime.MinValue;
                TimeSpan ts = new TimeSpan(10, 30, 0);
                model.OpeningTime    = s.Date + ts;
                model.OpeningTimeStr = admKonf.ClosedToHour.ToString() + ":" + admKonf.ClosedToMin.ToString();
                //model.ClosingTime = SetTime(admKonf.ClosedFromHour, admKonf.ClosedFromMin);
                model.ClosingTimeStr        = admKonf.ClosedFromHour.ToString() + ":" + admKonf.ClosedFromMin.ToString();
                model.InfoTextForClosedPage = _portalSosService.HamtaInfoText("Stangtsida").Text;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                ErrorManager.WriteToErrorLog("SystemController", "GetOpeningHours", e.ToString(), e.HResult, User.Identity.Name);
                var errorModel = new CustomErrorPageModel
                {
                    Information  = "Ett fel inträffade vid hämtning av öppettider.",
                    ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
                };
                return(View("CustomError", errorModel));
            }
            return(View("EditOpeningHours", model));
        }
Exemplo n.º 9
0
        public ActionResult SaveOpeningHoursInfo(SystemViewModels.OpeningHours openHours)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var userName = User.Identity.GetUserName();

                    OpeningHoursInfoDTO openHoursDTO = new OpeningHoursInfoDTO();

                    openHoursDTO = SetHoursAndMinutes(openHours);
                    openHoursDTO.ClosedAnyway          = openHours.ClosedAnyway;
                    openHoursDTO.InfoTextForClosedPage = openHours.InfoTextForClosedPage;

                    //Days
                    var daysListDTO = new List <string>();
                    foreach (var day in openHours.ClosedDaysList)
                    {
                        if (day.Selected)
                        {
                            daysListDTO.Add(day.NameEnglish);
                        }
                    }
                    openHoursDTO.ClosedDays = daysListDTO;

                    _portalSosService.SparaOppettider(openHoursDTO, userName);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    ErrorManager.WriteToErrorLog("SystemController", "SaveOpeningHoursInfo", e.ToString(), e.HResult, User.Identity.Name);
                    var errorModel = new CustomErrorPageModel
                    {
                        Information  = "Ett fel inträffade när information om öppettider skulle sparas.",
                        ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
                    };
                    return(View("CustomError", errorModel));
                }
                return(RedirectToAction("GetOpeningHours"));
            }

            //var x = Server.HtmlEncode(openHours.InfoTextForClosedPage);
            return(RedirectToAction("GetOpeningHours"));
        }
Exemplo n.º 10
0
 public ActionResult DeleteSpecialDay(int specialDayId)
 {
     try
     {
         _portalSosService.TaBortSpecialdag(specialDayId);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         ErrorManager.WriteToErrorLog("SystemController", "DeleteSpecialDay", e.ToString(), e.HResult, User.Identity.Name);
         var errorModel = new CustomErrorPageModel
         {
             Information  = "Ett fel inträffade när information om specialdag skulle tas bort.",
             ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
         };
         return(View("CustomError", errorModel));
     }
     return(RedirectToAction("GetSpecialDays"));
 }
Exemplo n.º 11
0
 public ActionResult DeleteFAQ(int faqId, int faqCatId)
 {
     try
     {
         _portalSosService.TaBortFAQ(faqId);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         ErrorManager.WriteToErrorLog("SystemController", "DeleteFAQ", e.ToString(), e.HResult, User.Identity.Name);
         var errorModel = new CustomErrorPageModel
         {
             Information  = "Ett fel inträffade när FAQ skulle tas bort.",
             ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
         };
         return(View("CustomError", errorModel));
     }
     return(RedirectToAction("GetFAQs", new { faqCatId = faqCatId }));
 }
Exemplo n.º 12
0
        public ActionResult GetFAQCategories()
        {
            var model = new SystemViewModels.SystemViewModel();

            try
            {
                model.FAQCategories = _portalSosService.HamtaFAQkategorier();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                ErrorManager.WriteToErrorLog("SystemController", "GetFAQCategories", e.ToString(), e.HResult, User.Identity.Name);
                var errorModel = new CustomErrorPageModel
                {
                    Information  = "Ett fel inträffade vid hämtning av FAQ-kategorier",
                    ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
                };
                return(View("CustomError", errorModel));
            }
            return(View("EditFAQCategory", model));
        }
Exemplo n.º 13
0
        public ActionResult GetSpecialDays()
        {
            var model = new SystemViewModels.SystemViewModel();

            try
            {
                var specialdaysList = _portalSosService.HamtaAllaSpecialdagar();
                model.SpecialDays = ConvertAdmSpecialdagToViewModel(specialdaysList.ToList());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                ErrorManager.WriteToErrorLog("SystemController", "GetSpecialDays", e.ToString(), e.HResult, User.Identity.Name);
                var errorModel = new CustomErrorPageModel
                {
                    Information  = "Ett fel inträffade vid hämtning av specialdagar.",
                    ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
                };
                return(View("CustomError", errorModel));
            }
            return(View("EditSpecialDays", model));
        }
Exemplo n.º 14
0
        public ActionResult GetInformationTexts(string selectedInfoType = "", string selectedText = "")
        {
            var model = new SystemViewModels.SystemViewModel();

            try
            {
                model.InfoPages        = _portalSosService.HamtaInformationstexter();
                model.SelectedInfo     = selectedInfoType;
                model.SelectedInfoText = selectedText;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                ErrorManager.WriteToErrorLog("SystemController", "GetInformationTexts", e.ToString(), e.HResult, User.Identity.Name);
                var errorModel = new CustomErrorPageModel
                {
                    Information  = "Ett fel inträffade vid hämtning av informationstexter.",
                    ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
                };
                return(View("CustomError", errorModel));
            }
            return(View("EditInfoTexts", model));
        }
Exemplo n.º 15
0
        public ActionResult GetFAQs(int faqCatId = 0, string faqCatName = "")
        {
            var model = new SystemViewModels.SystemViewModel();

            try
            {
                var faqs = _portalSosService.HamtaFAQs(faqCatId);
                model.FAQs = ConvertAdmFAQToViewModel(faqs.ToList());
                model.SelectedFAQCategory = faqCatId;
                if (faqCatId != 0 && faqCatName.IsEmpty())
                {
                    var faqCat = _portalSosService.HamtaFAQKategori(faqCatId);
                    model.SelectedFAQCategoryName = faqCat.Kategori;
                }
                else
                {
                    model.SelectedFAQCategoryName = faqCatName;
                }

                // Ladda drop down lists.
                var registerList = _portalSosService.HamtaAllaRegisterForPortalen();
                this.ViewBag.RegisterList = CreateRegisterDropDownList(registerList);
                //model.SelectedFAQ.SelectedRegisterId = 0;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                ErrorManager.WriteToErrorLog("SystemController", "GetFAQs", e.ToString(), e.HResult, User.Identity.Name);
                var errorModel = new CustomErrorPageModel
                {
                    Information  = "Ett fel inträffade vid hämtning av FAQs",
                    ContactEmail = ConfigurationManager.AppSettings["ContactEmail"],
                };
                return(View("CustomError", errorModel));
            }
            return(View("EditFAQs", model));
        }