Beispiel #1
0
        public ActionResult Customers(string salespersonId)
        {
            var model = new SalespersonViewModel();

            var salesperson = _salespersonDynamicsRepository.GetSalesperson(salespersonId);

            var customers = new List <CustomerViewModel>();

            var tempCustomers = _customerDynamicsRepository.GetCustomers().Where(x => x.SLPRSNID.Replace(" ", string.Empty).ToLower() == salespersonId.Replace(" ", string.Empty).ToLower()).OrderBy(y => y.SHRTNAME).ToList();

            if (tempCustomers != null && tempCustomers.Count > 0)
            {
                foreach (var tempCustomer in tempCustomers)
                {
                    CustomerViewModel convertedModel = new CustomerConverter().ConvertToListView(tempCustomer);

                    customers.Add(convertedModel);
                }
            }

            model.Customers       = customers;
            model.SalespersonName = salesperson.SLPRSNFN + " " + salesperson.SPRSNSLN;

            return(View(model));
        }
Beispiel #2
0
        /// <summary>
        /// convert salesperson to view model
        /// </summary>
        /// <param name="salesperson"></param>
        /// <returns></returns>
        public SalespersonViewModel ConvertToView(RM00301_Salesperson salesperson)
        {
            SalespersonViewModel model = new SalespersonViewModel();

            model.SalespersonId             = salesperson.SLPRSNID;
            model.SalespersonName           = (!string.IsNullOrEmpty(salesperson.SLPRSNFN.Replace(" ", string.Empty)) && !string.IsNullOrEmpty(salesperson.SPRSNSLN.Replace(" ", string.Empty))) ? salesperson.SLPRSNFN + " " + salesperson.SPRSNSLN : "N/A";
            model.Phone1                    = FormattingManager.FormatPhone(salesperson.PHONE1);
            model.FaxNumber                 = FormattingManager.FormatPhone(salesperson.FAX);
            model.SalesTerritoryDescription = salesperson.SALSTERR;
            model.IsActive                  = salesperson.INACTIVE != 1 ? true : false;

            return(model);
        }
Beispiel #3
0
        public ActionResult Index()
        {
            var model = new SalespersonViewModel();

            var salespersons = new List <SalespersonViewModel>();

            var tempSalespersons = _salespersonDynamicsRepository.GetSalespersons().Where(x => x.INACTIVE != 1).ToList();

            if (tempSalespersons != null && tempSalespersons.Count > 0)
            {
                foreach (var tempSalesperson in tempSalespersons)
                {
                    SalespersonViewModel convertedModel = new SalespersonConverter().ConvertToView(tempSalesperson);

                    salespersons.Add(convertedModel);
                }
            }

            model.Salespersons = salespersons.OrderBy(x => x.SalespersonName).ToList();

            return(View(model));
        }
Beispiel #4
0
        public JsonResult GetInactiveSalespersons()
        {
            var model = new SalespersonViewModel();

            var salespersons = new List <SalespersonViewModel>();

            var tempSalespersons = _salespersonDynamicsRepository.GetSalespersons().Where(x => x.INACTIVE != 0).ToList();

            if (tempSalespersons != null && tempSalespersons.Count > 0)
            {
                foreach (var tempSalesperson in tempSalespersons)
                {
                    SalespersonViewModel convertedModel = new SalespersonConverter().ConvertToView(tempSalesperson);

                    salespersons.Add(convertedModel);
                }
            }

            model.Salespersons = salespersons.OrderBy(x => x.SalespersonName).ToList();

            return(Json(model, JsonRequestBehavior.AllowGet));
        }