public ActionResult CreateUser(string firstName, string lastName, string emailAddress, DateTime dateofBirth, int carYear, string carMake, string carModel, int dUI, int speedTicket, string coverage)
        {
            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress) || string.IsNullOrEmpty(dateofBirth.ToString()) || string.IsNullOrEmpty(carYear.ToString()) || string.IsNullOrEmpty(carMake) || string.IsNullOrEmpty(carModel) || string.IsNullOrEmpty(dUI.ToString()) || string.IsNullOrEmpty(speedTicket.ToString()) || string.IsNullOrEmpty(coverage))
            {
                return(View("~Views/Shared/Error.cshtml"));
            }
            else
            {
                using (AutoInsuranceEntities2 db = new AutoInsuranceEntities2())
                {
                    var user = new CreateUser();
                    user.FirstName    = firstName;
                    user.LastName     = lastName;
                    user.EmailAddress = emailAddress;
                    user.DateofBirth  = dateofBirth;
                    user.CarYear      = carYear;
                    user.CarMake      = carMake;
                    user.CarModel     = carModel;
                    user.DUI          = dUI;
                    user.SpeedTicket  = speedTicket;
                    user.Coverage     = coverage;
                    user.Quote        = GenerateQuotes(dateofBirth, carYear, carMake, carModel, dUI, speedTicket, coverage);

                    db.CreateUsers.Add(user);
                    db.SaveChanges();
                    ViewBag.Message = "Your quote is " + "$" + user.Quote + ".";
                    return(View("Success"));
                }
            }
        }
Exemple #2
0
 // GET: Admin
 public ActionResult Index()
 {
     using (AutoInsuranceEntities2 db = new AutoInsuranceEntities2())
     {
         var createusers   = db.CreateUsers;
         var createUserVms = new List <CreateUserVm>();
         foreach (var user in createusers)
         {
             var createUserVm = new CreateUserVm();
             createUserVm.Id           = user.Id;
             createUserVm.FirstName    = user.FirstName;
             createUserVm.LastName     = user.LastName;
             createUserVm.EmailAddress = user.EmailAddress;
             createUserVm.Quote        = user.Quote;
             createUserVms.Add(createUserVm);
         }
         return(View(createUserVms));
     }
 }