public IActionResult Post([FromBody] CreateUserDto createUserDto) { return(_mapper.Map <User>(createUserDto) .Map(_userService.Create) .Map(() => AllOk()) .Reduce(BadRequestErrorHandler, err => err is FormatError) .Reduce(InternalServisErrorHandler)); //ako bude greska vrati u lambdu }
public IActionResult Post([FromBody] CreateUserDto createUserDto) => _mapper.Map <User>(createUserDto) .Map(_userService.RegisterUser) .Map(() => AllOk()) .Reduce(this.BadRequestErrorHandler, EmailAlreadyUsed) .Reduce(this.InternalServisErrorHandler);
public IActionResult Post([FromBody] RecipeInsertModelDto recipe) => _mapper.Map <RecipeInsertModel>(recipe) .Map(_commandRepository.Insert) .Map(x => Created(new { id = x })) .Reduce(_ => BadRequest(), error => error is ArgumentNotSet) .Reduce(_ => InternalServerError(), x => _logger.LogError(x.ToString()));
public IActionResult Post([FromBody] CreateDailyMenuDto model) => _mapper.Map <DailyMenuInsertModel>(model) .Map(_commandRepo.Insert) .Map(x => Created(new { id = x })) .Reduce(_ => BadRequest(), error => error is ArgumentNotSet) .Reduce(_ => InternalServerError(), x => _logger.LogError(x.ToString()));
public IActionResult Post([FromBody] CreateFoodDto model) => _mapper.Map <FoodInsertModel>(model) .Map(_foodCommandRepository.Insert) .Map(x => AllOk(new { id = x })) .Reduce(_ => BadRequest(), error => error is ArgumentNotSet, x => _logger.LogError(x.ToString())) .Reduce(_ => InternalServerError(), x => _logger.LogError(x.ToString()));