Ejemplo n.º 1
0
        public ActionResult AddDegree(DegreeViewModel model)
        {
            if (SiteConfiguration.IsDemoMode)
            {
                DisplayMessage("You can't save changes in demo mode.", MessageType.Warning);
                return RedirectToAction("AddDegree");
            }

            if (ModelState.IsValid)
            {
                var degree = Mapper.Map<Degree>(model);
                var result = adminService.AddDegree(degree);

                if (result.Success)
                {
                    DisplayMessage(Translations.Validations.ItemAdded, MessageType.OK);
                    return RedirectToAction("Degrees");
                }
            }

            AddError(Translations.Validations.ErrorTryLater);
            return RedirectToAction("AddDegree");
        }
Ejemplo n.º 2
0
        public ActionResult EditDegree(DegreeViewModel model, int id)
        {
            if (SiteConfiguration.IsDemoMode)
            {
                DisplayMessage("You can't save changes in demo mode.", MessageType.Warning);
                return RedirectToAction("EditDegree", new { id = id });
            }

            if (ModelState.IsValid)
            {
                var degree = Mapper.Map<Degree>(model);
                degree.UpdatedByUserID = CurrentUser.Id;

                var result = adminService.UpdateDegree(degree);

                if (result.Success)
                    DisplayMessage(Translations.Validations.ItemUpdated, MessageType.Information);
                else
                    DisplayMessage(Translations.Validations.ErrorTryLater, MessageType.Error);
            }

            return RedirectToAction("EditDegree", new { id = id });
        }
Ejemplo n.º 3
0
        public ActionResult AddDegree()
        {
            var model = new DegreeViewModel();
            model.DegreeCount = adminService.GetDegreeCount();
            model.AvailableLanguages = adminService.GetAvailableLanguages();
            model.SortOrder = model.DegreeCount;

            return View(model);
        }