public JsonResult GetAddressForAutoComplete() { var addressList = _addressLogic.GetList(); var cities = _cityLogic.GetList(); var provinces = _provinceLogic.GetList(); var countries = _countryLogic.GetList(); List <ViewModel_AddressForAutoComplete> addressesForAutoComplete = new List <ViewModel_AddressForAutoComplete>(); if (addressList.Count > 0) { foreach (var address in addressList) { ViewModel_AddressForAutoComplete addressForAutoComplete = new ViewModel_AddressForAutoComplete(); addressForAutoComplete.AddressId = address.Id; addressForAutoComplete.AddressLine = (address.UnitNumber == null ? "" : address.UnitNumber + ", ") + address.AddressLine + " (" + address.Id + ")"; string addressLine = ""; addressLine += address.UnitNumber; addressLine += !string.IsNullOrEmpty(address.UnitNumber) ? ", " + address.AddressLine : address.AddressLine; addressLine += !string.IsNullOrEmpty(address.AddressLine) ? ", " + cities.Find(c => c.Id == address.CityId).CityName : cities.Find(c => c.Id == address.CityId).CityName; addressLine += !string.IsNullOrEmpty(address.CityId.ToString()) ? ", " + provinces.Find(c => c.Id == address.ProvinceId).ShortCode : provinces.Find(c => c.Id == address.ProvinceId).ShortCode; addressLine += !string.IsNullOrEmpty(address.ProvinceId.ToString()) ? ", " + countries.Find(c => c.Id == address.CountryId).CountryName : countries.Find(c => c.Id == address.CountryId).CountryName; addressLine += !string.IsNullOrEmpty(address.CountryId.ToString()) ? ", " + address.PostCode : address.PostCode; addressForAutoComplete.AddressLine = addressLine.ToUpper(); addressesForAutoComplete.Add(addressForAutoComplete); } } return(Json(JsonConvert.SerializeObject(addressesForAutoComplete))); }
public IActionResult Index() { var provinceList = _provinceLogic.GetList(); var countryList = _countryLogic.GetList(); ViewModel_Province viewModel_Prov = new ViewModel_Province(); viewModel_Prov.Provinces = provinceList; viewModel_Prov.Countries = countryList; return(View(viewModel_Prov)); }
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())); }
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 IActionResult Index() { var cityList = _cityLogic.GetList(); var provinceList = _provinceLogic.GetList(); var countryList = _countryLogic.GetList(); ViewModel_City viewModel_City = new ViewModel_City(); viewModel_City.Cities = cityList; viewModel_City.Provinces = provinceList; viewModel_City.Countries = countryList; return(View(viewModel_City)); }
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); }
private List <ViewModel_SearchResult_Order> GetOrdersByQuery(string filteredData) { List <ViewModel_SearchResult_Order> searchResults = new List <ViewModel_SearchResult_Order>(); JObject queryData = new JObject(); string fromDate = "", toDate = "", optionForWaybill = "", waybillNumber = "", optionForBillTo = "", billToCustomerName = "", optionForShipper = "", shipperCustomerName = "", optionForCctn = "", cctnRef = "", optionForActn = "", actnRef = "", optionForConsignee = "", consigneeCustomerName = "", optionForDelRef = "", delRef = "", optionForPuRef = "", puRef = "", optionForOrderBy = "", orderBy = "", optionForBolRef = "", bolRef = "", optionForProRef = "", proRef = "", optionForCustomerRef = "", customerRef = ""; if (filteredData != string.Empty) { queryData = JObject.Parse(filteredData); fromDate = queryData.SelectToken("fromDate").ToString(); toDate = queryData.SelectToken("toDate").ToString(); optionForWaybill = queryData.SelectToken("optionForWaybill").ToString(); waybillNumber = queryData.SelectToken("waybillNumber").ToString(); optionForBillTo = queryData.SelectToken("optionForBillTo").ToString(); billToCustomerName = queryData.SelectToken("billToCustomerName").ToString(); optionForShipper = queryData.SelectToken("optionForShipper").ToString(); shipperCustomerName = queryData.SelectToken("shipperCustomerName").ToString(); optionForCctn = queryData.SelectToken("optionForCctn").ToString(); cctnRef = queryData.SelectToken("cctnRef").ToString(); optionForActn = queryData.SelectToken("optionForActn").ToString(); actnRef = queryData.SelectToken("actnRef").ToString(); optionForConsignee = queryData.SelectToken("optionForConsignee").ToString(); consigneeCustomerName = queryData.SelectToken("consigneeCustomerName").ToString(); optionForDelRef = queryData.SelectToken("optionForDelRef").ToString(); delRef = queryData.SelectToken("delRef").ToString(); optionForPuRef = queryData.SelectToken("optionForPuRef").ToString(); puRef = queryData.SelectToken("puRef").ToString(); optionForOrderBy = queryData.SelectToken("optionForOrderBy").ToString(); orderBy = queryData.SelectToken("orderBy").ToString(); optionForBolRef = queryData.SelectToken("optionForBolRef").ToString(); bolRef = queryData.SelectToken("bolRef").ToString(); optionForProRef = queryData.SelectToken("optionForProRef").ToString(); proRef = queryData.SelectToken("proRef").ToString(); optionForCustomerRef = queryData.SelectToken("optionForCustomerRef").ToString(); customerRef = queryData.SelectToken("customerRef").ToString(); } var orders = _orderLogic.GetList().Where(c => c.OrderTypeId == 1 && (c.TotalOrderCost + c.TotalAdditionalServiceCost) > 0).ToList(); List <Lms_CustomerPoco> customers = new List <Lms_CustomerPoco>(); customers = _customerLogic.GetList(); if (fromDate != "" && toDate != "") { orders = orders.Where(c => c.ScheduledPickupDate >= Convert.ToDateTime(fromDate) && c.ScheduledPickupDate <= Convert.ToDateTime(toDate)).ToList(); } if (waybillNumber.Trim() != "") { if (optionForWaybill == "1") { orders = orders.Where(c => c.WayBillNumber.Equals(waybillNumber.Trim())).ToList(); } else if (optionForWaybill == "2") { orders = orders.Where(c => c.WayBillNumber.Contains(waybillNumber.Trim())).ToList(); } } if (customerRef.Trim() != "") { if (optionForCustomerRef == "1") { orders = orders.Where(c => c.ReferenceNumber != null && c.ReferenceNumber.ToUpper().Equals(customerRef.ToUpper())).ToList(); } else if (optionForCustomerRef == "2") { orders = orders.Where(c => c.ReferenceNumber != null && c.ReferenceNumber.ToUpper().Contains(customerRef.ToUpper())).ToList(); } } if (billToCustomerName.Trim() != "") { if (optionForBillTo == "1") { customers = new List <Lms_CustomerPoco>(); customers = _customerLogic.GetList().Where(c => c.CustomerName.Equals(billToCustomerName.ToUpper())).OrderBy(c => c.Id).ToList(); orders = orders.Where(c => customers.Any(d => d.Id == c.BillToCustomerId)).ToList(); } else if (optionForBillTo == "2") { customers = new List <Lms_CustomerPoco>(); customers = _customerLogic.GetList().Where(c => c.CustomerName.ToUpper().Contains(billToCustomerName.ToUpper())).OrderBy(c => c.Id).ToList(); orders = orders.Where(c => customers.Any(d => d.Id == c.BillToCustomerId)).ToList(); } } if (shipperCustomerName.Trim() != "") { if (optionForShipper == "1") { customers = new List <Lms_CustomerPoco>(); customers = _customerLogic.GetList().Where(c => c.CustomerName.ToUpper().Equals(shipperCustomerName.ToUpper())).OrderBy(c => c.Id).ToList(); orders = orders.Where(c => customers.Any(d => c.ShipperCustomerId != null && d.Id == c.ShipperCustomerId)).ToList(); } else if (optionForShipper == "2") { customers = new List <Lms_CustomerPoco>(); customers = _customerLogic.GetList().Where(c => c.CustomerName.ToUpper().Contains(shipperCustomerName.ToUpper())).OrderBy(c => c.Id).ToList(); orders = orders.Where(c => customers.Any(d => c.ShipperCustomerId != null && d.Id == c.ShipperCustomerId)).ToList(); } } if (consigneeCustomerName.Trim() != "") { if (optionForConsignee == "1") { customers = new List <Lms_CustomerPoco>(); customers = _customerLogic.GetList().Where(c => c.CustomerName.ToUpper().Equals(consigneeCustomerName.ToUpper())).OrderBy(c => c.Id).ToList(); orders = orders.Where(c => customers.Any(d => c.ConsigneeCustomerId != null && d.Id == c.ConsigneeCustomerId)).ToList(); } else if (optionForConsignee == "2") { customers = new List <Lms_CustomerPoco>(); customers = _customerLogic.GetList().Where(c => c.CustomerName.ToUpper().Contains(consigneeCustomerName.ToUpper())).OrderBy(c => c.Id).ToList(); orders = orders.Where(c => customers.Any(d => c.ConsigneeCustomerId != null && d.Id == c.ConsigneeCustomerId)).ToList(); } } if (cctnRef.Trim() != "") { if (optionForCctn == "1") { orders = orders.Where(c => c.CargoCtlNumber != null && c.CargoCtlNumber.ToUpper().Equals(cctnRef.ToUpper())).ToList(); } else if (optionForCctn == "2") { orders = orders.Where(c => c.CargoCtlNumber != null && c.CargoCtlNumber.ToUpper().Contains(cctnRef.ToUpper())).ToList(); } } if (actnRef.Trim() != "") { if (optionForActn == "1") { orders = orders.Where(c => c.AwbCtnNumber != null && c.AwbCtnNumber.ToUpper().Equals(actnRef.ToUpper())).ToList(); } else if (optionForActn == "2") { orders = orders.Where(c => c.AwbCtnNumber != null && c.AwbCtnNumber.ToUpper().Contains(actnRef.ToUpper())).ToList(); } } if (delRef.Trim() != "") { if (optionForDelRef == "1") { orders = orders.Where(c => c.DeliveryReferenceNumber != null && c.DeliveryReferenceNumber.ToUpper().Equals(delRef.ToUpper())).ToList(); } else if (optionForDelRef == "2") { orders = orders.Where(c => c.DeliveryReferenceNumber != null && c.DeliveryReferenceNumber.ToUpper().Contains(delRef.ToUpper())).ToList(); } } if (puRef.Trim() != "") { if (optionForPuRef == "1") { orders = orders.Where(c => c.PickupReferenceNumber != null && c.PickupReferenceNumber.ToUpper().Equals(puRef.ToUpper())).ToList(); } else if (optionForPuRef == "2") { orders = orders.Where(c => c.PickupReferenceNumber != null && c.PickupReferenceNumber.ToUpper().Contains(puRef.ToUpper())).ToList(); } } if (orderBy.Trim() != "") { if (orderBy == "1") { orders = orders.Where(c => c.OrderedBy != null && c.OrderedBy.ToUpper().Equals(orderBy.ToUpper())).ToList(); } else if (orderBy == "2") { orders = orders.Where(c => c.OrderedBy != null && c.OrderedBy.ToUpper().Contains(orderBy.ToUpper())).ToList(); } } if (bolRef.Trim() != "") { if (orderBy == "1") { orders = orders.Where(c => c.BolReferenceNumber != null && c.BolReferenceNumber.ToUpper().Equals(bolRef.ToUpper())).ToList(); } else if (orderBy == "2") { orders = orders.Where(c => c.BolReferenceNumber != null && c.BolReferenceNumber.ToUpper().Contains(bolRef.ToUpper())).ToList(); } } if (proRef.Trim() != "") { if (orderBy == "1") { orders = orders.Where(c => c.ProReferenceNumber != null && c.ProReferenceNumber.ToUpper().Equals(proRef.ToUpper())).ToList(); } else if (orderBy == "2") { orders = orders.Where(c => c.ProReferenceNumber != null && c.ProReferenceNumber.ToUpper().Contains(proRef.ToUpper())).ToList(); } } customers = _customerLogic.GetList(); var employees = _employeeLogic.GetList(); var addresses = _addressLogic.GetList(); var unitTypes = _unitTypeLogic.GetList(); var weightScales = _weightScaleLogic.GetList(); var deliveyOptions = _deliveryOptionLogic.GetList(); var vehicleTypes = _vehicleTypeScaleLogic.GetList(); var cities = _cityLogic.GetList(); var provinces = _provinceLogic.GetList(); var countries = _countryLogic.GetList(); foreach (var order in orders) { var resultModel = new ViewModel_SearchResult_Order(); resultModel.OrderId = order.Id; resultModel.OrderTypeId = order.OrderTypeId; resultModel.OrderId = order.OrderTypeId; resultModel.OrderTypeId = order.OrderTypeId; resultModel.WayBillNumber = order.WayBillNumber; resultModel.ReferenceNumber = order.ReferenceNumber; resultModel.CargoCtlNumber = order.CargoCtlNumber; resultModel.AwbCtnNumber = order.AwbCtnNumber; resultModel.PickupReferenceNumber = order.PickupReferenceNumber; resultModel.DeliveryReferenceNumber = order.DeliveryReferenceNumber; resultModel.ShipperCustomerId = order.ShipperCustomerId; if (resultModel.ShipperCustomerId != null && resultModel.ShipperCustomerId > 0) { resultModel.ShipperCustomerName = customers.Where(c => c.Id == resultModel.ShipperCustomerId).FirstOrDefault().CustomerName; } resultModel.ShipperAddressId = order.ShipperAddressId; if (resultModel.ShipperAddressId != null && resultModel.ShipperAddressId > 0) { var address = addresses.Where(c => c.Id == resultModel.ShipperAddressId).FirstOrDefault(); resultModel.ShipperUnitNumber = address.UnitNumber; resultModel.ShipperAddressLine = address.AddressLine; if (address.CityId > 0) { resultModel.ShipperCityName = cities.Where(c => c.Id == address.CityId).FirstOrDefault().CityName; } if (address.ProvinceId > 0) { resultModel.ShipperProvinceName = provinces.Where(c => c.Id == address.ProvinceId).FirstOrDefault().ShortCode; } if (address.CountryId > 0) { resultModel.ShipperCountryName = countries.Where(c => c.Id == address.CountryId).FirstOrDefault().Alpha3CountryCode; } resultModel.ShipperPostCode = address.PostCode; } resultModel.ConsigneeCustomerId = order.ConsigneeCustomerId; if (resultModel.ConsigneeCustomerId != null && resultModel.ConsigneeCustomerId > 0) { resultModel.ConsigneeCustomerName = customers.Where(c => c.Id == resultModel.ConsigneeCustomerId).FirstOrDefault().CustomerName; } resultModel.ConsigneeAddressId = order.ConsigneeAddressId; if (resultModel.ConsigneeAddressId != null && resultModel.ConsigneeAddressId > 0) { var address = addresses.Where(c => c.Id == resultModel.ConsigneeAddressId).FirstOrDefault(); resultModel.ConsigneeUnitNumber = address.UnitNumber; resultModel.ConsigneeAddressLine = address.AddressLine; if (address.CityId > 0) { resultModel.ConsigneeCityName = cities.Where(c => c.Id == address.CityId).FirstOrDefault().CityName; } if (address.ProvinceId > 0) { resultModel.ConsigneeProvinceName = provinces.Where(c => c.Id == address.ProvinceId).FirstOrDefault().ShortCode; } if (address.CountryId > 0) { resultModel.ConsigneeCountryName = countries.Where(c => c.Id == address.CountryId).FirstOrDefault().Alpha3CountryCode; } resultModel.ConsigneePostCode = address.PostCode; } resultModel.BillToCustomerId = order.BillToCustomerId; if (resultModel.BillToCustomerId > 0) { resultModel.BillToCustomerName = customers.Where(c => c.Id == resultModel.BillToCustomerId).FirstOrDefault().CustomerName; } resultModel.ServiceProviderEmployeeId = order.ServiceProviderEmployeeId; if (resultModel.ServiceProviderEmployeeId > 0) { var emp = employees.Where(c => c.Id == resultModel.ServiceProviderEmployeeId).FirstOrDefault(); resultModel.ServiceProviderEmployeeName = emp.FirstName + " " + emp.LastName; } resultModel.ScheduledPickupDate = order.ScheduledPickupDate; resultModel.ExpectedDeliveryDate = order.ExpectedDeliveryDate; resultModel.CityId = order.CityId; if (resultModel.CityId > 0) { resultModel.CityName = cities.Where(c => c.Id == resultModel.CityId).FirstOrDefault().CityName; } resultModel.DeliveryOptionId = order.DeliveryOptionId; if (resultModel.DeliveryOptionId > 0) { resultModel.DeliveryOptionName = deliveyOptions.Where(c => c.Id == resultModel.DeliveryOptionId).FirstOrDefault().ShortCode; } resultModel.VehicleTypeId = order.VehicleTypeId; if (resultModel.VehicleTypeId > 0) { resultModel.VehicleTypeName = vehicleTypes.Where(c => c.Id == resultModel.VehicleTypeId).FirstOrDefault().TypeName; } resultModel.UnitTypeId = order.UnitTypeId; if (resultModel.UnitTypeId > 0) { resultModel.UnitTypeName = unitTypes.Where(c => c.Id == resultModel.UnitTypeId).FirstOrDefault().TypeName; } resultModel.WeightScaleId = order.WeightScaleId; if (resultModel.WeightScaleId > 0) { resultModel.WeightScaleName = weightScales.Where(c => c.Id == resultModel.WeightScaleId).FirstOrDefault().ShortCode; } resultModel.WeightTotal = order.WeightTotal; resultModel.UnitQuantity = order.UnitQuantity; resultModel.SkidQuantity = order.SkidQuantity; resultModel.TotalPiece = order.TotalPiece; resultModel.OrderBasicCost = order.OrderBasicCost; resultModel.BasicCostOverriden = order.BasicCostOverriden; resultModel.FuelSurchargePercentage = order.FuelSurchargePercentage; resultModel.DiscountPercentOnOrderCost = order.DiscountPercentOnOrderCost; resultModel.ApplicableGstPercent = order.ApplicableGstPercent; resultModel.TotalOrderCost = order.TotalOrderCost; resultModel.TotalAdditionalServiceCost = order.TotalAdditionalServiceCost; resultModel.OrderedBy = order.OrderedBy; resultModel.DeliveredBy = order.DeliveredBy; resultModel.BolReferenceNumber = order.BolReferenceNumber; resultModel.ProReferenceNumber = order.ProReferenceNumber; resultModel.ShipperName = order.ShipperName; resultModel.ShipperAddress = order.ShipperAddress; resultModel.OrderShareAmount = order.OrderShareAmount; resultModel.IsSharingOnPercent = order.IsSharingOnPercent; resultModel.IsInvoiced = order.IsInvoiced; resultModel.CommentsForWayBill = order.CommentsForWayBill; resultModel.IsPrintedOnWayBill = order.IsPrintedOnWayBill; resultModel.CommentsForInvoice = order.CommentsForInvoice; resultModel.IsPrintedOnInvoice = order.IsPrintedOnInvoice; resultModel.IsPrePrinted = order.IsPrePrinted; resultModel.Remarks = order.Remarks; resultModel.OrderDateString = order.CreateDate.ToString("dd-MMM-yyyy"); searchResults.Add(resultModel); } return(searchResults); }
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 IActionResult Index() { var customerList = _provinceLogic.GetList(); return(View()); }