コード例 #1
0
        public string CheckAppliancesInputModel(AppliancesInputModel inputModel)
        {
            DataWrapper <int> dataWrapper;

            if (string.IsNullOrWhiteSpace(inputModel.Model))
            {
                return("Enter the model name");
            }
            dataWrapper = _repo.CheckModelAvailability(inputModel.Model);
            if (dataWrapper.Data != 0)
            {
                return("This model already exists, maybe it lies in remote");
            }
            if (string.IsNullOrWhiteSpace(inputModel.Company))
            {
                return("Enter the company name");
            }
            if (string.IsNullOrWhiteSpace(inputModel.Country))
            {
                return("Enter the country");
            }
            if (inputModel.ProductionYear == null)
            {
                return("Enter the production year");
            }
            if (inputModel.Price == null)
            {
                return("Enter the price");
            }
            return("");
        }
コード例 #2
0
        public ActionResult <AppliancesShortcutOutputModel> AddNewProduct(AppliancesInputModel inputModel)
        {
            var validationResult = _validator.CheckAppliancesInputModel(inputModel);

            if (!string.IsNullOrWhiteSpace(validationResult))
            {
                return(BadRequest(validationResult));
            }
            var dataWrapper = _repo.AddProduct(_mapper.Map <AppliancesDto>(inputModel));

            return(MakeResponse(dataWrapper));
        }