コード例 #1
0
ファイル: ProductController.cs プロジェクト: katglin/CartsKO
 public int Save(Product product)
 {
     using (var productService = new ProductService())
     {
         return(productService.UpdateProduct(product));
     }
 }
コード例 #2
0
        public static dto.Product ToDTO(this bll.Product bll)
        {
            dto.Product dto = new dto.Product();

            dto.Id           = bll.Id;
            dto.Name         = bll.Name;
            dto.Code         = bll.Code;
            dto.Manufacturer = bll.Manufacturer;
            dto.Model        = bll.Model;
            dto.Revision     = bll.Revision;
            dto.Description  = bll.Description;
            dto.CreateDate   = bll.CreateDate;
            dto.CreateBy     = bll.CreateBy;

            return(dto);
        }
コード例 #3
0
 public int UpdateProduct(Product product)
 {
     using (var productRepo = new ProductRepository())
     {
         var config = new MapperConfiguration(cfg => cfg.CreateMap <Product, DAL.Models.Product>());
         var mapper = config.CreateMapper();
         if (product.Id > 0)
         {
             return(productRepo.UpdateProduct(mapper.Map <DAL.Models.Product>(product)));
         }
         else
         {
             return(productRepo.CreateProduct(mapper.Map <DAL.Models.Product>(product)));
         }
     }
 }
コード例 #4
0
        public static bll.Product ToBLL(this dto.Product dto)
        {
            bll.Product bll = new bll.Product();

            bll.Id           = dto.Id;
            bll.Name         = dto.Name;
            bll.Code         = dto.Code;
            bll.Manufacturer = dto.Manufacturer;
            bll.Model        = dto.Model;
            bll.Revision     = dto.Revision;
            //bll.Categories = dto.;
            bll.Description = dto.Description;
            bll.CreateDate  = dto.CreateDate;
            bll.CreateBy    = dto.CreateBy;

            return(bll);
        }
コード例 #5
0
ファイル: MyBLL.cs プロジェクト: RomaLagod/InterShop
        public Product GetProductById(int id)
        {
            DAL.Entity.Product product       = _dal.GetProductById(id);
            BLL.Models.Product productResult = null;

            productResult = new BLL.Models.Product
            {
                Id             = product.Id,
                CategoryId     = product.CategoryId,
                ManufacturerId = product.ManufacturerId,
                Name           = product.Name,
                Description    = product.Description,
                Price          = product.Price,
                Keywords       = product.Keywords,
                Quantity       = product.Quantity
            };
            return(productResult);
        }
コード例 #6
0
ファイル: MyBLL.cs プロジェクト: RomaLagod/InterShop
        public ICollection <Product> GetProductsByCategory(int categoryId)
        {
            List <BLL.Models.Product> list = new List <BLL.Models.Product>();

            foreach (var item in _dal.GetProductsByCategory(categoryId))
            {
                var product = new BLL.Models.Product
                {
                    Id             = item.Id,
                    CategoryId     = item.CategoryId,
                    ManufacturerId = item.ManufacturerId,
                    Name           = item.Name,
                    Description    = item.Description,
                    Price          = item.Price,
                    Keywords       = item.Keywords,
                    Quantity       = item.Quantity
                };
                list.Add(product);
            }
            return(list);
        }