public List <BundleViewModel> Match(List <Bundle> bundle) { PackageNumberBL _packageNumberService = new PackageNumberBL(); List <BundleViewModel> _results = new List <BundleViewModel>(); ShipmentBL shipment = new ShipmentBL(); //UserBL _userService = new UserBL(); UserStore _userService = new UserStore(); foreach (Bundle _bundle in bundle) { BundleViewModel model = new BundleViewModel(); string _airwaybill = ""; try { _airwaybill = _packageNumberService.FilterActive().Find(x => x.PackageNo == _bundle.Cargo).Shipment.AirwayBillNo; }catch (Exception) { continue; } BundleViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill); if (isExist != null) { isExist.Qty++; //_results.Add(isExist); } else { model.AirwayBillNo = _airwaybill; List <Shipment> list = shipment.FilterActive().Where(x => x.AirwayBillNo == _airwaybill).ToList(); foreach (Shipment ship in list) { model.Shipper = ship.Shipper.FullName; model.Consignee = ship.Consignee.FullName; model.Address = ship.Consignee.Address1; model.CommodityType = ship.Commodity.CommodityType.CommodityTypeName; model.Commodity = ship.Commodity.CommodityName; model.Qty++; model.AGW += ship.Weight; model.ServiceMode = ship.ServiceMode.ServiceModeName; model.PaymendMode = ship.PaymentMode.PaymentModeName; model.Area = ship.OriginCity.CityName; model.CreatedDate = ship.CreatedDate; model.Destination = ship.DestinationCity.CityName; model.BSO = ship.OriginCity.CityName; } model.SackNo = _bundle.SackNo; model.BCO = _bundle.BranchCorpOffice.BranchCorpOfficeName; //model.Scannedby = AppUser.User.Employee.FullName; model.Scannedby = "N/A"; //string employee = _userService.FilterActive().Find(x => x.UserId == _bundle.CreatedBy).Employee.FullName; string employee = _userService.FindById(_bundle.CreatedBy).Employee.FullName; if (employee != "") { model.Scannedby = employee; } _results.Add(model); } } return(_results); }
//Filter By BCOID and Driver and ALl batch public DataTable getBranchAcceptanceData1(DateTime date, Guid revenueUnitId, string driver) { BranchAcceptanceBL branchAcceptanceBl = new BranchAcceptanceBL(); ShipmentBL shipmentService = new ShipmentBL(); //List<Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList(); //List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.BatchID == batchId).ToList(); List <Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.Booking.BookingStatus.BookingStatusName == "Picked-up").ToList(); //List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.RecordStatus == 1 && x.Users.Employee.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.Driver == driver && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).Distinct().ToList(); List <BranchAcceptance> branchAcceptance = branchAcceptanceBl.FilterActive().Where(x => x.RecordStatus == 1 && x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.Driver == driver && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).Distinct().ToList(); List <BranchAcceptanceViewModel> list = Match(branchAcceptance, shipments).FindAll(x => x.Area != "N/A" && !x.Area.Contains("Walk-in")); DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("No", typeof(string))); dt.Columns.Add(new DataColumn("Area/Branch", typeof(string))); dt.Columns.Add(new DataColumn("Driver", typeof(string))); dt.Columns.Add(new DataColumn("Checker", typeof(string))); dt.Columns.Add(new DataColumn("Plate #", typeof(string))); dt.Columns.Add(new DataColumn("Batch", typeof(string))); dt.Columns.Add(new DataColumn("AWB", typeof(string))); dt.Columns.Add(new DataColumn("Recieved(Qty)", typeof(string))); dt.Columns.Add(new DataColumn("Discrepancy(Qty)", typeof(string))); dt.Columns.Add(new DataColumn("Total Qty", typeof(string))); dt.Columns.Add(new DataColumn("BCO", typeof(string))); dt.Columns.Add(new DataColumn("BSO", typeof(string))); dt.Columns.Add(new DataColumn("ScannedBy", typeof(string))); dt.Columns.Add(new DataColumn("Remarks", typeof(string))); dt.Columns.Add(new DataColumn("Notes", typeof(string))); dt.BeginLoadData(); int ctr = 1; foreach (BranchAcceptanceViewModel item in list.Distinct()) { DataRow row = dt.NewRow(); row[0] = ctr++.ToString(); row[1] = item.Area.ToString(); row[2] = item.Driver.ToString(); row[3] = item.Checker.ToString(); row[4] = item.PlateNo.ToString(); row[5] = item.Batch.ToString(); row[6] = item.AirwayBillNo.ToString(); row[7] = item.TotalRecieved.ToString(); row[8] = item.TotalDiscrepency.ToString(); row[9] = item.Total.ToString(); row[10] = item.BCO; row[11] = item.BSO; row[12] = item.ScannedBy; row[13] = item.Remarks; row[14] = item.Notes; dt.Rows.Add(row); } dt.EndLoadData(); return(dt); }
public StatementOfAccountBL() { _unitOfWork = GetUnitOfWork(); companyService = new CompanyBL(_unitOfWork); shipmentService = new ShipmentBL(_unitOfWork); paymentTypeService = new PaymentTypeBL(_unitOfWork); shipmentAdjustmentService = new ShipmentAdjustmentBL(_unitOfWork); soaPaymentService = new StatementOfAccountPaymentBL(_unitOfWork); paymentService = new PaymentBL(_unitOfWork); }
public DataTable getPickUpCargoData(DateTime date) { //GET LIST ShipmentBL _shipmentService = new ShipmentBL(); List <Shipment> _shipments = _shipmentService.FilterActive().Where(x => x.Booking.BookingStatus.BookingStatusName == "Picked-up" && x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && (x.CreatedDate).ToShortDateString() == date.ToShortDateString()).ToList(); List <PickupCargoManifestViewModel> modelList = Match(_shipments).OrderByDescending(x => x.AirwayBillNo).Distinct().ToList(); DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("No", typeof(string))); dt.Columns.Add(new DataColumn("AWB", typeof(string))); dt.Columns.Add(new DataColumn("Shipper", typeof(string))); dt.Columns.Add(new DataColumn("Shipper Address", typeof(string))); dt.Columns.Add(new DataColumn("Consignee", typeof(string))); dt.Columns.Add(new DataColumn("Consignee Address", typeof(string))); dt.Columns.Add(new DataColumn("Commodity", typeof(string))); dt.Columns.Add(new DataColumn("QTY", typeof(string))); dt.Columns.Add(new DataColumn("AGW", typeof(string))); dt.Columns.Add(new DataColumn("Service Mode", typeof(string))); dt.Columns.Add(new DataColumn("Payment Mode", typeof(string))); dt.Columns.Add(new DataColumn("Amount", typeof(string))); dt.Columns.Add(new DataColumn("Area", typeof(string))); dt.Columns.Add(new DataColumn("Driver", typeof(string))); dt.Columns.Add(new DataColumn("Checker", typeof(string))); dt.Columns.Add(new DataColumn("ScannedBy", typeof(string))); dt.BeginLoadData(); int ctr = 1; foreach (PickupCargoManifestViewModel item in modelList) { DataRow row = dt.NewRow(); row[0] = (ctr++).ToString(); row[1] = item.AirwayBillNo; row[2] = item.Shipper; row[3] = item.ShipperAddress; row[4] = item.Consignee; row[5] = item.ConsigneeAddress; row[6] = item.Commodity; row[7] = item.QTY.ToString(); row[8] = item.AGW.ToString(); row[9] = item.ServiceMode; row[10] = item.PaymentMode; row[11] = item.Amount; row[12] = item.Area; row[13] = item.Driver; row[14] = item.Checker; row[15] = item.ScannedBy; dt.Rows.Add(row); } dt.EndLoadData(); return(dt); }
public List <HoldCargoViewModel> Match(List <HoldCargo> _holdcargo) { List <HoldCargoViewModel> _results = new List <HoldCargoViewModel>(); PackageNumberBL _packageNumberService = new PackageNumberBL(); StatusBL status = new StatusBL(); ReasonBL reason = new ReasonBL(); UserRoleBL user = new UserRoleBL(); ShipmentBL shipmentService = new ShipmentBL(); List <Shipment> shipList = shipmentService.GetAll(); UserStore _userService = new UserStore(); foreach (HoldCargo holdCargo in _holdcargo) { HoldCargoViewModel model = new HoldCargoViewModel(); //string _airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == holdCargo.Cargo).Shipment.AirwayBillNo; HoldCargoViewModel isExist = _results.Find(x => x.AirwayBillNo == holdCargo.AirwayBillNo); if (isExist != null) { } else { model.Date = holdCargo.HoldCargoDate; model.AirwayBillNo = holdCargo.AirwayBillNo; Shipment ship = shipList.Find(x => x.AirwayBillNo == holdCargo.AirwayBillNo); if (ship != null) { model.Shipper = ship.Shipper.FullName; model.Consignee = ship.Consignee.FullName; model.Address = ship.Consignee.Address1; model.PaymentMode = ship.PaymentMode.PaymentModeName; model.ServiceMode = ship.ServiceMode.ServiceModeName; model.Status = status.GetById(holdCargo.StatusID).StatusName; // status.GetAll().Find(x => x.StatusID == holdCargo.StatusID).StatusName; model.Reason = reason.GetById(holdCargo.ReasonID).ReasonName; // .Find(x => x.ReasonID == holdCargo.ReasonID).ReasonName; model.EndorseBy = holdCargo.Endorsedby; //model.ScannedBy = user.GetActiveRoles().Find(x => x.RoleId == AppUser.User.UserId).RoleName; //model.ScannedBy = holdCargo.User.Employee.FullName; model.ScannedBy = "N/A"; string employee = _userService.FindById(holdCargo.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } //model.PreparedBy = user.GetAllUsers().Find(x => x.UserId == shi) model.Aging = Math.Round((DateTime.Now - holdCargo.HoldCargoDate).TotalDays, 2); model.Branch = holdCargo.User.Employee.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeName; _results.Add(model); } } } return(_results); }
public List <SegregationViewModel> Macth(List <Segregation> _segregation) { List <SegregationViewModel> _results = new List <SegregationViewModel>(); PackageNumberBL _packageNumberService = new PackageNumberBL(); ShipmentBL shipmentService = new ShipmentBL(); UserStore _userService = new UserStore(); foreach (Segregation segregation in _segregation) { SegregationViewModel model = new SegregationViewModel(); string _airwaybill = ""; try { _airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == segregation.Cargo).Shipment.AirwayBillNo; } catch (Exception) { continue; } SegregationViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill); if (isExist != null) { isExist.Qty++; } else { model.BranchCorpOffice = segregation.BranchCorpOffice.BranchCorpOfficeName; model.Driver = segregation.Driver; model.Checker = segregation.Checker; model.PlateNo = segregation.PlateNo; model.Batch = segregation.Batch.BatchName; model.AirwayBillNo = _airwaybill; model.Qty++; model.Area = shipmentService.GetAll().Find(x => x.AirwayBillNo == _airwaybill).DestinationCity.CityName; model.CreatedDate = segregation.CreatedDate; //model.ScannedBy = AppUser.User.Employee.FullName; model.ScannedBy = "N/A"; string employee = _userService.FindById(segregation.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } _results.Add(model); } } return(_results); }
//Complete Filter public DataTable getBranchAcceptanceDataByFilter(DateTime date, Guid?revenueUnitId, string driver, Guid?batchId) { RevenueUnitBL revenueunitservice = new RevenueUnitBL(); BatchBL batchservice = new BatchBL(); BranchAcceptanceBL branchAcceptanceBl = new BranchAcceptanceBL(); ShipmentBL shipmentService = new ShipmentBL(); BranchCorpOfficeBL bcoService = new BranchCorpOfficeBL(); //List<Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList(); List <Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.Booking.BookingStatus.BookingStatusName == "Picked-up" && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList(); // List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.BatchID == batchId && x.Driver == driver).ToList(); //List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.Users.Employee.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.RecordStatus == 1 && x.BatchID == batchId && x.Driver == driver && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList(); List <BranchAcceptanceViewModel> list = new List <BranchAcceptanceViewModel>(); List <BranchAcceptance> branchAcceptance = branchAcceptanceBl.FilterActive(). Where( x => x.RecordStatus == 1 //&& ((x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.Users.Employee.AssignedToArea.RevenueUnitId != Guid.Empty) || (x.Users.Employee.AssignedToArea.RevenueUnitId == x.Users.Employee.AssignedToArea.RevenueUnitId && revenueUnitId == Guid.Empty)) && ((x.BatchID == batchId && x.BatchID != Guid.Empty) || (x.BatchID == x.BatchID && batchId == Guid.Empty)) && ((x.Driver == driver && x.Driver != "All") || (x.Driver == x.Driver && driver == "All")) && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList(); string revenueunitname = ""; string batchname = ""; string bcoName = ""; if (batchId != Guid.Empty) { batchname = batchservice.FilterActive().Find(x => x.BatchID == batchId).BatchName; } else { batchname = "All"; } if (revenueUnitId != Guid.Empty) { revenueunitname = revenueunitservice.FilterActive().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName; } else { revenueunitname = "All"; } bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName; list = Match(branchAcceptance, shipments). FindAll (x => ((x.Area == revenueunitname && x.Area != "N/A") || (x.Area == x.Area && revenueunitname == "All")) && ((x.Driver == driver && x.Driver != "N/A") || (x.Driver == x.Driver && driver == "All")) && ((x.Batch == batchname && x.Batch != "N/A") || (x.Batch == x.Batch && batchname == "All")) && ((x.BCO == bcoName && x.BCO != "N/A") || (x.BCO == x.BCO && bcoName == "")) && !x.Area.Contains("Walk-in")); //if (revenueUnitId != Guid.Empty && batchId !=Guid.Empty) //{ // batchname = batchservice.GetAll().Find(x => x.BatchID == batchId).BatchName; // revenueunitname = revenueunitservice.GetAll().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName; // list = Match(branchAcceptance, shipments).FindAll(x => x.Area == revenueunitname && x.Batch == batchname); //} //else if (revenueUnitId == Guid.Empty && batchId != Guid.Empty) //{ // batchname = batchservice.GetAll().Find(x => x.BatchID == batchId).BatchName; // list = Match(branchAcceptance, shipments).FindAll(x => x.Batch == batchname && x.Area != "N/A"); //} //else if (revenueUnitId != Guid.Empty && batchId == Guid.Empty) //{ // revenueunitname = revenueunitservice.GetAll().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName; // list = Match(branchAcceptance, shipments).FindAll(x => x.Area == revenueunitname); //} //else //{ // bcoName = bcoService.GetAll().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName; // list = Match(branchAcceptance, shipments).FindAll(x => x.BCO == bcoName && x.Area != "N/A"); // //list = Match(branchAcceptance, shipments); //} DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("No", typeof(string))); dt.Columns.Add(new DataColumn("Area/Branch", typeof(string))); dt.Columns.Add(new DataColumn("Driver", typeof(string))); dt.Columns.Add(new DataColumn("Checker", typeof(string))); dt.Columns.Add(new DataColumn("Plate #", typeof(string))); dt.Columns.Add(new DataColumn("Batch", typeof(string))); dt.Columns.Add(new DataColumn("AWB", typeof(string))); dt.Columns.Add(new DataColumn("Recieved(Qty)", typeof(string))); dt.Columns.Add(new DataColumn("Discrepancy(Qty)", typeof(string))); dt.Columns.Add(new DataColumn("Total Qty", typeof(string))); dt.Columns.Add(new DataColumn("BCO", typeof(string))); dt.Columns.Add(new DataColumn("BSO", typeof(string))); dt.Columns.Add(new DataColumn("ScannedBy", typeof(string))); dt.Columns.Add(new DataColumn("Remarks", typeof(string))); dt.Columns.Add(new DataColumn("Notes", typeof(string))); dt.BeginLoadData(); int ctr = 1; foreach (BranchAcceptanceViewModel item in list) { DataRow row = dt.NewRow(); row[0] = ctr++.ToString(); row[1] = item.Area.ToString(); row[2] = item.Driver.ToString(); row[3] = item.Checker.ToString(); row[4] = item.PlateNo.ToString(); row[5] = item.Batch.ToString(); row[6] = item.AirwayBillNo.ToString(); row[7] = item.TotalRecieved.ToString(); row[8] = item.TotalDiscrepency.ToString(); row[9] = item.Total.ToString(); row[10] = item.BCO; row[11] = item.BSO; row[12] = item.ScannedBy; row[13] = item.Remarks; row[14] = item.Notes; dt.Rows.Add(row); } dt.EndLoadData(); return(dt); }
public List <DeliveryStatusViewModel> Match(List <Delivery> _deliveries) { BranchCorpOfficeBL bcoService = new BranchCorpOfficeBL(); DeliveryStatusBL status = new DeliveryStatusBL(); DeliveryRemarkBL remark = new DeliveryRemarkBL(); DistributionBL distributionService = new DistributionBL(); DeliveryReceiptBL deliveryReceiptService = new DeliveryReceiptBL(); ShipmentBL shipmentService = new ShipmentBL(); PackageNumberBL _packageNumberService = new PackageNumberBL(); List <DeliveryStatusViewModel> _results = new List <DeliveryStatusViewModel>(); List <Distribution> distributions = distributionService.GetAll().ToList(); List <DeliveryReceipt> deliveryReceipt = deliveryReceiptService.GetAll().ToList(); UserStore _userService = new UserStore(); foreach (Delivery delivery in _deliveries) { DeliveryStatusViewModel model = new DeliveryStatusViewModel(); DeliveryStatusViewModel isExist = _results.Find(x => x.AirwayBillNo == delivery.Shipment.AirwayBillNo); if (isExist != null) { isExist.QTY++; } else { model.AirwayBillNo = delivery.Shipment.AirwayBillNo; model.QTY = _packageNumberService.FilterActiveBy(x => x.Shipment.AirwayBillNo == delivery.Shipment.AirwayBillNo).Count; model.Status = delivery.DeliveryStatus.DeliveryStatusName; model.Remarks = "NA"; model.DeliveredBy = delivery.DeliveredBy.FullName; if (delivery.DeliveryRemarkId != null) { model.Remarks = delivery.DeliveryRemark.DeliveryRemarkName; } Distribution dis = distributions.Find(x => x.ShipmentId == delivery.ShipmentId); DeliveryReceipt dReceipt = deliveryReceipt.Find(x => x.DeliveryId == delivery.DeliveryId); //List<Distribution> list = distributions.Where( x => x.ShipmentId == delivery.ShipmentId).Distinct().ToList(); //foreach(Distribution dis in list) //{ // //model.Area = dis.Area.RevenueUnitName; // model.Driver = dis.Driver; // model.Checker = dis.Checker; // model.Batch = dis.Batch.BatchName; // model.PlateNo = dis.PlateNo; // model.BCO = dis.Area.City.BranchCorpOffice.BranchCorpOfficeName; //} model.Area = dis.Area.RevenueUnitName; model.Driver = dis.Driver; model.Checker = dis.Checker; model.Batch = dis.Batch.BatchName; model.PlateNo = dis.PlateNo; model.BCO = dis.Area.City.BranchCorpOffice.BranchCorpOfficeName; //model.ScannedBy = AppUser.User.Employee.FullName; model.ScannedBy = "N/A"; string employee = _userService.FindById(dis.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } model.ReceivedBy = "NA"; if (dReceipt != null) { model.ReceivedBy = dReceipt.ReceivedBy; } _results.Add(model); } } //List<BranchCorpOffice> _bco= bcoService.GetAll().Where(x => x.RecordStatus == 1 && x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).ToList(); //string bcoName = bcoService.GetAll().Where(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).Select(x => x.BranchCorpOfficeName).ToString(); //string bcoName = _bco.Select(x => x.BranchCorpOfficeName).ToString(); string bcoName = bcoService.GetAll().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName; List <DeliveryStatusViewModel> _resultsFilter = _results.FindAll(x => x.BCO == bcoName); //List<DeliveryStatusViewModel> resultList = modelList.FindAll(x => x.Area == revenueUnitName); //return _results; return(_resultsFilter); }
public ActionResult BookingDetailsTab(Booking booking, string submit) { ViewBag.PortList = DataContext.GetCountryPorts(); ViewBag.shipmentlist = DataContext.ShipmentTerm(); ViewBag.equipmentlist = DataContext.EquipmentType(); //ViewBag.PaymentList = DataContext.GetPaymentTerm(); if (submit == "Save") { if (ModelState.IsValid) { ErrorLog errorLog = DataContext.SaveBooking(booking); if (!errorLog.IsError) { booking.BookingID = errorLog.ErrorMessage; TempData["Message"] = "Booking Request successfully created Booking ID " + booking.BookingID; } else { TempData["Message"] = errorLog.ErrorMessage; } } ModelState.Clear(); return(RedirectToAction("BookingDetails", "BookingDetails", new { BookingID = booking.BookingID })); } if (submit == "Update") { if (ModelState.IsValid) { ErrorLog errorLog = DataContext.UpdateBooking(booking); if (!errorLog.IsError) { TempData["message"] = "Booking Request successfully updated"; } else { TempData["message"] = errorLog.ErrorMessage; } } else { TempData["Message"] = "Please check your fields, some of the fields are not in correct format"; } return(RedirectToAction("BookingDetails", "BookingDetails", new { BookingID = booking.BookingID })); } if (submit == "Create Shipment") { ShipmentBL shipmentnew = new ShipmentBL(); if (ModelState.IsValid) { shipmentnew.ShipmentDetailsModel.ShipmentTerm = booking.ShipmentTerm; shipmentnew.BLDetailsModel.LoadPort = booking.LoadPort; shipmentnew.BLDetailsModel.DischPort = booking.DischargePort; shipmentnew.BLDetailsModel.PlaceofReceipt = booking.PlaceOfReceipt; shipmentnew.BLDetailsModel.PlaceofDelivery = booking.PlaceOfDelivery; shipmentnew.BLDetailsModel.CargoDescription = booking.CargoType; shipmentnew.ShipmentDetailsModel.UniversalSerialNr = booking.UniversalSerialNr; TempData["shipmentobj"] = shipmentnew; ModelState.Clear(); return(RedirectToAction("ShipmentDetails", "ShipmentDetails")); } else { TempData["Message"] = "Please check the fields, some of the fields are not in correct format"; ModelState.Clear(); return(View()); } } else { return(View()); } }
public List <GatewayTransmitalViewModel> Match(List <GatewayTransmittal> _transmital) { List <GatewayTransmitalViewModel> _results = new List <GatewayTransmitalViewModel>(); CommodityBL commodityService = new CommodityBL(); GatewayTransmittalBL transmitalService = new GatewayTransmittalBL(); ShipmentBL shipmentService = new ShipmentBL(); PackageNumberBL _packageNumberService = new PackageNumberBL(); BundleBL bundleService = new BundleBL(); UserStore _userService = new UserStore(); foreach (GatewayTransmittal transmital in _transmital) { GatewayTransmitalViewModel model = new GatewayTransmitalViewModel(); Shipment _shipment = new Shipment(); string _airwaybill = ""; //List<string> listCargo = new List<string>(); //List<string> listAirwayBill = new List<string>(); List <Tuple <string, decimal> > listofSack = new List <Tuple <string, decimal> >(); int numberOfCargo = 0; decimal WeightOfCargo = 0; decimal totalWeightOfCargo = 0; _shipment = shipmentService.FilterActive().Where(x => x.AirwayBillNo == transmital.AirwayBillNo).FirstOrDefault(); // _shipment = shipmentService.FilterActive().Where(x => x.AirwayBillNo == transmital.AirwayBillNo && x.Booking.BookedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId).FirstOrDefault(); if (_shipment == null) { listofSack = bundleService.FilterActive().Where(x => x.SackNo == transmital.AirwayBillNo).Select(x => new Tuple <string, decimal>(x.Cargo, x.Weight)).ToList(); if (listofSack != null) { for (int i = 0; i < listofSack.Count; i++) { WeightOfCargo = listofSack[i].Item2; totalWeightOfCargo += WeightOfCargo; numberOfCargo++; } GatewayTransmitalViewModel model1 = new GatewayTransmitalViewModel(); GatewayTransmitalViewModel isExistSackNo = _results.Find(x => x.AirwayBillNo == transmital.AirwayBillNo); if (isExistSackNo != null) { isExistSackNo.QTY++; isExistSackNo.AGW += Convert.ToDecimal(totalWeightOfCargo); } else { model1.AirwayBillNo = transmital.AirwayBillNo; model1.Shipper = "N/A"; model1.Consignee = "N/A"; model1.Address = "N/A"; model1.CommodityType = transmital.CommodityType.CommodityTypeName; model1.Commodity = "N/A"; model1.QTY = listofSack.Count; model1.AGW = Convert.ToDecimal(totalWeightOfCargo); model1.ServiceMode = "N/A"; model1.PaymentMode = "N/A"; model1.Gateway = transmital.Gateway; model1.Destination = transmital.BranchCorpOffice.BranchCorpOfficeName; model1.Batch = transmital.Batch.BatchName; model1.CreatedDate = transmital.CreatedDate; model1.PlateNo = transmital.PlateNo; model1.MAWB = transmital.MasterAirwayBillNo; //model1.ScannedBy = AppUser.User.Employee.FullName; model1.ScannedBy = "N/A"; //string employee = _userService.FilterActive().Find(x => x.UserId == _bundle.CreatedBy).Employee.FullName; string employee = _userService.FindById(transmital.CreatedBy).Employee.FullName; if (employee != "") { model1.ScannedBy = employee; } _results.Add(model1); } } } else { _airwaybill = _shipment.AirwayBillNo; GatewayTransmitalViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill); if (isExist != null) { isExist.QTY++; isExist.AGW += Convert.ToDecimal(shipmentService.FilterActive().Find(x => x.AirwayBillNo == transmital.AirwayBillNo).Weight); } else { model.AirwayBillNo = transmital.AirwayBillNo; model.Shipper = _shipment.Shipper.FullName; model.Consignee = _shipment.Consignee.FullName; model.Address = _shipment.Consignee.Address1; model.CommodityType = transmital.CommodityType.CommodityTypeName; model.Commodity = _shipment.Commodity.CommodityName; model.QTY++; model.AGW = _shipment.Weight; model.ServiceMode = _shipment.ServiceMode.ServiceModeName; model.PaymentMode = _shipment.PaymentMode.PaymentModeName; model.Gateway = transmital.Gateway; model.Destination = transmital.BranchCorpOffice.BranchCorpOfficeName; model.Batch = transmital.Batch.BatchName; model.CreatedDate = transmital.CreatedDate; model.PlateNo = transmital.PlateNo; model.MAWB = transmital.MasterAirwayBillNo; //model.ScannedBy = AppUser.User.Employee.FullName; model.ScannedBy = "N/A"; //string employee = _userService.FilterActive().Find(x => x.UserId == _bundle.CreatedBy).Employee.FullName; string employee = _userService.FindById(transmital.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } _results.Add(model); } } } return(_results); }
public List <CargoTransferViewModel> Match(List <CargoTransfer> _cargoTransfers) { PackageNumberBL _packageNumberService = new PackageNumberBL(); ShipmentBL shipment = new ShipmentBL(); List <CargoTransferViewModel> _results = new List <CargoTransferViewModel>(); BundleBL bundleService = new BundleBL(); PackageNumber _packageNumber = new PackageNumber(); List <string> listCargo = new List <string>(); UserStore _userService = new UserStore(); foreach (CargoTransfer cargoTransfer in _cargoTransfers) { CargoTransferViewModel model = new CargoTransferViewModel(); string _airwaybill = ""; try { // _airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == cargoTransfer.Cargo).Shipment.AirwayBillNo; _packageNumber = _packageNumberService.FilterActive().Where(x => x.PackageNo == cargoTransfer.Cargo).FirstOrDefault(); if (_packageNumber == null) { CargoTransferViewModel model1 = new CargoTransferViewModel(); listCargo = bundleService.GetAll().Where(x => x.SackNo == cargoTransfer.Cargo).Select(y => y.Cargo).ToList(); if (listCargo != null && listCargo.Count != 0) { CargoTransferViewModel isExist = _results.Find(x => x.AWB == cargoTransfer.Cargo); if (isExist != null) { isExist.QTY++; model.Pieces++; } else { //List<Shipment> list = shipment.GetAll().Where(x => x.AirwayBillNo.Equals(_airwaybill)).ToList(); //model1.Origin = _airwaybill; //foreach (Shipment x in list) //{ // model1.Origin = x.OriginCity.CityName; // model1.Destination = x.DestinationCity.CityName; //} model1.Origin = "N/A"; model1.Destination = "N/A"; model1.Driver = cargoTransfer.Driver; model1.Checker = cargoTransfer.Checker; model1.Pieces = listCargo.Count; model1.PlateNo = cargoTransfer.PlateNo; model1.Batch = cargoTransfer.Batch.BatchName; model1.AWB = cargoTransfer.Cargo; model1.QTY = listCargo.Count; model1.CreatedDate = cargoTransfer.CreatedDate; model1.BCO = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName; model1.GATEWAY = cargoTransfer.RevenueUnit.RevenueUnitName; model1.SATELLITE = cargoTransfer.RevenueUnit.RevenueUnitName; //model1.ScannedBy = AppUser.User.Employee.FullName; model1.ScannedBy = "N/A"; string employee = _userService.FindById(cargoTransfer.CreatedBy).Employee.FullName; if (employee != "") { model1.ScannedBy = employee; } _results.Add(model1); } } } else { _airwaybill = _packageNumber.Shipment.AirwayBillNo; CargoTransferViewModel isExist = _results.Find(x => x.AWB == _airwaybill); if (isExist != null) { isExist.QTY++; model.Pieces++; //_results.Add(isExist); } else { List <Shipment> list = shipment.GetAll().Where(x => x.AirwayBillNo.Equals(_airwaybill)).ToList(); model.Origin = _airwaybill; foreach (Shipment x in list) { model.Origin = x.OriginCity.CityName; model.Destination = x.DestinationCity.CityName; model.BCO = x.DestinationCity.BranchCorpOffice.BranchCorpOfficeName; } model.Driver = cargoTransfer.Driver; model.Checker = cargoTransfer.Checker; model.Pieces++; model.PlateNo = cargoTransfer.PlateNo; model.Batch = cargoTransfer.Batch.BatchName; model.AWB = _airwaybill; model.QTY++; model.CreatedDate = cargoTransfer.CreatedDate; // model.BCO = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName; //model.BCO = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName; model.GATEWAY = cargoTransfer.RevenueUnit.RevenueUnitName; model.SATELLITE = cargoTransfer.RevenueUnit.RevenueUnitName; //model.ScannedBy = AppUser.User.Employee.FullName; model.ScannedBy = "N/A"; string employee = _userService.FindById(cargoTransfer.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } _results.Add(model); } } } catch (Exception) { continue; } } return(_results); }
public List <UnbundleViewModel> Match(List <Unbundle> _unbundle, List <Bundle> _bundle) { BranchCorpOfficeBL bcoService = new BranchCorpOfficeBL(); PackageNumberBL _packageNumberService = new PackageNumberBL(); List <UnbundleViewModel> _results = new List <UnbundleViewModel>(); ShipmentBL shipment = new ShipmentBL(); Shipment _shipment = new Shipment(); UserStore _userService = new UserStore(); //string bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName; string bcoName = ""; Guid bcoid; Guid userid; foreach (Bundle bundle in _bundle) { UnbundleViewModel model = new UnbundleViewModel(); try { _shipment = _packageNumberService.FilterActive().Find(x => x.PackageNo == bundle.Cargo).Shipment; } catch (Exception ex) { Logs.ErrorLogs("", "Unbundle Match", ex.Message); continue; } UnbundleViewModel isExist = _results.Find(x => x.AirwayBillNo == _shipment.AirwayBillNo); if (_unbundle.Exists(x => x.Cargo == bundle.Cargo)) { if (isExist != null) { isExist.ScannedPcs++; //isExist.TotalPcs += isExist.ScannedPcs; isExist.TotalPcs = isExist.ScannedPcs; } else { model.AirwayBillNo = _shipment.AirwayBillNo; model.SackNo = bundle.SackNo; model.ScannedPcs++; model.Weight += bundle.Weight; model.TotalPcs = model.ScannedPcs; model.Origin = _shipment.OriginCity.CityName; model.CreatedDate = bundle.CreatedDate; model.Branch = "N/A"; bcoid = _unbundle.Find(x => x.Cargo == bundle.Cargo).BranchCorpOfficeID; if (bcoid != null && bcoid != Guid.Empty) { bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == bcoid).BranchCorpOfficeName; model.Branch = bcoName; } //model.ScannedBy = AppUser.User.Employee.FullName; model.ScannedBy = "N/A"; userid = _unbundle.Find(x => x.Cargo == bundle.Cargo).CreatedBy; string employee = _userService.FindById(userid).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } _results.Add(model); } } else { if (isExist != null) { isExist.TotalDiscrepency++; //isExist.TotalPcs += isExist.TotalDiscrepency; isExist.TotalPcs = isExist.TotalDiscrepency; } else { model.AirwayBillNo = _shipment.AirwayBillNo; model.SackNo = bundle.SackNo; model.TotalDiscrepency++; model.TotalPcs = model.TotalDiscrepency; model.Weight += bundle.Weight; model.Origin = _shipment.OriginCity.CityName; model.CreatedDate = bundle.CreatedDate; model.Branch = "N/A"; bcoName = _packageNumberService.FilterActive().Find(x => x.PackageNo == bundle.Cargo).Shipment.OriginCity.BranchCorpOffice.BranchCorpOfficeName; if (bcoName != "") { //bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == bcoid).BranchCorpOfficeName; model.Branch = bcoName; } //model.Branch = bundle.BranchCorpOffice.BranchCorpOfficeName; model.ScannedBy = "N/A"; _results.Add(model); } } } return(_results); }