public void UpdateProduct(Product Product)
 {
     using (CBContext db1 = new CBContext())
     {
         db1.Entry(Product.Category).State = System.Data.Entity.EntityState.Unchanged;
         db1.Entry(Product).State          = System.Data.Entity.EntityState.Modified;
         db1.SaveChanges();
     }
 }
 public void SaleProductsDeductedFromStock(StockInventry stock)
 {
     using (var context = new CBContext())
     {
         if (context.StockInventries.Any(x => x.ProductId == stock.ProductId && x.BatchNo == stock.BatchNo && x.Stock > stock.Stock))
         {
             var data = context.StockInventries.Where(x => x.ProductId == stock.ProductId && x.BatchNo == stock.BatchNo).FirstOrDefault();
             data.Stock       = (data.Stock - stock.Stock);
             data.TotalAmount = (data.TotalAmount - stock.TotalAmount);
             data.Sale        = (data.Sale + stock.Sale);
             data.LooseSale   = (data.LooseSale + stock.LooseSale);
             //code to minus the pack if loose sale is equal to pack size
             var temp = context.Products.Where(x => x.Id == stock.ProductId && x.BatchNo == stock.BatchNo).FirstOrDefault();
             if (data.LooseSale >= temp.PackSize)
             {
                 data.Stock     = data.Stock - 1;
                 data.Sale      = data.Sale + 1;
                 data.LooseSale = (int)(data.LooseSale - temp.PackSize);
             }
             //ends here
             context.Entry(data).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
         }
     }
 }
        public IHttpActionResult PutReplies(int id, Reply reply)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != reply.Id)
            {
                return(BadRequest());
            }

            db.Entry(reply).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ReplyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 4
0
        public void UpdateProduct(Product product)
        {
            using (var context = new CBContext())
            {
                //While Edit Product, Category of Product is not changing.It can be fixed by this approach
                //Take Product from Database and update its properties from the supplied product object
                //Problem occured!!new category is added while editing a product category,Lets fix this by taking another strategy


                //var productInDb = context.Products.Where(x => x.ID == product.ID).FirstOrDefault();

                //productInDb.Name = product.Name;
                //productInDb.Description = product.Description;

                //productInDb.Price = product.Price;

                //productInDb.Category = product.Category; //For this reason,new category is added while editing a product category,Lets fix this by taking another strategy

                ////If imageurl is empty don't update it
                //if (!string.IsNullOrEmpty(product.ImageURL))
                //{
                //    productInDb.ImageURL = product.ImageURL;
                //}

                //context.Entry(productInDb).State = System.Data.Entity.EntityState.Modified;
                ////context.Categories.Remove(category);
                //context.SaveChanges();

                context.Entry(product).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
            }
        }
Esempio n. 5
0
        public IHttpActionResult PutPost(int id, [FromBody] Post post)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != post.Id)
            {
                return(BadRequest());
            }

            db.Entry(post).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PostExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public void Update(DispensaryDrugTable edit)
 {
     using (var context = new CBContext())
     {
         context.Entry(edit).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Esempio n. 7
0
 public void UpdateWishlist(WishList Wishlist)
 {
     using (var context = new CBContext())
     {
         context.Entry(Wishlist).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Esempio n. 8
0
 public void UpdateConfig(Config config)
 {
     using (var context = new CBContext())
     {
         context.Entry(config).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void UpdateProduct(Product product)
 {
     using (var context = new CBContext())
     {   //take product from database and update its properies
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Esempio n. 10
0
 public void UpdateConfig(Config configuration)
 {
     using (var db = new CBContext())
     {
         db.Entry(configuration).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 11
0
 public void DeleteProduct(Product product)
 {
     using (var context = new CBContext()) {
         context.Entry(product).State = System.Data.Entity.EntityState.Deleted;
         //context.catagories.Remove(catagory);
         context.SaveChanges();
     }
 }
 public void UpdateProduct(Product product)
 {
     using (CBContext context = new CBContext())
     {
         context.Entry(product).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void UpdateStudent(Student product)
 {
     using (var context = new CBContext())
     {
         context.Entry(product).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Esempio n. 14
0
 public void Update(DispensaryServices dispensaryServices)
 {
     using (var context = new CBContext())
     {
         context.Entry(dispensaryServices).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void UpdateCategory(Category category)
 {
     using (CBContext db = new CBContext())
     {
         db.Entry(category).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 16
0
 public void Update(AppointmentList appointmentList)
 {
     using (var context = new CBContext())
     {
         context.Entry(appointmentList).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void Update(WeeklyDoctorList weeklyDoctorList)
 {
     using (var context = new CBContext())
     {
         context.Entry(weeklyDoctorList).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Esempio n. 18
0
 public void UpdateCategory(Category category)
 {
     using (var context = new CBContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Esempio n. 19
0
 public void SaveProduct(Product Product)
 {
     using (CBContext db = new CBContext()) {
         db.Entry(Product.Category).State = System.Data.Entity.EntityState.Unchanged;
         db.Products.Add(Product);
         db.SaveChanges();
     }
 }
 public void UpdateCategory(Category category)
 {
     using (CBContext context = new CBContext())
     {
         context.Entry(category).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Esempio n. 21
0
 public void UpdateProduct(Product product)
 {
     using (var context = new CBContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void UpdateReturnItem(OrderItem item)
 {
     using (var context = new CBContext())
     {
         context.Entry(item).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Esempio n. 23
0
        public void Update(Category entity)
        {
            var old = Get(entity.ID);

            old.Name            = entity.Name;
            old.Description     = entity.Description;
            db.Entry(old).State = System.Data.Entity.EntityState.Modified;
            SaveChanges();
        }
Esempio n. 24
0
 public void AddScreper(ScreperURL screperURL)
 {
     using (var context = new CBContext())
     {
         context.Entry(screperURL).State = System.Data.Entity.EntityState.Unchanged;
         context.ScreperURLs.Add(screperURL);
         context.SaveChanges();
     }
 }
Esempio n. 25
0
 public void SaveProduct(Product product)
 {
     using (var context = new CBContext())
     {
         context.Entry(product.catagory).State = System.Data.Entity.EntityState.Unchanged;
         context.products.Add(product);
         context.SaveChanges();
     }
 }
Esempio n. 26
0
        public void EditProduit(Produit cat)
        {
            using (var context = new CBContext())
            {
                context.Entry(cat).State = System.Data.Entity.EntityState.Modified;

                context.SaveChanges();
            }
        }
Esempio n. 27
0
 // Save Product
 public void SaveProduct(Product product)
 {
     using (var context = new CBContext())
     {
         context.Entry(product.Category).State = EntityState.Unchanged;
         context.Products.Add(product);
         context.SaveChanges();
     }
 }
 public bool UpdateOrderStatus(int ID, string status)
 {
     using (var context = new CBContext())
     {
         var order = context.Orders.Find(ID);
         order.Status = status;
         context.Entry(order).State = EntityState.Modified;
         return(context.SaveChanges() > 0);
     }
 }
 public void SaveProduct(Product product)
 {
     //  use   ( Reposetory)
     using (var context = new CBContext())
     {
         context.Entry(product.Category).State = System.Data.Entity.EntityState.Unchanged;
         context.Products.Add(product);
         context.SaveChanges();
     }
 }
Esempio n. 30
0
        public void SaveProduct(Product product)
        {
            using (var context = new CBContext()) // create an object of 'CBContext'
            {
                // keep category unchanged becasue we dont want to create another category with every product that we add
                context.Entry(product.Category).State = System.Data.Entity.EntityState.Unchanged;

                context.Products.Add(product); // add 'category' argument to the database 'Categories', will be stored in memory not in database yet
                context.SaveChanges();         // will save it into the database
            }
        }