public async Task <IActionResult> EditPlan(long planId, [FromBody] EditPlanModel model) { try { model.Id = planId; var result = await planLib.EditPlanAsync(model, CurrentUserId); return(CustomResult(result)); } catch (System.Exception exp) { return(CustomError(exp)); } }
public async Task <PlanModel> EditPlanAsync(EditPlanModel model, long userId) { var entity = await planRepo.FirstAsync(x => x.Id == model.Id && x.UserId == userId); if (entity == null) { throw new Exception("Plan not exist!"); } entity.Description = model.Description; entity.EndDate = model.EndDate; entity.Name = model.Name; entity.StartDate = model.StartDate; await unitOfWork.CommitAsync(); return(ConvertEntityToPlanModel(entity)); }