Esempio n. 1
0
 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();
     }
 }
Esempio n. 2
0
 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();
     }
 }
Esempio n. 3
0
 public SuccessResponse Put(IngredientGroupRequest request)
 {
     return(_ingredientGroupService.Update(request));
 }
Esempio n. 4
0
 public CreateResponse Post(IngredientGroupRequest request)
 {
     return(_ingredientGroupService.Create(request));
 }