public IActionResult Create(BlogWriterViewModel model) { if (ModelState.IsValid) { var writer = _mapper.Map <BlogWriterViewModel, BlogWriter>(model); writer.AddedBy = _admin.Fullname; _blogRepository.CreateBLogWriter(writer); return(RedirectToAction("index")); } return(View(model)); }
public IActionResult Edit(BlogWriterViewModel model) { if (ModelState.IsValid) { var blogWriter = _mapper.Map <BlogWriterViewModel, BlogWriter>(model); var writerToUpdate = _blogRepository.GetBlogWriterById(model.Id); if (writerToUpdate == null) { return(NotFound()); } writerToUpdate.ModifiedBy = _admin.Fullname; _blogRepository.UpdateBlogWriter(writerToUpdate, blogWriter); return(RedirectToAction("index")); } return(View(model)); }