public CreateResponse Create(IngredientGroupRequest request) { try { var ingredientGroup = TypeAdapter.Adapt <IngredientGroup>(request); _ingredientGroupValidator.ValidateAndThrowException(ingredientGroup, "Base"); _ingredientGroupRepository.Add(ingredientGroup); return(new CreateResponse(ingredientGroup.Id)); } catch (DataAccessException) { throw new ApplicationException(); } }
public SuccessResponse Update(IngredientGroupRequest request) { try { var currentIngredientGroup = _ingredientGroupRepository.FindBy(request.Id); currentIngredientGroup.ThrowExceptionIfRecordIsNull(); var ingredientGroupToCopy = TypeAdapter.Adapt <IngredientGroup>(request); TypeAdapter.Adapt(ingredientGroupToCopy, currentIngredientGroup); _ingredientGroupValidator.ValidateAndThrowException(currentIngredientGroup, "Base"); _ingredientGroupRepository.Update(currentIngredientGroup); return(new SuccessResponse { IsSuccess = true }); } catch (DataAccessException) { throw new ApplicationException(); } }
public SuccessResponse Put(IngredientGroupRequest request) { return(_ingredientGroupService.Update(request)); }
public CreateResponse Post(IngredientGroupRequest request) { return(_ingredientGroupService.Create(request)); }