Exemplo n.º 1
0
        public List <CustomerLocationModel> GetCustomerLocationModels(Guid cdId)
        {
            var customerDepartment = _departmentService
                                     .CustomerDepartmentByCustomerDepartmentId(cdId);
            var list = _locationService
                       .GetAllCustomerLocationsByCustomerID(customerDepartment.CustomerID);
            var result = new List <CustomerLocationModel>();

            foreach (var customerLocation in list)
            {
                var address = _addressService.AddressById(customerLocation.AddressID);
                result.Add(new CustomerLocationModel()
                {
                    // one CustomerDepartmentName
                    CustomerDepartmentName = customerDepartment.CustomerDepartmentName,
                    // several customerLocation
                    CustomerLocationID   = customerLocation.CustomerLocationID,
                    CustomerLocationName = customerLocation.CustomerLocationName,
                    Telephone            = customerLocation.TelephoneNumber,
                    FaxNumber            = customerLocation.FaxNumber,
                    Address = address == null ? new AddressModels() : new AddressModels()
                    {
                        AddressLine1 = address.AddressLine1 ?? "",
                        AddressLine2 = address.AddressLine2 ?? "",
                        AddressLine3 = address.AddressLine3 ?? "",
                        CountyCity   = address.CountyCity ?? "",
                        PostalTown   = address.PostalTown ?? "",
                        Postcode     = address.Postcode ?? "",
                    }

                    /*
                     * Address = customerLocation.Address == null ? new AddressModels() : new AddressModels()
                     * {
                     *  AddressLine1 = customerLocation.Address.AddressLine1 ?? "",
                     *  AddressLine2 = customerLocation.Address.AddressLine2 ?? "",
                     *  AddressLine3 = customerLocation.Address.AddressLine3 ?? "",
                     *  CountyCity = customerLocation.Address.CountyCity ?? "",
                     *  PostalTown = customerLocation.Address.PostalTown ?? "",
                     *  Postcode = customerLocation.Address.Postcode ?? "",
                     * }
                     */
                });
            }
            return(result);
        }
Exemplo n.º 2
0
        public List <CustomerDepartmentEditModel> BuildCustomerDepartmentModels(List <CustomerDepartment> customerDepartments)
        {
            var list = new List <CustomerDepartmentEditModel>();

            foreach (var item in customerDepartments)
            {
                var model = new CustomerDepartmentEditModel();
                model.CustomerDepartmentID   = item.CustomerDepartmentID;
                model.CustomerDepartmentName = item.CustomerDepartmentName;
                model.CustomerID             = item.CustomerID;
                model.EmailAddress           = item.EmailAddress;
                model.Commission             = item.Commission.HasValue ? item.Commission.Value : 0;
                model.Handling   = item.Handling.HasValue ? item.Handling.Value : 0;
                model.RebateType = item.RebateType;
                model.RebateRate = item.RebateRate.HasValue ? item.RebateRate.Value : 0;
                model.RebateCustomerDepartmentID           = item.RebateCustomerDepartmentID; //.HasValue ? item.RebateCustomerDepartmentID.Value : Guid.Empty
                model.RebateCustomerCompany_DepartmentName = item.RebateCustomerDepartmentID.HasValue
                    ? _customerDepartmentService.CustomerDepartmentByCustomerDepartmentId(item.RebateCustomerDepartmentID.Value).CustomerDepartmentName
                    : string.Empty;
                model.SalesPersonUserID = item.SalesPersonUserID;
                //model.SalesPersonName = __get_name__(item.SalesPersonUserID); ////////////////////
                model.InvoiceCustomerLocationID    = item.InvoiceCustomerLocationID;
                model.InvoiceCustomerLocation_Name = _customerDepartmentLocationService
                                                     .GetCustomerDepartmentLocationByLocId(item.InvoiceCustomerLocationID)
                                                     .CustomerLocation.CustomerLocationName;
                model.InvoiceFrequency        = item.InvoiceFrequency.ToString();
                model.TransactionTaxReference = item.TransactionTaxReference;
                model.CreditTerms             = item.CreditTerms.HasValue ? item.CreditTerms.Value : 0;
                model.CreditLimit             = item.CreditLimit.HasValue ? item.CreditLimit.Value : 0;
                model.NoteID = item.NoteID;
                model.Notes  = item.NoteID.HasValue ? _noteService.Find(item.NoteID.Value).NoteText : string.Empty;
                // setup LxbViewModel of ListBox
                var customerDepartmentLocations = _customerDepartmentLocationService.GetCustomerDepartmentLocationListByDepId(item.CustomerDepartmentID);
                model.SelectedLocationIds = new List <string>();
                model.LbxLocationOptions  = new List <LbxViewModel>();
                foreach (var cdl in customerDepartmentLocations)
                {
                    model.SelectedLocationIds.Add(cdl.CustomerLocationID.ToString());
                    var lxbItem = new LbxViewModel();
                    lxbItem.Id    = cdl.CustomerLocationID.ToString();
                    lxbItem.label = _customerLocationService.CustomerLocationById(cdl.CustomerLocationID.Value).CustomerLocationName;
                    lxbItem.value = cdl.CustomerLocationID.ToString();
                    model.LbxLocationOptions.Add(lxbItem);
                }
                list.Add(model);
            }
            return(list);
        }