Ejemplo n.º 1
0
 public void RegisterUserTest()
 {
     EFStoreRepository target = new EFStoreRepository(); // TODO: Initialize to an appropriate value
     User user = new User { Email = "*****@*****.**", Password = "******" };
     Customer customer = new Customer { CustomerID ="r1144", CompanyName = "aa", ContactName = "aa", ContactTitle = "aa", Address = "aa", City = "aa", Country = "aa", Fax = "aa", Phone = "aa", PostalCode = "aa", Region = "aa" };
     target.RegisterUserWithCustomer(user, customer);
 }
Ejemplo n.º 2
0
        public ActionResult CompleteRegistration(bool accepted = true)
        {
            //check user registration
            if (Session["UserRegistrationViewModel"] == null)
                return RedirectToAction("UserRegistration", new { app_culture = RouteData.Values["app_culture"] });
            UserRegistrationViewModel userRegistrationModel = (UserRegistrationViewModel)Session["UserRegistrationViewModel"];
            if (!userRegistrationModel.Password.Equals(userRegistrationModel.ConfirmPassword))
                return RedirectToAction("UserRegistration", new { app_culture = RouteData.Values["app_culture"] });
            if (repository.Users.SingleOrDefault(u => u.Email == userRegistrationModel.Email) != null)
                return RedirectToAction("UserRegistration", new { app_culture = RouteData.Values["app_culture"] });

            //check customerMainRegistration
            if (Session["CustomerMainViewModel"] == null)
                return RedirectToAction("CustomerMain", new { app_culture = RouteData.Values["app_culture"] });
            CustomerMainViewModel customerMainModel = (CustomerMainViewModel)Session["CustomerMainViewModel"];
            if (repository.Customers.SingleOrDefault(c => c.CustomerID == customerMainModel.CustomerID) != null)
                return RedirectToAction("CustomerMain", new { app_culture = RouteData.Values["app_culture"] });

            //check customerDetailRegistration
            if (Session["CustomerDetailViewModel"] == null)
                return RedirectToAction("CustomerDetail", new { app_culture = RouteData.Values["app_culture"] });
            CustomerDetailViewModel customerDetailModel = (CustomerDetailViewModel)Session["CustomerDetailViewModel"];

            if (accepted)
            {
                User user = new User { Email = userRegistrationModel.Email, Password = userRegistrationModel.Password };
                Customer customer = new Customer { CustomerID = customerMainModel.CustomerID, CompanyName = customerMainModel.CompanyName, ContactName = customerMainModel.ContactName, ContactTitle = customerMainModel.ContactTitle, Address = customerDetailModel.Address, City = customerDetailModel.City, Country = customerDetailModel.Country, Fax = customerDetailModel.Fax, Phone = customerDetailModel.Phone, PostalCode = customerDetailModel.PostalCode, Region = customerDetailModel.Region };
                user.Customer = customer;
                try
                {
                    repository.RegisterUser(user);
                }
                catch (Exception e)
                {
                    return RedirectToAction("UserRegistration", new { app_culture = RouteData.Values["app_culture"] });
                }
                return RedirectToAction("RegistrationCompleted", new { app_culture = RouteData.Values["app_culture"] });
            }
            else
            {
                return RedirectToAction("UserRegistration", new { app_culture = RouteData.Values["app_culture"] });
            }
        }
Ejemplo n.º 3
0
 public bool CheckCustomerConstraint(Customer customer)
 {
     if (context.Customers.SingleOrDefault(c => c.CustomerID == customer.CustomerID) != null)
         return false;
     else
         return true;
 }