Exemplo n.º 1
0
        public CustomerDepartmentEditModel GetCustomerDepartmentEditModel(Guid id)
        {
            var entity = _customerDepartmentService.CustomerDepartmentById(id);
            var customerCompanyName = _customerService.CustomerById(entity.CustomerID).CustomerCompanyName;
            var model = new CustomerDepartmentEditModel()
            {
                CustomerDepartmentID       = entity.CustomerDepartmentID,
                CustomerDepartmentName     = entity.CustomerDepartmentName,
                RebateCustomerDepartmentID = entity.RebateCustomerDepartmentID,
                RebateRate = entity.RebateRate,
                RebateType = entity.RebateType,
                RebateCustomerCompany_DepartmentName = customerCompanyName + " - " + entity.CustomerDepartmentName
            };

            return(model);
        }
        public List <CustomerContactModel> BuildCustomerContactModels(List <CustomerContact> customerContacts)
        {
            var list = new List <CustomerContactModel>();

            foreach (var item in customerContacts)
            {
                var model = new CustomerContactModel();
                model.CustomerContactID = item.CustomerContactID;
                model.CustomerID        = item.CustomerID;
                model.SortOrder         = item.SortOrder.HasValue ? item.SortOrder.Value : Guid.Empty;
                model.ContactID         = item.ContactID;
                var contact = _contactService.GetContactById(item.ContactID);
                model.EmailAddress     = contact.EmailAddress;
                model.FirstName        = contact.FirstName;
                model.LastName         = contact.LastName;
                model.Title            = contact.Title;
                model.ContactType      = contact.ContactType;
                model.ContactReference = contact.ContactReference;
                model.DDITelephoneNo   = contact.DDITelephoneNo;
                model.MobileNo         = contact.MobileNo;
                model.NoteID           = contact.NoteID;
                model.Notes            = contact.NoteID.HasValue ? _noteService.Find(contact.NoteID.Value).NoteText : string.Empty;
                // setup LxbViewModel of ListBox
                var customerContactLocations = _customerContactLocationService.GetCustomerContactLocationListByConId(item.CustomerContactID);
                model.SelectedLocationIds = new List <string>();
                model.LbxLocationOptions  = new List <LbxViewModel>();
                foreach (var ccl in customerContactLocations)
                {
                    model.SelectedLocationIds.Add(ccl.CustomerLocationID.ToString());
                    var lxbItem = new LbxViewModel();
                    lxbItem.Id    = ccl.CustomerLocationID.ToString();
                    lxbItem.label = _customerLocationService.CustomerLocationById(ccl.CustomerLocationID).CustomerLocationName;
                    lxbItem.value = ccl.CustomerLocationID.ToString();
                    model.LbxLocationOptions.Add(lxbItem);
                }
                var customerContactDepartments = _customerContactDepartmentService.GetCustomerContactDepartmentListByConId(item.CustomerContactID);
                model.SelectedDepartmentIds = new List <string>();
                model.LbxDepartmentOptions  = new List <LbxViewModel>();
                foreach (var ccd in customerContactDepartments)
                {
                    model.SelectedDepartmentIds.Add(ccd.CustomerDepartmentID.ToString());
                    var lxbItem = new LbxViewModel();
                    lxbItem.Id    = ccd.CustomerDepartmentID.ToString();
                    lxbItem.label = _customerDepartmentService.CustomerDepartmentById(ccd.CustomerDepartmentID.Value).CustomerDepartmentName;
                    lxbItem.value = ccd.CustomerDepartmentID.ToString();
                    model.LbxDepartmentOptions.Add(lxbItem);
                }
                list.Add(model);
            }
            return(list);
        }