public IActionResult Index() { ValidateSession(); ViewBag.TaxToCall = Enum.GetValues(typeof(Enum_TaxToCall)).Cast <Enum_TaxToCall>(); var configuration = _configurationLogic.GetSingleById(1); _unitTypeLogic = new Lms_UnitTypeLogic(_cache, new EntityFrameworkGenericRepository <Lms_UnitTypePoco>(_dbContext)); _weightScaleLogic = new Lms_WeightScaleLogic(_cache, new EntityFrameworkGenericRepository <Lms_WeightScalePoco>(_dbContext)); ViewBag.UnitTypes = _unitTypeLogic.GetList(); ViewBag.WeightScales = _weightScaleLogic.GetList(); return(View(configuration)); }
private ViewModel_Tariff GetTariffData() { _tariffLogic = new Lms_TariffLogic(_cache, new EntityFrameworkGenericRepository <Lms_TariffPoco>(_dbContext)); _cityLogic = new App_CityLogic(_cache, new EntityFrameworkGenericRepository <App_CityPoco>(_dbContext)); _deliveryOptionLogic = new Lms_DeliveryOptionLogic(_cache, new EntityFrameworkGenericRepository <Lms_DeliveryOptionPoco>(_dbContext)); _vehicleTypeLogic = new Lms_VehicleTypeLogic(_cache, new EntityFrameworkGenericRepository <Lms_VehicleTypePoco>(_dbContext)); _unitTypeLogic = new Lms_UnitTypeLogic(_cache, new EntityFrameworkGenericRepository <Lms_UnitTypePoco>(_dbContext)); _weightScaleLogic = new Lms_WeightScaleLogic(_cache, new EntityFrameworkGenericRepository <Lms_WeightScalePoco>(_dbContext)); ViewModel_Tariff tariffViewModel = new ViewModel_Tariff(); tariffViewModel.Tariffs = _tariffLogic.GetList(); tariffViewModel.Cities = _cityLogic.GetList(); tariffViewModel.DeliveryOptions = _deliveryOptionLogic.GetList(); tariffViewModel.VehicleTypes = _vehicleTypeLogic.GetList(); tariffViewModel.UnitTypes = _unitTypeLogic.GetList(); tariffViewModel.WeightScales = _weightScaleLogic.GetList(); return(tariffViewModel); }
public SearchController(IMemoryCache cache, IEmailService emailService, IHostingEnvironment hostingEnvironment, IHttpContextAccessor httpContext, LogisticsContext dbContext) { _cache = cache; _dbContext = dbContext; _emailService = emailService; _hostingEnvironment = hostingEnvironment; _httpContext = httpContext; _orderLogic = new Lms_OrderLogic(_cache, new EntityFrameworkGenericRepository <Lms_OrderPoco>(_dbContext)); _customerLogic = new Lms_CustomerLogic(_cache, new EntityFrameworkGenericRepository <Lms_CustomerPoco>(_dbContext)); _addressLogic = new Lms_AddressLogic(_cache, new EntityFrameworkGenericRepository <Lms_AddressPoco>(_dbContext)); _employeeLogic = new Lms_EmployeeLogic(_cache, new EntityFrameworkGenericRepository <Lms_EmployeePoco>(_dbContext)); _cityLogic = new App_CityLogic(_cache, new EntityFrameworkGenericRepository <App_CityPoco>(_dbContext)); _provinceLogic = new App_ProvinceLogic(_cache, new EntityFrameworkGenericRepository <App_ProvincePoco>(_dbContext)); _countryLogic = new App_CountryLogic(_cache, new EntityFrameworkGenericRepository <App_CountryPoco>(_dbContext)); _unitTypeLogic = new Lms_UnitTypeLogic(_cache, new EntityFrameworkGenericRepository <Lms_UnitTypePoco>(_dbContext)); _weightScaleLogic = new Lms_WeightScaleLogic(_cache, new EntityFrameworkGenericRepository <Lms_WeightScalePoco>(_dbContext)); _deliveryOptionLogic = new Lms_DeliveryOptionLogic(_cache, new EntityFrameworkGenericRepository <Lms_DeliveryOptionPoco>(_dbContext)); _vehicleTypeScaleLogic = new Lms_VehicleTypeLogic(_cache, new EntityFrameworkGenericRepository <Lms_VehicleTypePoco>(_dbContext)); }
private ViewModel_MiscellaneousOrder GetMiscellaneousOrders() { ViewModel_MiscellaneousOrder miscOrderViewModel = new ViewModel_MiscellaneousOrder(); _cityLogic = new App_CityLogic(_cache, new EntityFrameworkGenericRepository <App_CityPoco>(_dbContext)); miscOrderViewModel.Cities = _cityLogic.GetList(); _provinceLogic = new App_ProvinceLogic(_cache, new EntityFrameworkGenericRepository <App_ProvincePoco>(_dbContext)); miscOrderViewModel.Provinces = _provinceLogic.GetList(); _configurationLogic = new Lms_ConfigurationLogic(_cache, new EntityFrameworkGenericRepository <Lms_ConfigurationPoco>(_dbContext)); miscOrderViewModel.Configuration = _configurationLogic.GetList().FirstOrDefault(); _customerLogic = new Lms_CustomerLogic(_cache, new EntityFrameworkGenericRepository <Lms_CustomerPoco>(_dbContext)); miscOrderViewModel.Customers = _customerLogic.GetList(); _deliveryOptionLogic = new Lms_DeliveryOptionLogic(_cache, new EntityFrameworkGenericRepository <Lms_DeliveryOptionPoco>(_dbContext)); miscOrderViewModel.DeliveryOptions = _deliveryOptionLogic.GetList(); _unitTypeLogic = new Lms_UnitTypeLogic(_cache, new EntityFrameworkGenericRepository <Lms_UnitTypePoco>(_dbContext)); miscOrderViewModel.UnitTypes = _unitTypeLogic.GetList(); _weightScaleLogic = new Lms_WeightScaleLogic(_cache, new EntityFrameworkGenericRepository <Lms_WeightScalePoco>(_dbContext)); miscOrderViewModel.WeightScales = _weightScaleLogic.GetList(); _additionalServiceLogic = new Lms_AdditionalServiceLogic(_cache, new EntityFrameworkGenericRepository <Lms_AdditionalServicePoco>(_dbContext)); miscOrderViewModel.AdditionalServices = _additionalServiceLogic.GetList(); _employeeLogic = new Lms_EmployeeLogic(_cache, new EntityFrameworkGenericRepository <Lms_EmployeePoco>(_dbContext)); miscOrderViewModel.Employees = _employeeLogic.GetList().Where(c => c.EmployeeTypeId == 5).ToList(); // Load employees 'Broker' var orders = _orderLogic.GetList().Where(c => c.OrderTypeId == 3).ToList(); // Load only misc. orders List <ViewModel_OrderDispatched> viewModelOrders = new List <ViewModel_OrderDispatched>(); foreach (var item in orders) { ViewModel_OrderDispatched viewModelOrder = new ViewModel_OrderDispatched(); viewModelOrder.OrderId = item.Id; viewModelOrder.OrderTypeId = item.OrderTypeId; viewModelOrder.OrderTypeFlag = "Misc."; viewModelOrder.ServiceProviderEmployeeId = item.ServiceProviderEmployeeId; if (item.ServiceProviderEmployeeId != null && item.ServiceProviderEmployeeId > 0) { viewModelOrder.ServiceProviderEmployeeName = (miscOrderViewModel.Employees.Where(c => c.Id == item.ServiceProviderEmployeeId).FirstOrDefault()).FirstName; } viewModelOrder.WayBillNumber = item.WayBillNumber; viewModelOrder.OrderDateString = item.CreateDate.ToString("dd-MMM-yy"); viewModelOrder.CustomerRefNumber = item.ReferenceNumber; viewModelOrder.UnitTypeId = item.UnitTypeId; if (item.UnitTypeId > 0) { viewModelOrder.UnitTypeName = miscOrderViewModel.UnitTypes.Where(c => c.Id == viewModelOrder.UnitTypeId).FirstOrDefault().ShortCode; } viewModelOrder.UnitQuantity = item.UnitQuantity; viewModelOrder.SkidQuantity = item.SkidQuantity; viewModelOrder.TotalPiece = item.TotalPiece; viewModelOrder.SpcIns = ""; viewModelOrder.BillerCustomerId = item.BillToCustomerId; if (item.BillToCustomerId > 0) { viewModelOrder.BillerCustomerName = miscOrderViewModel.Customers.Where(c => c.Id == viewModelOrder.BillerCustomerId).FirstOrDefault().CustomerName; } viewModelOrders.Add(viewModelOrder); } miscOrderViewModel.MiscellaneousOrders = viewModelOrders; return(miscOrderViewModel); }
public JsonResult PrintWaybill([FromBody] dynamic orderData) { try { List <ViewModel_PrintWaybill> waybillPrintViewModels = new List <ViewModel_PrintWaybill>(); JArray wayBillNumberList = null; var orderList = _orderLogic.GetList(); _addressLogic = new Lms_AddressLogic(_cache, new EntityFrameworkGenericRepository <Lms_AddressPoco>(_dbContext)); var addresses = _addressLogic.GetList(); _cityLogic = new App_CityLogic(_cache, new EntityFrameworkGenericRepository <App_CityPoco>(_dbContext)); var cities = _cityLogic.GetList(); _provinceLogic = new App_ProvinceLogic(_cache, new EntityFrameworkGenericRepository <App_ProvincePoco>(_dbContext)); var provinces = _provinceLogic.GetList(); _customerLogic = new Lms_CustomerLogic(_cache, new EntityFrameworkGenericRepository <Lms_CustomerPoco>(_dbContext)); var customers = _customerLogic.GetList(); _deliveryOptionLogic = new Lms_DeliveryOptionLogic(_cache, new EntityFrameworkGenericRepository <Lms_DeliveryOptionPoco>(_dbContext)); var deliveryOptions = _deliveryOptionLogic.GetList(); _unitTypeLogic = new Lms_UnitTypeLogic(_cache, new EntityFrameworkGenericRepository <Lms_UnitTypePoco>(_dbContext)); var unitTypes = _unitTypeLogic.GetList(); _weightScaleLogic = new Lms_WeightScaleLogic(_cache, new EntityFrameworkGenericRepository <Lms_WeightScalePoco>(_dbContext)); var weightScales = _weightScaleLogic.GetList(); if (orderData != null) { wayBillNumberList = JArray.Parse(JsonConvert.SerializeObject(orderData[0])); } foreach (var item in wayBillNumberList) { var wbNumber = item.ToString(); var orderInfo = orderList.Where(c => c.WayBillNumber == wbNumber && c.OrderTypeId == 1).FirstOrDefault(); //consider only the single order; not the return order if (orderInfo != null) { ViewModel_PrintWaybill waybillPrintViewModel = new ViewModel_PrintWaybill(); waybillPrintViewModel.WaybillNumber = orderInfo.WayBillNumber; waybillPrintViewModel.WayBillDate = orderInfo.CreateDate.ToString("dd-MMM-yy"); waybillPrintViewModel.BillerCustomerId = orderInfo.BillToCustomerId; waybillPrintViewModel.CustomerRefNo = orderInfo.ReferenceNumber; waybillPrintViewModel.CargoCtlNo = orderInfo.CargoCtlNumber; waybillPrintViewModel.AwbContainerNo = orderInfo.AwbCtnNumber; waybillPrintViewModel.BillerCustomerName = customers.Where(c => c.Id == orderInfo.BillToCustomerId).FirstOrDefault().CustomerName; waybillPrintViewModel.OrderedByName = orderInfo.OrderedBy; waybillPrintViewModel.DeliveryOptionShortCode = deliveryOptions.Where(c => c.Id == orderInfo.DeliveryOptionId).FirstOrDefault().ShortCode; waybillPrintViewModel.OrderBasePrice = orderInfo.OrderBasicCost.ToString(); if (orderInfo.BasicCostOverriden != null && orderInfo.BasicCostOverriden > 0) { waybillPrintViewModel.OrderBasePrice = orderInfo.BasicCostOverriden.ToString(); } if (orderInfo.DiscountPercentOnOrderCost != null && orderInfo.DiscountPercentOnOrderCost > 0) { var orderDiscount = Convert.ToDecimal(waybillPrintViewModel.OrderBasePrice) - (Convert.ToDecimal(waybillPrintViewModel.OrderBasePrice) * orderInfo.DiscountPercentOnOrderCost / 100); if (orderDiscount > 0) { waybillPrintViewModel.OrderDiscountAmount = orderDiscount.ToString(); waybillPrintViewModel.OrderBasePrice = (Convert.ToDecimal(waybillPrintViewModel.OrderBasePrice) - (decimal)orderDiscount).ToString(); } else { waybillPrintViewModel.OrderDiscountAmount = "0.00"; } } if (orderInfo.FuelSurchargePercentage != null && orderInfo.FuelSurchargePercentage > 0) { var fuelAmnt = Convert.ToDecimal(waybillPrintViewModel.OrderBasePrice) * orderInfo.FuelSurchargePercentage / 100; if (fuelAmnt > 0) { waybillPrintViewModel.FuelSurcharge = fuelAmnt.ToString(); } else { waybillPrintViewModel.FuelSurcharge = "0.00"; } } if (orderInfo.TotalAdditionalServiceCost > 0) { waybillPrintViewModel.AdditionalServiceCost = orderInfo.TotalAdditionalServiceCost.ToString(); } else { waybillPrintViewModel.AdditionalServiceCost = "0.00"; } if (orderInfo.ApplicableGstPercent != null && orderInfo.ApplicableGstPercent > 0) { var taxAmnt = Convert.ToDecimal(waybillPrintViewModel.OrderBasePrice) * orderInfo.ApplicableGstPercent / 100; if (taxAmnt > 0) { waybillPrintViewModel.OrderTaxAmountOnBasePrice = taxAmnt.ToString(); } else { waybillPrintViewModel.OrderTaxAmountOnBasePrice = "0.00"; } } waybillPrintViewModel.NetTotalOrderCost = (Convert.ToDecimal(waybillPrintViewModel.OrderBasePrice) + Convert.ToDecimal(waybillPrintViewModel.FuelSurcharge) + Convert.ToDecimal(waybillPrintViewModel.AdditionalServiceCost)).ToString(); waybillPrintViewModel.ShipperCustomerName = customers.Where(c => c.Id == orderInfo.ShipperCustomerId).FirstOrDefault().CustomerName; var shippperAddress = addresses.Where(c => c.Id == orderInfo.ShipperAddressId).FirstOrDefault(); waybillPrintViewModel.ShipperCustomerAddressLine1 = !string.IsNullOrEmpty(shippperAddress.UnitNumber) ? shippperAddress.UnitNumber + ", " + shippperAddress.AddressLine : shippperAddress.AddressLine; waybillPrintViewModel.ShipperCustomerAddressLine2 = cities.Where(c => c.Id == shippperAddress.CityId).FirstOrDefault().CityName + ", " + provinces.Where(c => c.Id == shippperAddress.ProvinceId).FirstOrDefault().ShortCode + " " + shippperAddress.PostCode; waybillPrintViewModel.ConsigneeCustomerName = customers.Where(c => c.Id == orderInfo.ConsigneeCustomerId).FirstOrDefault().CustomerName; var consigneeAddress = addresses.Where(c => c.Id == orderInfo.ConsigneeAddressId).FirstOrDefault(); waybillPrintViewModel.ConsigneeCustomerAddressLine1 = !string.IsNullOrEmpty(consigneeAddress.UnitNumber) ? consigneeAddress.UnitNumber + ", " + consigneeAddress.AddressLine : consigneeAddress.AddressLine; waybillPrintViewModel.ConsigneeCustomerAddressLine2 = cities.Where(c => c.Id == consigneeAddress.CityId).FirstOrDefault().CityName + ", " + provinces.Where(c => c.Id == consigneeAddress.ProvinceId).FirstOrDefault().ShortCode + " " + consigneeAddress.PostCode; waybillPrintViewModel.TotalSkidPieces = 0; waybillPrintViewModel.UnitTypeName = unitTypes.Where(c => c.Id == orderInfo.UnitTypeId).FirstOrDefault().TypeName; waybillPrintViewModel.UnitTypeShortCode = unitTypes.Where(c => c.Id == orderInfo.UnitTypeId).FirstOrDefault().ShortCode; waybillPrintViewModel.UnitQuantity = orderInfo.UnitQuantity; waybillPrintViewModel.WeightScaleShortCode = weightScales.Where(c => c.Id == orderInfo.WeightScaleId).FirstOrDefault().ShortCode; waybillPrintViewModel.WeightTotal = orderInfo.WeightTotal.ToString(); waybillPrintViewModel.DeliveryDate = null; waybillPrintViewModel.DeliveryTime = null; waybillPrintViewModel.PUDriverName = ""; waybillPrintViewModel.DeliveryDriverName = orderInfo.WayBillNumber; if (orderInfo.IsPrintedOnWayBill != null && orderInfo.IsPrintedOnWayBill == true) { waybillPrintViewModel.WaybillComments = orderInfo.CommentsForWayBill; } waybillPrintViewModels.Add(waybillPrintViewModel); } } var webrootPath = _hostingEnvironment.WebRootPath; var uniqueId = DateTime.Now.ToFileTime(); var path = "/contents/waybills/waybill_" + uniqueId + ".pdf"; var filePath = webrootPath + path; var pdfReport = new ViewAsPdf("PrintWaybill", waybillPrintViewModels); var file = pdfReport.BuildFile(ControllerContext).Result; System.IO.File.WriteAllBytes(filePath, file); //_emailService.SendEmail("*****@*****.**", "test subject", "test body content", path); return(Json(path)); } catch (Exception ex) { return(null); } //return View(); }
public WeightScaleController(IMemoryCache cache, LogisticsContext dbContext) { _dbContext = dbContext; _weightScaleLogic = new Lms_WeightScaleLogic(_cache, new EntityFrameworkGenericRepository <Lms_WeightScalePoco>(_dbContext)); }