Esempio n. 1
0
 public InvLib.ProductEdit Update(InvLib.ProductEdit obj)
 {
     if (obj.IsNew)
     {
         var newId = (from r in MockDb.ProductData select r.Id).Max() + 1;
         LoadProperty(obj, InvLib.ProductEdit.IdProperty, newId);
         var p = new ProductData {
             Id = newId, Name = obj.Name, Price = obj.Price, CategoryId = obj.CategoryId
         };
         MockDb.ProductData.Add(p);
         MarkOld(obj);
     }
     else if (obj.IsDeleted)
     {
         Delete(new SingleCriteria <InvLib.ProductEdit, int>(obj.Id));
         MarkNew(obj);
     }
     else
     {
         var p = (from r in MockDb.ProductData where r.Id == obj.Id select r).Single();
         p.Name       = obj.Name;
         p.Price      = obj.Price;
         p.CategoryId = obj.CategoryId;
         MarkOld(obj);
     }
     return(obj);
 }
Esempio n. 2
0
 public InvLib.ProductEdit Create()
 {
   var item = new InvLib.ProductEdit();
   item.CategoryId = 3;
   CheckRules(item);
   return item;
 }
Esempio n. 3
0
        public InvLib.ProductEdit Create()
        {
            var item = new InvLib.ProductEdit();

            item.CategoryId = 3;
            CheckRules(item);
            return(item);
        }
        public void UpdateItem(InvLib.ProductEdit product)
        {
            var item = Model.Where(r => r.Id == product.Id).FirstOrDefault();

            if (item != null)
            {
                item.UpdateItem(product);
            }
        }
Esempio n. 5
0
 public InvLib.ProductEdit Fetch(SingleCriteria<InvLib.ProductEdit, int> criteria)
 {
   var item = new InvLib.ProductEdit();
   using (BypassPropertyChecks(item))
   {
     var p = (from r in MockDb.ProductData where r.Id == criteria.Value select r).Single();
     LoadProperty(item, InvLib.ProductEdit.IdProperty, p.Id);
     item.Name = p.Name;
     item.Price = p.Price;
     item.CategoryId = p.CategoryId;
   }
   MarkOld(item);
   return item;
 }
Esempio n. 6
0
        public InvLib.ProductEdit Fetch(SingleCriteria <InvLib.ProductEdit, int> criteria)
        {
            var item = new InvLib.ProductEdit();

            using (BypassPropertyChecks(item))
            {
                var p = (from r in MockDb.ProductData where r.Id == criteria.Value select r).Single();
                LoadProperty(item, InvLib.ProductEdit.IdProperty, p.Id);
                item.Name       = p.Name;
                item.Price      = p.Price;
                item.CategoryId = p.CategoryId;
            }
            MarkOld(item);
            return(item);
        }