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));
        }
Beispiel #2
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));
        }
        private void SaveEncryptItems(string method, string str, string key, string result)
        {
            EncryptItem encryptItem = new EncryptItem();

            encryptItem.method   = method;
            encryptItem.str      = str;
            encryptItem.key      = key;
            encryptItem.result   = result;
            encryptItem.datetime = DateTime.Now.ToString();

            context.EncryptItems.Add(encryptItem);
            context.SaveChanges();
        }
Beispiel #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();
            }
        }
 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();
         }
     }
 }
Beispiel #6
0
 public void SaveCatagory(Catagory catagory)
 {
     using (var context = new CBContext()) {
         context.catagories.Add(catagory);
         context.SaveChanges();
     }
 }
 public void AddPurchaseOrder(PurchaseOrder product)
 {
     using (var context = new CBContext())
     {
         context.PurchaseOrders.Add(product);
         context.SaveChanges();
     }
 }
 public void UpdateReturnItem(OrderItem item)
 {
     using (var context = new CBContext())
     {
         context.Entry(item).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #9
0
 public void UpdateConfig(Config configuration)
 {
     using (var db = new CBContext())
     {
         db.Entry(configuration).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
 public void UpdateCategory(Category category)
 {
     using (CBContext context = new CBContext())
     {
         context.Entry(category).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void SaveProduct(Product product)
 {
     using (var context = new CBContext())
     {
         context.Products.Add(product);
         context.SaveChanges();
     }
 }
 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 SaveWishlist(WishList Wishlist)
 {
     using (var context = new CBContext())
     {
         context.wishlist.Add(Wishlist);
         context.SaveChanges();
     }
 }
Beispiel #14
0
 public int SaveOrder(Order order)
 {
     using (var context = new CBContext())
     {
         context.Orders.Add(order);
         return(context.SaveChanges());
     }
 }
Beispiel #15
0
 public void UpdateConfig(Config config)
 {
     using (var context = new CBContext())
     {
         context.Entry(config).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #16
0
 public void SaveConfig(Config config)
 {
     using (var context = new CBContext())
     {
         context.Configurations.Add(config);
         context.SaveChanges();
     }
 }
 public void SaveProduct(Product product)
 {
     using (var db = new CBContext())
     {
         db.Products.Add(product);
         db.SaveChanges();
     }
 }
 public void SaveOrders(Order order)
 {
     using (var context = new CBContext())
     {
         context.Order.Add(order);
         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();
     }
 }
 public void AddIntoMasterOrder(PurchaseOrderMaster ob)
 {
     using (var context = new CBContext())
     {
         context.OrderMaster.Add(ob);
         context.SaveChanges();
     }
 }
Beispiel #21
0
 public void SaveDonor(Donor donor)
 {
     using (var context = new CBContext())
     {
         context.Donors.Add(donor);
         context.SaveChanges();
     }
 }
 public void UpdateWishlist(WishList Wishlist)
 {
     using (var context = new CBContext())
     {
         context.Entry(Wishlist).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void DeleteProduct(int ID)
 {
     using (CBContext db = new CBContext()) {
         var product = db.Products.Find(ID);
         db.Products.Remove(product);
         db.SaveChanges();
     }
 }
Beispiel #24
0
 public void SaveService(AppointmentList dispensaryServices)
 {
     using (var context = new CBContext())
     {
         context.AppointmentList.Add(dispensaryServices);
         context.SaveChanges();
     }
 }
 public void UpdateProduct(Product product)
 {
     using (var context = new CBContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #26
0
 public void SaveProduit(Produit c)
 {
     using (var context = new CBContext())
     {
         context.Produits.Add(c);
         context.SaveChanges();
     }
 }
Beispiel #27
0
 public void UpdateCategory(Category category)
 {
     using (var context = new CBContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void AddTransaction(PurchaseProductsMaster ob)
 {
     using (var context = new CBContext())
     {
         context.PurchaseProductMaster.Add(ob);
         context.SaveChanges();
     }
 }
Beispiel #29
0
 public void Update(AppointmentList appointmentList)
 {
     using (var context = new CBContext())
     {
         context.Entry(appointmentList).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #30
0
 public void SaveConfig(Config configuration)
 {
     using (var db = new CBContext())
     {
         db.Configurations.Add(configuration);
         db.SaveChanges();
     }
 }