public IActionResult Edit(LikeAbleAreasViewModel model) { var like = _mapper.Map <LikeAbleAreasViewModel, LikeableArea>(model); if (model == null) { return(NotFound()); } if (ModelState.IsValid) { var updateLike = _aboutRepository.GetLikeAreById(model.Id); updateLike.ModifiedBy = _admin.Name; updateLike.ModifiedDate = DateTime.Now; if (model.File != null) { like.Photo = _fileManager.Upload(model.File); } else { like.Photo = updateLike.Photo; } _aboutRepository.UpdateLikeArea(updateLike, like); return(RedirectToAction("index")); } return(View(model)); }
public IActionResult Create(LikeAbleAreasViewModel model) { ViewBag.About = _aboutRepository.GetAboutFull(); if (model == null) { return(NotFound()); } if (ModelState.IsValid) { var like = _mapper.Map <LikeAbleAreasViewModel, LikeableArea>(model); like.AddedBy = _admin.Name; like.AddedDate = DateTime.Now; if (model.File != null) { like.Photo = _fileManager.Upload(model.File); } else { like.Photo = null; } _aboutRepository.AddLikeAble(like); return(RedirectToAction("index")); } return(View(model)); }