Пример #1
0
        public ActionResult Edit(int id, CustomerViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.FinancialID == null)
                    {
                        int recordsEdited = CustomerProcessor.UpdateCustomer(id, model.FirstName, model.LastName, model.Address,
                                                                             model.City, model.Province, model.PostalCode, model.PhoneNumber, model.Email, model.LeadSource,
                                                                             model.Status, model.Notes);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        int customerEdited = CustomerProcessor.UpdateCustomer(id, model.FirstName, model.LastName, model.Address,
                                                                              model.City, model.Province, model.PostalCode, model.PhoneNumber, model.Email, model.LeadSource,
                                                                              model.Status, model.Notes);

                        int financialEdited = FinancialProcessor.ModifyFinancial(id, model.Quote, model.FinalPrice, model.Commission);
                        return(RedirectToAction("Index"));
                    }
                }
                catch
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Пример #2
0
        public async Task <ActionResult> Register(CustomerModel model)
        {
            model.cID                = 69;
            model.BidLimit           = 50000;
            model.VarificationStatus = "NEW";
            model.cRating            = 0.0;

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.cEmail, Email = model.cEmail
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    int recordCreated = CustomerProcessor.CreateCustomer(model.cName, model.cNumber, model.cAddress, model.cEmail, model.cNID, model.cRating, model.BidLimit, model.VarificationStatus);
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #3
0
        public ActionResult CreateCustomer(CustomerModel model, int[] selectedOrders)
        {
            if (ModelState.IsValid)
            {
                if (selectedOrders != null)
                {
                    foreach (var order in OrderProcessor.LoadOrders().Where(ord => selectedOrders.Contains(ord.Id)))
                    {
                        model.Orders.Add(new OrderModel
                        {
                            OrderID = order.OrderId,
                            Date    = order.Date
                        });
                    }
                }
                int recordsCreated = CustomerProcessor.CreateCustomer
                                     (
                    model.CustomerID,
                    model.Name,
                    model.PhoneNumber,
                    model.Email
                                     );

                foreach (var item in model.Orders)
                {
                    CustomersOrdersProcessor.CreateCustomersOrders
                    (
                        model.CustomerID,
                        item.OrderID
                    );
                }
                return(RedirectToAction("ViewCustomers"));
            }
            return(View());
        }
Пример #4
0
        // READ: get details for a customer
        public ActionResult Details(int id) // the int ID is coming from the path of the controller
        {
            // pull in one customer into a CustomerModel object (based on data access model)
            var data = CustomerProcessor.LoadMultiMap(id);

            // create a new object of CustomerModel type (based on the UI model)
            CustomerViewModel customerDetails;

            customerDetails = new CustomerViewModel
            {
                CustomerID  = data.CustomerID,
                FirstName   = data.FirstName,
                LastName    = data.LastName,
                Address     = data.Address,
                City        = data.City,
                Province    = data.Province,
                PostalCode  = data.PostalCode,
                PhoneNumber = data.PhoneNumber,
                Email       = data.Email,
                LeadSource  = data.LeadSource,
                Status      = data.Status,
                Notes       = data.Notes,
                FinancialID = data.FinancialData.FinancialID,
                Quote       = data.FinancialData.Quote,
                FinalPrice  = data.FinancialData.FinalPrice,
                Commission  = data.FinancialData.Commission
            };

            return(View(customerDetails));
        }
Пример #5
0
        public ActionResult ViewCustomersDetails(int id = 0)
        {
            //Получаем покупателя с идентификатором равным id
            var data = CustomerProcessor.LoadCustomers().Where(c => c.CustomerId == id).FirstOrDefault();

            if (data == null)
            {
                return(RedirectToAction("ViewCustomers"));
            }

            //Получаем из списка заказов все заказы данного покупателя
            var dataOrdersCustomers = CustomersOrdersProcessor.LoadCustomersOrders().Where(co => co.CustomerId == data.CustomerId) as List <DALCustomersOrdersModel>;

            //Теперь нужно найти по идентификаторам заказов сами заказы
            //OrderId - уникальные
            var DALorders = new List <DALOrdersModel>();
            var orders    = new List <OrderModel>();

            CustomerModel customer;

            if (dataOrdersCustomers != null)
            {
                foreach (var item in dataOrdersCustomers)
                {
                    DALorders.Add(OrderProcessor.LoadOrders().Where(oid => oid.OrderId == item.OrderId).FirstOrDefault());
                }


                foreach (var dalOrder in DALorders)
                {
                    orders.Add(new OrderModel
                    {
                        OrderID = dalOrder.OrderId,
                        Date    = dalOrder.Date
                    });
                }

                customer = new CustomerModel
                {
                    CustomerID  = data.CustomerId,
                    Name        = data.FullName,
                    PhoneNumber = data.PhoneNumber,
                    Email       = data.EmailAddress,
                    Orders      = orders
                };
            }
            else
            {
                customer = new CustomerModel
                {
                    CustomerID  = data.CustomerId,
                    Name        = data.FullName,
                    PhoneNumber = data.PhoneNumber,
                    Email       = data.EmailAddress,
                };
            }


            return(View(customer));
        }
Пример #6
0
        public void MakeBid(int P, int B)
        {
            string userID = User.Identity.GetUserId();
            List <CustomerModelDB> customer = CustomerProcessor.getCustomersViaNetID(userID);

            AuctionProccessor.makebid(Convert.ToInt32(Session["AUCTION_ID"]), P, B, customer[0].cID);
        }
Пример #7
0
        // READ: Customer/Edit/5
        public ActionResult Edit(int id)
        {
            // pull in all customers into a CustomerModel list (based on data access model)
            var data = CustomerProcessor.LoadMultiMap(id);

            // create a new list of CustomerModel type (based on the UI model)
            CustomerViewModel customerEdit;

            customerEdit = new CustomerViewModel
            {
                CustomerID  = data.CustomerID,
                FirstName   = data.FirstName,
                LastName    = data.LastName,
                Address     = data.Address,
                City        = data.City,
                Province    = data.Province,
                PostalCode  = data.PostalCode,
                PhoneNumber = data.PhoneNumber,
                Email       = data.Email,
                LeadSource  = data.LeadSource,
                Status      = data.Status,
                Notes       = data.Notes,
                FinancialID = data.FinancialData.FinancialID,
                Quote       = data.FinancialData.Quote,
                FinalPrice  = data.FinancialData.FinalPrice,
                Commission  = data.FinancialData.Commission
            };

            return(View(customerEdit));
        }
Пример #8
0
 public CustomerPuller(CustomerPullerOptionManager optionManager,
                       CustomerProcessor processor,
                       FastProvider provider,
                       FastAdapter adapter,
                       EntityRepository entityRepository,
                       ConnectionRepository connectionRepository) : base(optionManager, processor, provider, adapter, entityRepository, connectionRepository)
 {
 }
Пример #9
0
        /// <summary>
        /// 批量设置顾客头像状态
        /// </summary>
        public virtual void BatchUpdateAvatarStatus(List <int> CustomerSysNoList, AvtarShowStatus AvtarImageStatus)
        {
            CustomerProcessor processor = ObjectFactory <CustomerProcessor> .Instance;

            foreach (int sysNo in CustomerSysNoList)
            {
                processor.UpdateAvatarStatus(sysNo, AvtarImageStatus);
            }
        }
Пример #10
0
        public void ProcessOrder(OrderInfo orderInfo)
        {
            BillingProcessor  billingProcessor  = new BillingProcessor();
            CustomerProcessor customerProcessor = new CustomerProcessor();
            Notifier          notifier          = new Notifier();

            billingProcessor.ProcessPayment(orderInfo.CustomerName, orderInfo.CreditCard, orderInfo.CustomerEmail);
            customerProcessor.UpdateCustomerOrder(orderInfo.CustomerName, orderInfo.Product);
            notifier.SendReceipt(orderInfo);
        }
        private void btnGo_Click(object sender, EventArgs e)
        {
            IFileHandler fileHandler       = new FileHandler();
            ICalculator  paymentCalculator = new PaymentCalculator();

            CustomerProcessor customerProcessor = new CustomerProcessor(fileHandler, paymentCalculator);

            CustomerFacade cf = new CustomerFacade(customerProcessor);

            cf.Process(sourceFile, targetFolder);

            MessageBox.Show("Processing completed.", "Policy Renewals", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #12
0
        public void TestCustomerProcessorUpdate()
        {
            Mock <ICustomerRepository> mockCustomerRepository = new Mock <ICustomerRepository>();
            Mock <IProductRepository>  mockProductRepository  = new Mock <IProductRepository>();

            mockCustomerRepository.Setup(obj => obj.Save()).Callback(() => Console.WriteLine("Mock save in Customer Repository called."));
            mockProductRepository.Setup(obj => obj.Save()).Callback(() => Console.WriteLine("Mock save in Product Repository called."));

            ICustomerProcessor customerProcessor = new CustomerProcessor(mockCustomerRepository.Object, mockProductRepository.Object);

            customerProcessor.UpdateCustomerOrder("CUST101", "PROD400");

            Assert.IsTrue(1 == 1);
        }
Пример #13
0
 public ActionResult Login(int Id, String Password)
 {
     if (ModelState.IsValid)
     {
         CustomerModel customer = CustomerProcessor.LoginCustomer(Id, Password);
         if (customer == null)
         {
             ViewData["idLogin"] = "******";
             return(View());
         }
         ViewData["idLogin"] = null;
         return(Redirect("~/Shop/CustomerHomeShop?id=" + customer.Id + "&FirstName=" + customer.FirstName.Trim() + "&LastName=" + customer.LastName.Trim() +
                         "&Email=" + customer.Email + "&Password=" + customer.Password));
     }
     return(View());
 }
Пример #14
0
        public ActionResult SignUp(CustomerModel model)
        {
            model.cID                = 69;
            model.BidLimit           = 50000;
            model.VarificationStatus = "NEW";
            model.cRating            = 0.0;

            if (ModelState.IsValid)
            {
                int recordCreated = CustomerProcessor.CreateCustomer(model.cName, model.cNumber, model.cAddress, model.cEmail, model.cNID, model.cRating, model.BidLimit, model.VarificationStatus);

                return(RedirectToAction("Index"));
            }

            return(View());
        }
Пример #15
0
        public ActionResult SignUp(Customer cust)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    int recodSCreated = CustomerProcessor.CreateCustomer(cust.Id, cust.FirstName, cust.LastName, cust.Email, cust.Password);
                    ViewData["id"] = null;
                    return(RedirectToAction("Login"));
                }
                catch (Exception e)
                {
                    ViewData["id"] = "Id is uniqe and used";
                }
            }

            return(View(cust));
        }
Пример #16
0
        public ActionResult SignUp(Customer customer)
        {
            if (ModelState.IsValid)
            {
                int recordsCreated = CustomerProcessor.CreateCustomer(
                    customer.FirstName,
                    customer.LastName,
                    customer.Occupation,
                    customer.City,
                    customer.State,
                    customer.Email,
                    customer.ImageURL);

                return(RedirectToAction("CustomerList"));
            }

            return(View());
        }
Пример #17
0
        public ActionResult Filter(string status) // ajax options
        {
            var data = CustomerProcessor.LoadCustomers();
            List <CustomerViewModel> customers = new List <CustomerViewModel>();

            foreach (var row in data)
            {
                customers.Add(new CustomerViewModel
                {
                    CustomerID  = row.CustomerID,
                    FirstName   = row.FirstName,
                    LastName    = row.LastName,
                    Address     = row.Address,
                    City        = row.City,
                    Province    = row.Province,
                    PostalCode  = row.PostalCode,
                    PhoneNumber = row.PhoneNumber,
                    Email       = row.Email,
                    LeadSource  = row.LeadSource,
                    Status      = row.Status,
                    Notes       = row.Notes,
                });
            }

            // Process the status list and assign to Viewbag
            List <string> statusList = new List <String>();

            foreach (var row in customers)
            {
                if (row.Status != null)
                {
                    statusList.Add(row.Status.ToString());
                }
            }

            ViewBag.status = new SelectList(statusList);

            if (!String.IsNullOrEmpty(status))
            {
                customers = customers.Where(s => s.Status == status).ToList();
            }

            return(PartialView("_Customers", customers));
        }
Пример #18
0
        // READ: list the customers
        public ActionResult Index(string status)
        {
            // 1. Get the data and put it into a list
            var data = CustomerProcessor.LoadCustomers();                        // load all customers into var
            List <CustomerViewModel> customers = new List <CustomerViewModel>(); // create CustomerViewModel type list

            foreach (var row in data)                                            // pass the data model list to the view model list.
            {
                customers.Add(new CustomerViewModel
                {
                    CustomerID  = row.CustomerID,
                    FirstName   = row.FirstName,
                    LastName    = row.LastName,
                    Address     = row.Address,
                    City        = row.City,
                    Province    = row.Province,
                    PostalCode  = row.PostalCode,
                    PhoneNumber = row.PhoneNumber,
                    Email       = row.Email,
                    LeadSource  = row.LeadSource,
                    Status      = row.Status,
                    Notes       = row.Notes,
                });
            }

            // 2. Create the status filter list and send to View Bag
            List <string> statusList = new List <String>();

            foreach (var row in customers)
            {
                if (row.Status != null)
                {
                    statusList.Add(row.Status.ToString());
                }
            }

            var filteredStatusList = statusList.Distinct();

            ViewBag.status = new SelectList(filteredStatusList);

            return(View(status));
        }
Пример #19
0
        public ActionResult ViewCustomers()
        {
            ViewBag.Message = "The List of Cutomers";

            var data = CustomerProcessor.LoadCustomers();
            List <CustomerModel> customers = new List <CustomerModel>();

            foreach (var row in data)
            {
                customers.Add(new CustomerModel
                {
                    CustomerID  = row.CustomerId,
                    Name        = row.FullName,
                    PhoneNumber = row.PhoneNumber,
                    Email       = row.EmailAddress
                });
            }

            return(View(customers));
        }
Пример #20
0
        public ActionResult ViewCustomers()
        {
            ViewBag.Message = "View Customer page.";

            var data = CustomerProcessor.LoadCustomers();
            List <CustomerModel> customers = new List <CustomerModel>();

            foreach (var row in data)
            {
                customers.Add(new CustomerModel
                {
                    CustomerID = row.CustomerID,
                    FName      = row.FName,
                    LName      = row.LName,
                    Address    = row.Address,
                    Phone      = row.Phone,
                    StartDate  = row.StartDate
                });
            }

            return(View(customers));
        }
Пример #21
0
        [ValidateAntiForgeryToken] // we check this on both the front and back-end
        public ActionResult Create(CustomerViewModel customerModel)
        {
            if (ModelState.IsValid) // if valid, post, then return to the customer list
            {
                try
                {
                    int recordsCreated = CustomerProcessor.CreateCustomer(customerModel.FirstName, customerModel.LastName, customerModel.Address,
                                                                          customerModel.City, customerModel.Province, customerModel.PostalCode, customerModel.PhoneNumber, customerModel.Email, customerModel.LeadSource,
                                                                          customerModel.Status, customerModel.Notes);

                    return(RedirectToAction("Index"));
                }
                catch
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Пример #22
0
        public JsonResult GetCustomers()
        {
            ViewBag.Message = "Customer List";

            var             result   = CustomerProcessor.LoadCustomers();
            List <Customer> customer = new List <Customer>();

            foreach (var row in result)
            {
                customer.Add(new Customer
                {
                    FirstName  = row.FirstName,
                    LastName   = row.LastName,
                    Occupation = row.Occupation,
                    City       = row.City,
                    State      = row.State,
                    Email      = row.Email,
                    ImageURL   = row.ImageURL
                });
            }

            return(Json(customer, JsonRequestBehavior.AllowGet));
        }
Пример #23
0
        //GET: Customer/Delete/5
        public ActionResult Delete(int?id)
        {
            ViewBag.Message = "Delete a Customer";

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var data = CustomerProcessor.LoadSingleCustomer(id);

            CustomerViewModel customerDelete;

            customerDelete = new CustomerViewModel
            {
                CustomerID  = data.CustomerID,
                FirstName   = data.FirstName,
                LastName    = data.LastName,
                Address     = data.Address,
                City        = data.City,
                Province    = data.Province,
                PostalCode  = data.PostalCode,
                PhoneNumber = data.PhoneNumber,
                Email       = data.Email,
                LeadSource  = data.LeadSource,
                Status      = data.Status,
                Notes       = data.Notes
            };

            if (customerDelete == null)
            {
                return(HttpNotFound());
            }

            return(View(customerDelete));
        }
Пример #24
0
        public ActionResult Quote()
        {
            // pull in all customers into a CustomerModel list (based on data access model)
            var data = CustomerProcessor.MultipleMultiMap();

            // create a new list of CustomerModel type (based on the UI model)
            List <CustomerViewModel> customers = new List <CustomerViewModel>();

            foreach (var row in data) // take the data access model and map it to the UI model.
            {
                customers.Add(new CustomerViewModel
                {
                    CustomerID  = row.CustomerID,
                    FirstName   = row.FirstName,
                    LastName    = row.LastName,
                    Address     = row.Address,
                    City        = row.City,
                    Province    = row.Province,
                    PostalCode  = row.PostalCode,
                    PhoneNumber = row.PhoneNumber,
                    Email       = row.Email,
                    LeadSource  = row.LeadSource,
                    Status      = row.Status,
                    Notes       = row.Notes,
                    Quote       = row.FinancialData.Quote,
                    FinalPrice  = row.FinancialData.FinalPrice,
                    Commission  = row.FinancialData.Commission
                });
            }

            decimal?total = customers.QuoteTotal();

            ViewBag.Quote = total;

            return(View());
        }
Пример #25
0
 public CustomerPuller(CustomerPullerOptionManager optionManager,
                       CustomerProcessor processor,
                       FastAdapter adapter) : base(optionManager, processor, adapter)
 {
 }
Пример #26
0
 public CustomerIndexer(
     CustomerProcessor processor,
     CustomerIndexerOptionManager optionManager,
     FastAdapter adapter) : base(processor, optionManager, adapter)
 {
 }
Пример #27
0
        public ActionResult GetCustomerData(string status)
        {
            // 1. Get the data and put it into a list
            var data = CustomerProcessor.LoadCustomers();                        // load all customers into var
            List <CustomerViewModel> customers = new List <CustomerViewModel>(); // create CustomerViewModel type list

            foreach (var row in data)                                            // pass the data model list to the view model list.
            {
                customers.Add(new CustomerViewModel
                {
                    CustomerID  = row.CustomerID,
                    FirstName   = row.FirstName,
                    LastName    = row.LastName,
                    Address     = row.Address,
                    City        = row.City,
                    Province    = row.Province,
                    PostalCode  = row.PostalCode,
                    PhoneNumber = row.PhoneNumber,
                    Email       = row.Email,
                    LeadSource  = row.LeadSource,
                    Status      = row.Status,
                    Notes       = row.Notes,
                });
            }

            // 2. Create the status filter list and send to View Bag
            List <string> statusList = new List <String>();

            foreach (var row in customers)
            {
                if (row.Status != null)
                {
                    statusList.Add(row.Status.ToString());
                }
            }

            var filteredStatusList = statusList.Distinct();

            ViewBag.status = new SelectList(filteredStatusList);

            // 3. Filter the list if needed
            if (!String.IsNullOrEmpty(status))
            {
                customers = customers.Where(s => s.Status == status).ToList();
            }

            // 4a. If this is an AJAX request, format the data, and return a JSON result object (for processing with JavaScript)
            if (Request.IsAjaxRequest())
            {
                var formattedData = customers.Select(c => new
                {
                    CustomerID  = c.CustomerID,
                    FirstName   = c.FirstName,
                    LastName    = c.LastName,
                    Address     = c.Address,
                    City        = c.City,
                    Province    = c.Province,
                    PostalCode  = c.PostalCode,
                    PhoneNumber = c.PhoneNumber,
                    Email       = c.Email,
                    LeadSource  = c.LeadSource,
                    Status      = c.Status,
                    Notes       = c.Notes
                });
                return(Json(formattedData, JsonRequestBehavior.AllowGet));
            }
            // 4b. If no filtering is needed, return full customer list.
            {
                return(PartialView(customers));
            }
        }
Пример #28
0
        public ActionResult Delete(int id)
        {
            int recordsCreated = CustomerProcessor.DeleteCustomer(id);

            return(RedirectToAction("Index"));
        }