Ejemplo n.º 1
0
        public List <CustomerDepartmentViewModel> GetAllCustomerDepartments()
        {
            List <CustomerDepartment> listOfAll = _customerDepartmentService.GetAllCustomerDepartments();
            var cdvmList = new List <CustomerDepartmentViewModel>();

            foreach (var entity in listOfAll)
            {
                var customerCompanyName = _customerService.CustomerById(entity.CustomerID).CustomerCompanyName;
                var model = new CustomerDepartmentViewModel()
                {
                    CustomerDepartmentID       = entity.CustomerDepartmentID,
                    CustomerDepartmentName     = entity.CustomerDepartmentName,
                    RebateCustomerDepartmentID = entity.RebateCustomerDepartmentID,
                    RebateRate = entity.RebateRate,
                    RebateType = entity.RebateType,
                    CustomerDepartmentEditModels = entity.Customer.CustomerDepartments
                                                   .Select(cd => new CustomerDepartmentEditModel()
                    {
                        CustomerDepartmentID   = cd.CustomerDepartmentID,
                        CustomerDepartmentName = cd.CustomerDepartmentName,
                        RebateCustomerCompany_DepartmentName = customerCompanyName
                                                               + " - " + cd.CustomerDepartmentName
                    }).ToList()
                };
                cdvmList.Add(model);
            }
            return(cdvmList);
        }
Ejemplo n.º 2
0
        // GET: Customers/Create
        public IActionResult Create()
        {
            var viewModel = new CustomerDepartmentViewModel {
                Departments = _context.Department.ToList()
            };

            return(View(viewModel));
        }
Ejemplo n.º 3
0
        public CustomerDepartmentViewModel UpdateRebate(CustomerDepartmentViewModel model)
        {
            var entity = _customerDepartmentService.CustomerDepartmentById(model.CustomerDepartmentID);

            entity.RebateType = (byte)model.RebateType;
            entity.RebateRate = model.RebateRate;
            entity.RebateCustomerDepartmentID = model.RebateCustomerDepartmentID;
            entity.UpdatedDate = DateTime.Now;
            entity.UpdatedBy   = _principal.Id;
            _customerDepartmentService.Update(entity);
            return(model);
        }
Ejemplo n.º 4
0
        public CustomerDepartmentViewModel GetCustomerDepartment(Guid id)
        {
            var entity = _customerDepartmentService.CustomerDepartmentById(id);
            var customerCompanyName = _customerService.CustomerById(entity.CustomerID).CustomerCompanyName;
            var model = new CustomerDepartmentViewModel()
            {
                CustomerDepartmentID       = entity.CustomerDepartmentID,
                CustomerDepartmentName     = entity.CustomerDepartmentName,
                RebateCustomerDepartmentID = entity.RebateCustomerDepartmentID,
                RebateRate = entity.RebateRate,
                RebateType = entity.RebateType,
                CustomerDepartmentEditModels = entity.Customer.CustomerDepartments.Select(cd => new CustomerDepartmentEditModel()
                {
                    CustomerDepartmentID   = cd.CustomerDepartmentID,
                    CustomerDepartmentName = cd.CustomerDepartmentName,
                    RebateCustomerCompany_DepartmentName = customerCompanyName
                                                           + " - " + cd.CustomerDepartmentName
                }).ToList()
            };

            return(model);
        }
Ejemplo n.º 5
0
        // GET: Customers/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var customer = await _context.Customer.FindAsync(id);

            if (customer == null)
            {
                return(NotFound());
            }

            var viewModel = new CustomerDepartmentViewModel {
                Customer = customer, Departments = _context.Department.ToList()
            };

            //ViewData["DepartmentId"] = new SelectList(_context.Department, "Id", "Id", customer.DepartmentId);

            return(View(viewModel));
        }