예제 #1
0
 public int setType(int productID, Resource.ProductType type)
 {
     DB.Models.ProductType dbProductType = mapper.Map <DB.Models.ProductType>(type);
     DB.Models.Product     product       = _context.Product.Where(p => p.ID == productID).SingleOrDefault();
     if (product == null)
     {
         return(0);
     }
     _context.Attach(dbProductType);
     product.ProductType = dbProductType;
     _context.Update(product);
     return(_context.SaveChanges());
 }
예제 #2
0
 public Resource.ProductType getType(int productID)
 {
     //TODO not null defense
     DB.Models.ProductType productBrand = _context.Product.Include(p => p.ProductType).Where(p => p.ID == productID).Select(p => p.ProductType).SingleOrDefault();
     return(mapper.Map <API.Resource.ProductType>(productBrand));
 }