Beispiel #1
0
        public static BaseResponse CreateNotFoundResponse(long id, ITranslationProvider translationProvider)
        {
            BaseResponse response = new BaseResponse();

            response.Success = false;
            response.Message = string.Format(translationProvider.GetTranslation(Translations.ItemWithIdXNotFound).Text, id);
            return(response);
        }
Beispiel #2
0
 public static BaseResponse CreateOkResponse(ITranslationProvider translationProvider)
 {
     return(new BaseResponse
     {
         Message = translationProvider.GetTranslation(Translations.EverythingOk).Text,
         Success = true
     });
 }
        public static BaseResponseWithItem <T> CreateOkResponse(T item, ITranslationProvider translationProvider)
        {
            BaseResponseWithItem <T> response = new BaseResponseWithItem <T>();

            response.Success = true;
            response.Message = translationProvider.GetTranslation(Translations.EverythingOk).Text;
            response.Item    = item;
            return(response);
        }
Beispiel #4
0
        private BaseResponse ValidateProductDto(ProductDto productDto)
        {
            BaseResponse baseResponse = new BaseResponse();

            baseResponse.Success = true;

            if (string.IsNullOrEmpty(productDto.Name))
            {
                baseResponse.Success = false;
                baseResponse.Message = translationProvider.GetTranslation(Translations.NameIsRequired).Text;
                return(baseResponse);
            }

            if (productDto.Price <= 0)
            {
                baseResponse.Success = false;
                baseResponse.Message = translationProvider.GetTranslation(Translations.PriceMustBeBiggerThanZero).Text;
                return(baseResponse);
            }

            return(baseResponse);
        }