public ActionResult Create(Reason model) { try { model.Id = 0; var article = new Reason { Title = model.Title, TitleEng = model.TitleEng, Text = model.Text == null ? "" : HttpUtility.HtmlDecode(model.Text), TextEng = model.TextEng == null ? "" : HttpUtility.HtmlDecode(model.TextEng), SortOrder = model.SortOrder }; _repository.AddReason(article); } catch (Exception ex) { TempData["errorMessage"] = ex.Message + (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message) ? ex.InnerException.Message : ""); return View(model); } return RedirectToAction("Index"); }
public int AddReason(Reason reason) { _store.Reasons.Add(reason); _store.SaveChanges(); return reason.Id; }
public void SaveReason(Reason reason) { //var cache = _store.Reasons.SingleOrDefault(a => a.Id == reason.Id); _store.SaveChanges(); }