public ActionResult Create(PageViewModel collection) { try { if (ModelState.IsValid) { var model = _mapper.Map <Page>(collection); model.CreatorId = LogedInAdmin.Id; _pageService.Insert(model); return(RedirectToAction("Index")); } ViewBag.PositionsList = new SelectList(_dropDownService.GetPositions(), "id", "name", null); ModelState.AddModelError(string.Empty, GeneralMessages.DefectiveEntry); } catch (Exception ex) { _logger.Error(ex); if (ex.Message.Contains("duplicate")) { ModelState.AddModelError(string.Empty, GeneralMessages.Duplicated); } else { if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource)) { ModelState.AddModelError(string.Empty, ex.Message); } else { ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError); } } } return(View(collection)); }
// GET: Slider/Create public ActionResult Create() { ViewBag.PositionsList = new SelectList(_dropDownService.GetPositions(), "id", "name", null); return(View()); }