public IActionResult Index()
        {
            ValidateSession();

            _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));
            _employeeLogic = new Lms_EmployeeLogic(_cache, new EntityFrameworkGenericRepository <Lms_EmployeePoco>(_dbContext));

            ViewBag.UserGroups = Enum.GetValues(typeof(Enum_UserGroup)).Cast <Enum_UserGroup>();
            ViewBag.Cities     = _cityLogic.GetList().Select(c => new App_CityPoco {
                Id = c.Id, CityName = c.CityName
            }).ToList();
            ViewBag.Provinces = _provinceLogic.GetList().Select(c => new App_ProvincePoco {
                Id = c.Id, ShortCode = c.ShortCode, IsDefault = c.IsDefault
            }).ToList();
            ViewBag.Countries = _countryLogic.GetList().Select(c => new App_CountryPoco {
                Id = c.Id, CountryName = c.CountryName, IsDefault = c.IsDefault
            }).ToList();
            ViewBag.Employees = _employeeLogic.GetList().Select(c => new Lms_EmployeePoco {
                Id = c.Id, FirstName = c.FirstName, LastName = c.LastName, EmailAddress = c.EmailAddress
            }).ToList();

            return(View(GetUserData()));
        }
 public CityController(IMemoryCache cache, LogisticsContext dbContext)
 {
     _dbContext     = 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));
 }
示例#3
0
        private List <ViewModel_CustomerAddress> GetCustomerAddressData(int id)
        {
            List <ViewModel_CustomerAddress> customerAddressViewModel = new List <ViewModel_CustomerAddress>();

            _customerAddressLogic = new Lms_CustomerAddressMappingLogic(_cache, new EntityFrameworkGenericRepository <Lms_CustomerAddressMappingPoco>(_dbContext));
            var customerAddresses = _customerAddressLogic.GetList().Where(c => c.CustomerId == id).ToList();

            _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();

            _countryLogic = new App_CountryLogic(_cache, new EntityFrameworkGenericRepository <App_CountryPoco>(_dbContext));
            var countries = _countryLogic.GetList();

            _addressLogic = new Lms_AddressLogic(_cache, new EntityFrameworkGenericRepository <Lms_AddressPoco>(_dbContext));
            var addresses = _addressLogic.GetList();

            foreach (var custAddress in customerAddresses)
            {
                ViewModel_CustomerAddress customerAddress = new ViewModel_CustomerAddress();

                var address = addresses.Where(c => c.Id == custAddress.AddressId).FirstOrDefault();
                customerAddress.CustomerId      = custAddress.CustomerId;
                customerAddress.AddressId       = custAddress.AddressId;
                customerAddress.AddressTypeId   = custAddress.AddressTypeId;
                customerAddress.AddressTypeName = customerAddress.AddressTypeId == 1 ? "Billing" : customerAddress.AddressTypeId == 2 ? "Shipping" : customerAddress.AddressTypeId == 4 ? "Warehouse" : "";

                customerAddress.IsDefault = custAddress.IsDefault;

                customerAddress.UnitNumber   = address.UnitNumber;
                customerAddress.HouseNumber  = address.HouseNumber;
                customerAddress.AddressLine  = address.AddressLine;
                customerAddress.CityId       = address.CityId;
                customerAddress.CityName     = cities.Where(c => c.Id == address.CityId).FirstOrDefault().CityName;
                customerAddress.ProvinceId   = address.ProvinceId;
                customerAddress.ProvinceName = provinces.Where(c => c.Id == address.ProvinceId).FirstOrDefault().ShortCode;
                customerAddress.CountryId    = address.CountryId;
                customerAddress.CountryName  = countries.Where(c => c.Id == address.CountryId).FirstOrDefault().CountryName;
                customerAddress.PostCode     = address.PostCode;

                customerAddress.MergedAddressLine  = !string.IsNullOrEmpty(customerAddress.UnitNumber) ? customerAddress.UnitNumber + ", " : customerAddress.UnitNumber;
                customerAddress.MergedAddressLine += !string.IsNullOrEmpty(customerAddress.AddressLine) ? customerAddress.AddressLine + ", " : customerAddress.AddressLine;
                customerAddress.MergedAddressLine += customerAddress.CityName + ", " + customerAddress.ProvinceName + ", " + customerAddress.CountryName;
                customerAddress.MergedAddressLine += !string.IsNullOrEmpty(customerAddress.PostCode) ? ", " + customerAddress.PostCode : customerAddress.PostCode;

                customerAddress.Email         = address.EmailAddress1;
                customerAddress.Phone         = address.PrimaryPhoneNumber;
                customerAddress.Fax           = address.Fax;
                customerAddress.ContactPerson = address.ContactPersonName;

                customerAddressViewModel.Add(customerAddress);
            }


            return(customerAddressViewModel);
        }
 public AddressController(IMemoryCache cache, LogisticsContext dbContext)
 {
     _cache         = cache;
     _dbContext     = dbContext;
     _addressLogic  = new Lms_AddressLogic(_cache, new EntityFrameworkGenericRepository <Lms_AddressPoco>(_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));
 }
        public IActionResult Index()
        {
            ValidateSession();
            _configurationLogic          = new Lms_ConfigurationLogic(_cache, new EntityFrameworkGenericRepository <Lms_ConfigurationPoco>(_dbContext));
            ViewBag.DefaultFuelSurcharge = _configurationLogic.GetSingleById(1).DefaultFuelSurcharge;

            _cityLogic        = new App_CityLogic(_cache, new EntityFrameworkGenericRepository <App_CityPoco>(_dbContext));
            ViewBag.Cities    = _cityLogic.GetList();
            _provinceLogic    = new App_ProvinceLogic(_cache, new EntityFrameworkGenericRepository <App_ProvincePoco>(_dbContext));
            ViewBag.Provinces = _provinceLogic.GetList();
            _countryLogic     = new App_CountryLogic(_cache, new EntityFrameworkGenericRepository <App_CountryPoco>(_dbContext));
            ViewBag.Countries = _countryLogic.GetList();

            return(View(GetCustomerData(0)));
        }
        private ViewModel_Employee GetEmployeeData()
        {
            ViewModel_Employee employeeViewModel = new ViewModel_Employee();

            employeeViewModel.Employees = _employeeLogic.GetList();

            _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));

            employeeViewModel.Cities    = _cityLogic.GetList();
            employeeViewModel.Provinces = _provinceLogic.GetList();
            employeeViewModel.Countries = _countryLogic.GetList();

            return(employeeViewModel);
        }
        public ReportController(IMemoryCache cache, IHostingEnvironment hostingEnvironment, IHttpContextAccessor httpContext, LogisticsContext dbContext)
        {
            _dbContext          = dbContext;
            _cache              = cache;
            _hostingEnvironment = hostingEnvironment;
            _httpContext        = httpContext;

            _orderLogic             = new Lms_OrderLogic(_cache, new EntityFrameworkGenericRepository <Lms_OrderPoco>(_dbContext));
            _customerLogic          = new Lms_CustomerLogic(_cache, new EntityFrameworkGenericRepository <Lms_CustomerPoco>(_dbContext));
            _addressMappingLogic    = new Lms_CustomerAddressMappingLogic(_cache, new EntityFrameworkGenericRepository <Lms_CustomerAddressMappingPoco>(_dbContext));
            _addressLogic           = new Lms_AddressLogic(_cache, new EntityFrameworkGenericRepository <Lms_AddressPoco>(_dbContext));
            _invoiceLogic           = new Lms_InvoiceLogic(_cache, new EntityFrameworkGenericRepository <Lms_InvoicePoco>(_dbContext));
            _additionalServiceLogic = new Lms_OrderAdditionalServiceLogic(_cache, new EntityFrameworkGenericRepository <Lms_OrderAdditionalServicePoco>(_dbContext));
            _paymentMethodLogic     = new Lms_PaymentMethodLogic(_cache, new EntityFrameworkGenericRepository <Lms_PaymentMethodPoco>(_dbContext));
            _paymentCollectionLogic = new Lms_InvoicePaymentCollectionLogic(_cache, new EntityFrameworkGenericRepository <Lms_InvoicePaymentCollectionPoco>(_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));
            _bankLogic     = new Lms_BankLogic(_cache, new EntityFrameworkGenericRepository <Lms_BankPoco>(_dbContext));
        }
        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));
        }
示例#9
0
        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);
        }
示例#10
0
        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();
        }
示例#11
0
 public ProvinceController(IMemoryCache cache, LogisticsContext dbContext)
 {
     _cache         = cache;
     _dbContext     = dbContext;
     _provinceLogic = new App_ProvinceLogic(_cache, new EntityFrameworkGenericRepository <App_ProvincePoco>(_dbContext));
 }