Esempio n. 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);
        }
Esempio n. 2
0
 public static BaseResponse CreateOkResponse(ITranslationProvider translationProvider)
 {
     return(new BaseResponse
     {
         Message = translationProvider.GetTranslation(Translations.EverythingOk).Text,
         Success = true
     });
 }
Esempio n. 3
0
        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);
        }
Esempio n. 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);
        }