public ActionResult CreatePost(CreateArticleView model) { if (ModelState.IsValid) { try { var entity = Mapper.Map <Article>(model); _unitOfWork.ArticleRepository.Insert(entity); _unitOfWork.Save(); return(RedirectToAction("Index")); } catch (Exception ex) { throw new Exception(ex.Message); } } return(RedirectToAction("Create")); }
public ActionResult Create(CreateArticleView model) { model.ArticleCategory = _unitOfWork.ArticleCategoryRepository.Get() .Where(x => x.Id != Guid.Empty) .Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }).ToList(); model.Users = _unitOfWork.UserRepository.Get() .Where(x => x.Id != Guid.Empty) .Select(x => new SelectListItem { Text = x.LoginName, Value = x.Id.ToString() }).ToList(); return(View(model)); }