public IActionResult Edit(ContentModel model) { var content = _contentRepository.GetById(model.Id); if (content == null) { return(RedirectToAction("Index")); } if (ModelState.IsValid) { try { content = model.ToEntity(content, _mapper); _contentRepository.Update(content); //update content and mappings TempData["Message"] = "The content has been updated successfully."; return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Message = ex.ToString(); } } model.Languages = _languageRepository.GetAll().ToList(); return(View(model)); }
public IActionResult Create(ContentModel model) { if (ModelState.IsValid) { try { var content = model.ToEntity(_mapper); content.CreatedBy = "Berkay"; _contentRepository.Insert(content); //create content and mappings _contentRepository.Save(); TempData["Message"] = "The new content has been added successfully."; return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Message = ex.ToString(); } } return(View(model)); }