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 }); }
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)); }
public async Task <ColorModel> GetColorById(int id) { var entity = await _colorRepository.GetById(id); var model = entity?.MapTo <ColorModel>(); return(model); }
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)); }
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); }
public Color GetColor(Guid id) { var color = colorRepository.GetById(id); return(color); }