Пример #1
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));
        }
Пример #2
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());
        }
Пример #3
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());
        }
Пример #4
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());
        }
Пример #5
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));
        }
Пример #6
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());
            }
        }