public ActionResult Edit(PostCreateViewModel current) { if (ModelState.IsValid) { var model = current.ToPostCreateModel(); model.AuthorId = UserManager.GetUserId(User.Identity.Name); EntityAction result = service.Update(model); if (result == EntityAction.Updated) { current.State = ActionState.Success; current.Message = ApplicationMessages.UpdateSuccess; } } else { current.State = ActionState.Error; current.Message = ApplicationMessages.ErrorHasBeen; } return(View("Create", current)); }
public ActionResult Create(PostCreateViewModel current) { if (ModelState.IsValid) { current.SendDate = PersianDate.Now; var model = current.ToPostCreateModel(); model.AuthorId = UserManager.GetUserId(User.Identity.Name); EntityAction result = service.Create(model); if (result == EntityAction.Added) { current.State = ActionState.Success; current.Message = ApplicationMessages.InsertSuccess; } } else { current.State = ActionState.Error; current.Message = ApplicationMessages.ErrorHasBeen; } return(View(current)); }