public async Task <IActionResult> UpdateAsync(int id, [FromBody] SavePlanResource resource) { var plan = _mapper.Map <SavePlanResource, Plan>(resource); var result = await _planService.UpdateAsync(id, plan); if (!result.Success) { return(BadRequest(result.Message)); } var planResource = _mapper.Map <Plan, PlanResource>(result.Resource); return(Ok(planResource)); }
public async Task <IActionResult> PostAsync([FromBody] SavePlanResource resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var plan = _mapper.Map <SavePlanResource, Plan>(resource); var result = await _planService.SaveAsync(plan); if (!result.Success) { return(BadRequest(result.Message)); } var planResouce = _mapper.Map <Plan, PlanResource>(result.Resource); return(Ok(planResouce)); }