public async Task <PlanView> AddPlanAsync(NewPlanInput input) { var entity = input.ToEntity(); var result = _planRepository.Add(entity); var planEntity = await result.ProjectToPlanView().FirstOrDefaultAsync(); var item = planEntity; return(item); }
public async Task <ActionResult <PlanView> > Add([FromBody] NewPlanInput newPlanInput) { try { var validationResult = _newPlanInputValidator.Validate(newPlanInput); if (validationResult.IsValid) { var result = await _planService.AddPlanAsync(newPlanInput); return(result); } return(BadRequest()); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }