public OrderDispatchedMaster add(OrderDispatchedMaster item) { logger.Info("start OrderDispatchedMaster: "); try { var identity = User.Identity as ClaimsIdentity; int compid = 0, userid = 0; foreach (Claim claim in identity.Claims) { if (claim.Type == "compid") { compid = int.Parse(claim.Value); } if (claim.Type == "userid") { userid = int.Parse(claim.Value); } } if (item == null) { throw new ArgumentNullException("item"); } logger.Info("User ID : {0} , Company Id : {1}", compid, userid); context.AddOrderDispatchedMaster(item); logger.Info("End UnitMaster: "); return(item); } catch (Exception ex) { logger.Error("Error in OrderDispatchedMaster " + ex.Message); logger.Info("End OrderDispatchedMaster: "); return(null); } }
public dynamic Bounce(OrderDispatchedMaster data) { var comp = db.OrderDispatchedMasters.Where(x => x.OrderId == data.OrderId).FirstOrDefault(); try { comp.Status = "Account settled"; //comp.UpdatedDate = indianTime; db.OrderDispatchedMasters.Attach(comp); db.Entry(comp).State = EntityState.Modified; db.SaveChanges(); if (data.OrderId != 0) { var obj = db.DbOrderMaster.Where(x => x.OrderId == data.OrderId).FirstOrDefault(); obj.Status = "Account settled"; obj.UpdatedDate = DateTime.Now; db.DbOrderMaster.Attach(obj); db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); } return(comp); } catch (Exception ex) { } return(null); }
public OrderDispatchedMaster Get(string id) { logger.Info("start PurchaseOrderMaster: "); OrderDispatchedMaster wh = new OrderDispatchedMaster(); if (id != null) { int Id = Convert.ToInt32(id); AuthContext db = new AuthContext(); wh = db.OrderDispatchedMasters.Where(x => x.OrderId == Id).SingleOrDefault(); return(wh); } return(null); }
public HttpResponseMessage post(OrderDispatchedMaster obj) //Order delivered or canceled { try { var DBoyorders = context.orderdeliveredreturn(obj); if (DBoyorders == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Not Delivered")); } return(Request.CreateResponse(HttpStatusCode.OK, DBoyorders)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public OrderDispatchedMaster put(int id, string DboyNo) { var db = new AuthContext(); logger.Info("start OrderDispatchedMaster: "); OrderDispatchedMaster obj = db.OrderDispatchedMasters.Where(x => x.OrderDispatchedMasterId == id).FirstOrDefault(); People DeliveryOBJ = db.Peoples.Where(x => x.Mobile == DboyNo).FirstOrDefault(); obj.DboyName = DeliveryOBJ.DisplayName; obj.DboyMobileNo = DeliveryOBJ.Mobile; try { var identity = User.Identity as ClaimsIdentity; int compid = 0, userid = 0; foreach (Claim claim in identity.Claims) { if (claim.Type == "compid") { compid = int.Parse(claim.Value); } if (claim.Type == "userid") { userid = int.Parse(claim.Value); } } // item.CompanyId = compid; if (obj == null) { throw new ArgumentNullException("item"); } logger.Info("User ID : {0} , Company Id : {1}", compid, userid); context.UpdateOrderDispatchedMaster(obj); logger.Info("End UnitMaster: "); return(obj); } catch (Exception ex) { logger.Error("Error in OrderDispatchedMaster " + ex.Message); logger.Info("End OrderDispatchedMaster: "); return(null); } }
public dynamic Bounce(OrderDispatchedMaster data) { var comp = db.OrderDispatchedMasters.Where(x => x.OrderId == data.OrderId).FirstOrDefault(); try { var stt = "Partial receiving -Bounce"; comp.cheq = true; comp.Status = stt; comp.UpdatedDate = DateTime.Now; comp.BounceCheqAmount = 200; db.OrderDispatchedMasters.Attach(comp); db.Entry(comp).State = EntityState.Modified; db.SaveChanges(); try { var obj = db.DbOrderMaster.Where(x => x.OrderId == data.OrderId).FirstOrDefault(); obj.Status = "Partial receiving -Bounce"; obj.UpdatedDate = DateTime.Now; db.DbOrderMaster.Attach(obj); db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); } catch { } return(comp); } catch (Exception ex) { } return(null); }
public List <OrderDispatchedDetails> add(List <OrderDispatchedDetails> po) { bool isDiscount = false; //bool isBaseWithoutChild = false; double finaltotal = 0; double finalTaxAmount = 0; double finalSGSTTaxAmount = 0; double finalCGSTTaxAmount = 0; double finalGrossAmount = 0; double finalTotalTaxAmount = 0; foreach (OrderDispatchedDetails pc in po) { ItemMaster items = db.itemMasters.Where(x => x.ItemId == pc.ItemId).Select(x => x).FirstOrDefault(); OrderMaster om = db.DbOrderMaster.Where(x => x.OrderId == pc.OrderId && x.Deleted == false).FirstOrDefault(); om.Status = "Ready to Dispatch"; db.DbOrderMaster.Attach(om); db.Entry(om).State = EntityState.Modified; db.SaveChanges(); if (pc != null && pc.isDeleted != true) { ItemMaster master = db.itemMasters.Where(c => c.ItemId == pc.ItemId).SingleOrDefault(); CurrentStock item = db.DbCurrentStock.Where(x => x.ItemNumber == master.Number && x.Warehouseid == pc.Warehouseid).SingleOrDefault(); if (item != null) { CurrentStockHistory Oss = new CurrentStockHistory(); if (item != null) { Oss.StockId = item.StockId; Oss.ItemNumber = item.ItemNumber; Oss.ItemName = item.ItemName; Oss.OdOrPoId = pc.OrderId; Oss.CurrentInventory = item.CurrentInventory; Oss.InventoryOut = Convert.ToInt32(pc.qty); Oss.TotalInventory = Convert.ToInt32(item.CurrentInventory - pc.qty); Oss.WarehouseName = item.WarehouseName; Oss.CreationDate = DateTime.Now; db.CurrentStockHistoryDb.Add(Oss); int id = db.SaveChanges(); } item.CurrentInventory = Convert.ToInt32(item.CurrentInventory - pc.qty); context.UpdateCurrentStock(item); } var ord = db.DbOrderDetails.Where(r => r.OrderDetailsId == pc.OrderDetailsId).SingleOrDefault(); ord.Status = "Ready to Dispatch"; ord.DiscountPercentage = pc.DiscountPercentage; db.DbOrderDetails.Attach(ord); db.Entry(ord).State = EntityState.Modified; db.SaveChanges(); // calculation var od = new OrderDispatchedDetails(); od.OrderDispatchedDetailsId = pc.OrderDispatchedDetailsId; if (pc.DiscountPercentage == 0) { isDiscount = false; } else { isDiscount = true; } od.DiscountPercentage = pc.DiscountPercentage; od.OrderDetailsId = pc.OrderDetailsId; od.OrderId = pc.OrderId; od.OrderDispatchedMasterId = pc.OrderDispatchedMasterId; od.CustomerId = pc.CustomerId; od.CustomerName = pc.CustomerName; od.City = pc.City; od.Mobile = pc.Mobile; od.OrderDate = pc.OrderDate; od.CompanyId = pc.CompanyId; od.CityId = pc.CityId; od.Warehouseid = pc.Warehouseid; od.WarehouseName = pc.WarehouseName; od.CategoryName = pc.CategoryName; od.ItemId = pc.ItemId; od.Itempic = pc.Itempic; od.itemname = pc.itemname; od.SubcategoryName = pc.SubcategoryName; od.SubsubcategoryName = pc.SubsubcategoryName; od.itemcode = pc.itemcode; od.Barcode = pc.Barcode; od.UnitPrice = pc.UnitPrice; od.Purchaseprice = pc.Purchaseprice; od.MinOrderQty = pc.MinOrderQty; od.MinOrderQtyPrice = pc.MinOrderQtyPrice; od.qty = pc.qty; od.price = pc.price; od.MinOrderQty = pc.MinOrderQty; int MOQ = items.MinOrderQty; od.MinOrderQtyPrice = MOQ * items.UnitPrice; od.price = items.price; od.MinOrderQty = items.MinOrderQty; od.MinOrderQtyPrice = MOQ * items.UnitPrice; od.qty = Convert.ToInt32(pc.qty); od.SizePerUnit = pc.SizePerUnit; int qty = 0; if (master != null) { qty = Convert.ToInt32(pc.qty); } else { qty = Convert.ToInt32(od.qty); } od.TaxPercentage = items.TotalTaxPercentage; if (od.TaxPercentage >= 0) { od.SGSTTaxPercentage = od.TaxPercentage / 2; od.CGSTTaxPercentage = od.TaxPercentage / 2; } od.HSNCode = items.HSNCode; //........CALCULATION FOR NEW SHOPKIRANA............................. od.Noqty = qty; // for total qty (no of items) // STEP 1 (UNIT PRICE * QTY) - SHOW PROPERTY od.TotalAmt = System.Math.Round(pc.UnitPrice * qty, 2); // STEP 2 (AMOUT WITHOU TEX AND WITHOUT DISCOUNT ) - SHOW PROPERTY od.AmtWithoutTaxDisc = ((100 * od.UnitPrice * qty) / (1 + od.TaxPercentage / 100)) / 100; // STEP 3 (AMOUNT WITHOUT TAX AFTER DISCOUNT) - UNSHOW PROPERTY od.AmtWithoutAfterTaxDisc = (100 * od.AmtWithoutTaxDisc) / (100 + od.DiscountPercentage); //STEP 4 (TAX AMOUNT) - UNSHOW PROPERTY od.TaxAmmount = (od.AmtWithoutAfterTaxDisc * od.TaxPercentage) / 100; if (od.TaxAmmount >= 0) { od.SGSTTaxAmmount = od.TaxAmmount / 2; od.CGSTTaxAmmount = od.TaxAmmount / 2; } //STEP 5(TOTAL TAX AMOUNT) - UNSHOW PROPERTY od.TotalAmountAfterTaxDisc = od.AmtWithoutAfterTaxDisc + od.TaxAmmount; //...............Calculate Discount............................. //od.DiscountPercentage = items.PramotionalDiscount; od.DiscountAmmount = 0; // double DiscountAmmount = od.DiscountAmmount; // double NetAmtAfterDis = (od.NetAmmount - DiscountAmmount); od.NetAmtAfterDis = 0; //double TaxAmmount = od.TaxAmmount; //................................................................... //od.UnitId = items.UnitId; //od.Unitname = items.UnitName; od.Purchaseprice = items.price; //od.VATTax = items.VATTax; od.CreatedDate = Convert.ToDateTime(pc.CreatedDate); od.UpdatedDate = Convert.ToDateTime(pc.CreatedDate); od.Deleted = false; od.Status = "Ready to Dispatch"; od.QtyChangeReason = pc.QtyChangeReason; od.itemNumber = pc.itemNumber; context.AddOrderDispatchedDetails(od); finaltotal = finaltotal + od.TotalAmt; finalTaxAmount = finalTaxAmount + od.TaxAmmount; finalSGSTTaxAmount = finalSGSTTaxAmount + od.SGSTTaxAmmount; finalCGSTTaxAmount = finalCGSTTaxAmount + od.CGSTTaxAmmount; finalGrossAmount = finalGrossAmount + od.TotalAmountAfterTaxDisc; finalTotalTaxAmount = finalTotalTaxAmount + od.TotalAmountAfterTaxDisc; } else { } } int masterid = Convert.ToInt32(po[0].OrderDispatchedMasterId); OrderDispatchedMaster ODM = db.OrderDispatchedMasters.Where(x => x.OrderDispatchedMasterId == masterid).FirstOrDefault(); finaltotal = finaltotal + ODM.deliveryCharge; finalGrossAmount = finalGrossAmount + ODM.deliveryCharge; if (ODM.WalletAmount > 0) { ODM.TotalAmount = System.Math.Round(finaltotal, 2) - ODM.WalletAmount.GetValueOrDefault(); ODM.TaxAmount = System.Math.Round(finalTaxAmount, 2); ODM.SGSTTaxAmmount = System.Math.Round(finalSGSTTaxAmount, 2); ODM.CGSTTaxAmmount = System.Math.Round(finalCGSTTaxAmount, 2); ODM.GrossAmount = System.Math.Round((Convert.ToInt32(finalGrossAmount) - ODM.WalletAmount.GetValueOrDefault()), 0); } else { ODM.TotalAmount = System.Math.Round(finaltotal, 2); ODM.TaxAmount = System.Math.Round(finalTaxAmount, 2); ODM.SGSTTaxAmmount = System.Math.Round(finalSGSTTaxAmount, 2); ODM.CGSTTaxAmmount = System.Math.Round(finalCGSTTaxAmount, 2); ODM.GrossAmount = System.Math.Round((finalGrossAmount), 0); } if (isDiscount == true) { ODM.DiscountAmount = finalTotalTaxAmount - finaltotal; } else { ODM.DiscountAmount = 0; } db.OrderDispatchedMasters.Attach(ODM); db.Entry(ODM).State = EntityState.Modified; db.SaveChanges(); try { var FreeItemList = db.SKFreeItemDb.Where(f => f.OrderId == po[0].OrderId).ToList(); foreach (var freeitem in FreeItemList) { CurrentStock itemms = db.DbCurrentStock.Where(x => x.ItemNumber == freeitem.itemNumber).SingleOrDefault(); if (itemms != null) { itemms.CurrentInventory = Convert.ToInt32(itemms.CurrentInventory + (freeitem.TotalQuantity)); context.UpdateCurrentStock(itemms); } } } catch (Exception ex) { } return(po); }
public dynamic cashstatus(OrderDispatchedMaster data) { var comp = db.OrderDispatchedMasters.Where(x => x.OrderId == data.OrderId).FirstOrDefault(); try { if (data.CheckAmount == 0 && data.ElectronicAmount == 0) { comp.cash = true; comp.Status = "Account settled"; comp.UpdatedDate = DateTime.Now; db.OrderDispatchedMasters.Attach(comp); db.Entry(comp).State = EntityState.Modified; db.SaveChanges(); try { var obj = db.DbOrderMaster.Where(x => x.OrderId == data.OrderId).FirstOrDefault(); obj.Status = "Account settled"; obj.UpdatedDate = DateTime.Now; db.DbOrderMaster.Attach(obj); db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); } catch { } } else if (data.CheckAmount == 0 && data.ElectronicAmount != 0 && data.electronic == true) { comp.cash = true; comp.Status = "Account settled"; comp.UpdatedDate = DateTime.Now; db.OrderDispatchedMasters.Attach(comp); db.Entry(comp).State = EntityState.Modified; db.SaveChanges(); try { var obj = db.DbOrderMaster.Where(x => x.OrderId == data.OrderId).FirstOrDefault(); obj.Status = "Account settled"; obj.UpdatedDate = DateTime.Now; db.DbOrderMaster.Attach(obj); db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); } catch { } } else if (data.CheckAmount != 0 && data.ElectronicAmount == 0 && data.cheq == true) { comp.cash = true; comp.Status = "Account settled"; comp.UpdatedDate = DateTime.Now; db.OrderDispatchedMasters.Attach(comp); db.Entry(comp).State = EntityState.Modified; db.SaveChanges(); try { var obj = db.DbOrderMaster.Where(x => x.OrderId == data.OrderId).FirstOrDefault(); obj.Status = "Account settled"; obj.UpdatedDate = DateTime.Now; db.DbOrderMaster.Attach(obj); db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); } catch { } } else if (data.CheckAmount != 0 && data.ElectronicAmount != 0 && data.cheq == true && data.electronic == true) { comp.cash = true; comp.Status = "Account settled"; comp.UpdatedDate = DateTime.Now; db.OrderDispatchedMasters.Attach(comp); db.Entry(comp).State = EntityState.Modified; db.SaveChanges(); try { var obj = db.DbOrderMaster.Where(x => x.OrderId == data.OrderId).FirstOrDefault(); obj.Status = "Account settled"; obj.UpdatedDate = DateTime.Now; db.DbOrderMaster.Attach(obj); db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); } catch { } } else { comp.cash = true; comp.Status = "Partial settled"; comp.UpdatedDate = DateTime.Now; db.OrderDispatchedMasters.Attach(comp); db.Entry(comp).State = EntityState.Modified; db.SaveChanges(); try { var obj = db.DbOrderMaster.Where(x => x.OrderId == data.OrderId).FirstOrDefault(); obj.Status = "Partial settled"; obj.UpdatedDate = DateTime.Now; db.DbOrderMaster.Attach(obj); db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); } catch { } } return(comp); } catch (Exception ex) { } return(null); }
public List <ReturnOrderDispatchedDetails> add(List <ReturnOrderDispatchedDetails> po) { int Oid = po[0].OrderId; List <OrderDispatchedDetails> dispatchedobj = new List <OrderDispatchedDetails>(); dispatchedobj = db.OrderDispatchedDetailss.Where(x => x.OrderId == Oid).ToList(); List <FinalOrderDispatchedDetails> Finalobj = new List <FinalOrderDispatchedDetails>(); try { for (var i = 0; i < dispatchedobj.Count; i++) { for (var k = 0; k < po.Count; k++) { if (po[k].isDeleted != true && dispatchedobj[i].ItemId == po[k].ItemId) { dispatchedobj[i].qty = dispatchedobj[i].qty - po[k].qty; var itemIDmaster = dispatchedobj[i].ItemId; ItemMaster items = db.itemMasters.Where(x => x.ItemId == itemIDmaster).Select(x => x).FirstOrDefault(); FinalOrderDispatchedDetails newfinal = new FinalOrderDispatchedDetails(); newfinal.OrderDispatchedDetailsId = dispatchedobj[i].OrderDispatchedDetailsId; newfinal.OrderDetailsId = dispatchedobj[i].OrderDetailsId; newfinal.OrderId = dispatchedobj[i].OrderId; newfinal.OrderDispatchedMasterId = dispatchedobj[i].OrderDispatchedMasterId; newfinal.CustomerId = dispatchedobj[i].CustomerId; newfinal.CustomerName = dispatchedobj[i].CustomerName; newfinal.City = dispatchedobj[i].City; newfinal.Mobile = dispatchedobj[i].Mobile; newfinal.OrderDate = dispatchedobj[i].OrderDate; newfinal.CompanyId = dispatchedobj[i].CompanyId; newfinal.CityId = dispatchedobj[i].CityId; newfinal.Warehouseid = dispatchedobj[i].Warehouseid; newfinal.WarehouseName = dispatchedobj[i].WarehouseName; newfinal.CategoryName = dispatchedobj[i].CategoryName; newfinal.ItemId = dispatchedobj[i].ItemId; newfinal.Itempic = dispatchedobj[i].Itempic; newfinal.itemname = dispatchedobj[i].itemname; newfinal.itemcode = dispatchedobj[i].itemcode; newfinal.Barcode = dispatchedobj[i].Barcode; newfinal.UnitPrice = dispatchedobj[i].UnitPrice; newfinal.Purchaseprice = dispatchedobj[i].Purchaseprice; newfinal.MinOrderQty = dispatchedobj[i].MinOrderQty; newfinal.MinOrderQtyPrice = dispatchedobj[i].MinOrderQtyPrice; newfinal.qty = dispatchedobj[i].qty; newfinal.price = dispatchedobj[i].price; newfinal.MinOrderQty = dispatchedobj[i].MinOrderQty; int MOQ = dispatchedobj[i].MinOrderQty; newfinal.MinOrderQtyPrice = MOQ * dispatchedobj[i].UnitPrice; newfinal.qty = Convert.ToInt32(dispatchedobj[i].qty); int qty = 0; qty = Convert.ToInt32(newfinal.qty); newfinal.TaxPercentage = items.TotalTaxPercentage; //........CALCULATION FOR NEW SHOPKIRANA............................. newfinal.Noqty = qty; // for total qty (no of items) // STEP 1 (UNIT PRICE * QTY) - SHOW PROPERTY newfinal.TotalAmt = System.Math.Round(newfinal.UnitPrice * qty, 2); // STEP 2 (AMOUT WITHOU TEX AND WITHOUT DISCOUNT ) - SHOW PROPERTY newfinal.AmtWithoutTaxDisc = ((100 * newfinal.UnitPrice * qty) / (1 + newfinal.TaxPercentage / 100)) / 100; // STEP 3 (AMOUNT WITHOUT TAX AFTER DISCOUNT) - UNSHOW PROPERTY newfinal.AmtWithoutAfterTaxDisc = (100 * newfinal.AmtWithoutTaxDisc) / (100 + items.PramotionalDiscount); //STEP 4 (TAX AMOUNT) - UNSHOW PROPERTY newfinal.TaxAmmount = (newfinal.AmtWithoutAfterTaxDisc * newfinal.TaxPercentage) / 100; //STEP 5(TOTAL TAX AMOUNT) - UNSHOW PROPERTY newfinal.TotalAmountAfterTaxDisc = newfinal.AmtWithoutAfterTaxDisc + newfinal.TaxAmmount; //...............Calculate Discount............................. newfinal.DiscountPercentage = items.PramotionalDiscount; newfinal.DiscountAmmount = 0; newfinal.NetAmtAfterDis = 0; //................................................................... newfinal.Purchaseprice = items.price; //newfinal.VATTax = items.VATTax; newfinal.CreatedDate = Convert.ToDateTime(dispatchedobj[i].CreatedDate); newfinal.UpdatedDate = Convert.ToDateTime(dispatchedobj[i].CreatedDate); newfinal.Deleted = false; Finalobj.Add(newfinal); } } } foreach (FinalOrderDispatchedDetails x1 in Finalobj) { db = new AuthContext(); db.FinalOrderDispatchedDetailsDb.Add(x1); int id = db.SaveChanges(); } List <int> ItemIds = new List <int>(); foreach (ReturnOrderDispatchedDetails pc in po) { db = new AuthContext(); OrderMaster om = db.DbOrderMaster.Where(x => x.OrderId == pc.OrderId && x.Deleted == false).FirstOrDefault(); om.Status = "Order Canceled"; db.DbOrderMaster.Attach(om); db.Entry(om).State = EntityState.Modified; db.SaveChanges(); OrderDispatchedMaster odm = db.OrderDispatchedMasters.Where(x => x.OrderId == pc.OrderId && x.Deleted == false).FirstOrDefault(); odm.Status = "Order Canceled"; db.OrderDispatchedMasters.Attach(odm); db.Entry(odm).State = EntityState.Modified; db.SaveChanges(); //update stock ItemMaster master = db.itemMasters.Where(c => c.ItemId == pc.ItemId).SingleOrDefault(); CurrentStock itemm = db.DbCurrentStock.Where(x => x.ItemNumber == master.Number && x.Warehouseid == pc.Warehouseid).SingleOrDefault(); if (itemm != null && !ItemIds.Any(x => x == master.ItemId)) { CurrentStockHistory Oss = new CurrentStockHistory(); if (itemm != null) { Oss.StockId = itemm.StockId; Oss.ItemNumber = itemm.ItemNumber; Oss.ItemName = itemm.ItemName; Oss.CurrentInventory = itemm.CurrentInventory; Oss.OdOrPoId = pc.OrderId; Oss.OrderCancelInventoryIn = Convert.ToInt32(pc.qty); Oss.TotalInventory = Convert.ToInt32(itemm.CurrentInventory + pc.qty); Oss.WarehouseName = itemm.WarehouseName; Oss.CreationDate = DateTime.Now; db.CurrentStockHistoryDb.Add(Oss); int id = db.SaveChanges(); } itemm.CurrentInventory = Convert.ToInt32(itemm.CurrentInventory + (pc.qty)); context.UpdateCurrentStock(itemm); ItemIds.Add(master.ItemId); } var ord = db.DbOrderDetails.Where(r => r.OrderDetailsId == pc.OrderDetailsId).SingleOrDefault(); ord.Status = "Order Canceled"; db.DbOrderDetails.Attach(ord); db.Entry(ord).State = EntityState.Modified; db.SaveChanges(); db.AddReturnOrderDispatchedDetails(pc); } try { OrderMaster om = db.DbOrderMaster.Where(x => x.OrderId == Oid && x.Deleted == false).FirstOrDefault(); var rpoint = db.RewardPointDb.Where(c => c.CustomerId == om.CustomerId).FirstOrDefault(); if (rpoint != null) { if (om.RewardPoint > 0) { rpoint.EarningPoint -= om.RewardPoint; if (rpoint.EarningPoint < 0) { rpoint.EarningPoint = 0; } rpoint.UpdatedDate = indianTime; rpoint.TransactionDate = indianTime; db.RewardPointDb.Attach(rpoint); db.Entry(rpoint).State = EntityState.Modified; db.SaveChanges(); } } } catch (Exception ex) { } try { var FreeItemList = db.SKFreeItemDb.Where(f => f.OrderId == Oid).ToList(); foreach (var freeitem in FreeItemList) { CurrentStock itemms = db.DbCurrentStock.Where(x => x.ItemNumber == freeitem.itemNumber).SingleOrDefault(); if (itemms != null) { itemms.CurrentInventory = Convert.ToInt32(itemms.CurrentInventory + (freeitem.TotalQuantity)); context.UpdateCurrentStock(itemms); } } } catch (Exception ex) { } return(po); } catch (Exception exe) { return(null); } }