DRMFSS.BLL.Dispatch.Update C# (CSharp) Method

Update() public method

Updates the specified inserted.
public Update ( List inserted, List updated, List deleted ) : void
inserted List The inserted.
updated List The updated.
deleted List The deleted.
return void
        public void Update(List<BLL.DispatchDetail> inserted, List<BLL.DispatchDetail> updated, 
            List<BLL.DispatchDetail> deleted)
        {
            CTSContext db = new CTSContext();
            BLL.Dispatch orginal = db.Dispatches.Where(p => p.DispatchID == this.DispatchID).SingleOrDefault();
                    if (orginal != null)
                    {
                        orginal.BidNumber = this.BidNumber;
                        orginal.DispatchDate = this.DispatchDate;
                        orginal.DriverName = this.DriverName;
                        orginal.FDPID = this.FDPID;
                        orginal.GIN = this.GIN;
                        orginal.PeriodYear = this.PeriodYear;
                        orginal.PeriodMonth = this.PeriodMonth;
                        orginal.PlateNo_Prime = this.PlateNo_Prime;
                        orginal.PlateNo_Trailer = this.PlateNo_Trailer;
                        //orginal.ProgramID = this.ProgramID;
                        orginal.RequisitionNo = this.RequisitionNo;
                        orginal.Round = this.Round;
                        //orginal.StackNumber = this.StackNumber;
                        //orginal.StoreID = this.StoreID;
                        orginal.TransporterID = this.TransporterID;
                        orginal.UserProfileID = this.UserProfileID;
                        //orginal.WarehouseID = this.WarehouseID;
                        orginal.WeighBridgeTicketNumber = this.WeighBridgeTicketNumber;
                        orginal.Remark = this.Remark;
                        orginal.DispatchedByStoreMan = this.DispatchedByStoreMan;
                        //orginal.ProjectNumber = this.ProjectNumber;
                        //orginal.SINumber = this.SINumber;

                        foreach (BLL.DispatchDetail update in updated)
                        {
                            BLL.DispatchDetail updatedCommodity = db.DispatchDetails.Where(p => p.DispatchDetailID == update.DispatchDetailID).SingleOrDefault();
                            if (updatedCommodity != null)
                            {
                                updatedCommodity.CommodityID = update.CommodityID;
                                updatedCommodity.Description = update.Description;
                                //updatedCommodity.DispatchedQuantityInUnit = update.DispatchedQuantityInUnit;
                                //updatedCommodity.DispatchedQuantityInMT = update.DispatchedQuantityInMT;
                                updatedCommodity.RequestedQunatityInUnit = update.RequestedQunatityInUnit;
                                updatedCommodity.RequestedQuantityInMT = update.RequestedQuantityInMT;
                                updatedCommodity.UnitID = update.UnitID;
                            }
                        }
                        db.SaveChanges();
                    }
        }