Esempio n. 1
0
 public int Save(Product product)
 {
     using (var productService = new ProductService())
     {
         return(productService.UpdateProduct(product));
     }
 }
Esempio n. 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);
        }
Esempio n. 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)));
         }
     }
 }
Esempio n. 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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }