Пример #1
0
 public ActionResult Delete(ColorDTO entity)
 {
     try
     {
         Color color = colorRepository.GetById(entity.ColorID);
         colorRepository.Delete(color);
         colorRepository.Save();
         return(Json(entity, JsonRequestBehavior.DenyGet));
     }
     catch (Exception e)
     {
         return(Json(false, JsonRequestBehavior.DenyGet));
     }
 }
 private Product CreateProduct(ProductNewViewModel viewModel, string fileName)
 {
     return(new Product
     {
         Title = viewModel.Title,
         Color = _colorRepository.GetById(viewModel.SelectedColorId),
         Company = _companyRepository.GetById(viewModel.SelectedCompanyId),
         Price = viewModel.Price,
         InStock = viewModel.InStock,
         ShortDescription = viewModel.ShortDescription,
         LongDescription = viewModel.LongDescription,
         SubCategory = _subCategoryRepository.GetById(viewModel.SelectedSubCategoryId),
         Warranty = viewModel.WarrantyYears,
         imgTitle = fileName
     });
 }
Пример #3
0
        public ColorDto DeleteColor(int id)
        {
            var colorModel = _repo.GetById(id);

            if (colorModel == null)
            {
                return(null);
            }

            var res = _repo.Delete(colorModel);

            if (res <= 0)
            {
                return(null);
            }
            return(_mapper.Map <ColorDto>(colorModel));
        }
Пример #4
0
        public async Task <ColorModel> GetColorById(int id)
        {
            var entity = await _colorRepository.GetById(id);

            var model = entity?.MapTo <ColorModel>();

            return(model);
        }
Пример #5
0
        public ProductDetailDto GetProductDetail(int id)
        {
            var detail = _repo.GetById(id);

            detail.Color   = _colorRepo.GetById(detail.ColorId);
            detail.Size    = _sizeRepo.GetById(detail.SizeId);
            detail.Product = _productRepo.GetById(detail.ProductId);
            return(_mapper.Map <ProductDetailDto>(detail));
        }
Пример #6
0
        public ColorItemResponse Item([FromBody] ColorItemRequest request)
        {
            ColorItemResponse response = new ColorItemResponse();

            if (request.Id <= 0)
            {
                response.Status = -1;
                return(response);
            }

            ColorEntity entity = colorRepository.GetById(request.Id);

            if (entity == null)
            {
                response.Status = 404;
                return(response);
            }

            response.Item = colorConvertor.toExtendedVo(entity);

            response.Status = 1;
            return(response);
        }
Пример #7
0
        public Color GetColor(Guid id)
        {
            var color = colorRepository.GetById(id);

            return(color);
        }