예제 #1
0
        public ActionResult Create([Bind(Include = "EmployeeId,Firstname,LastName,Email")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "DriversId,Firstname,LastName,TimeIn,In,Out,TimeOut")] Driver driver)
        {
            if (ModelState.IsValid)
            {
                db.Drivers.Add(driver);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(driver));
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "TicketNumber,FirstName,LastName,Make,Model,Color,LicensePlate,ParkedLocation,ParkedBy,exp")] OwnersInformation ownersInformation)
        {
            if (ModelState.IsValid)
            {
                ownersInformation.Arrival = DateTime.Now;
                db.OwnersInformations.Add(ownersInformation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ParkedBy = new SelectList(db.Drivers, "DriversId", "Firstname", ownersInformation.ParkedBy);
            return(View(ownersInformation));
        }
        public ActionResult Create(Activity monitor)
        {
            if (ModelState.IsValid)
            {
                var ticketnum     = db.OwnersInformations.Find(monitor.TicketNumber);
                var missingticket = false;
                if (ticketnum == null)
                {
                    ModelState.AddModelError("TicketNumber", "THIS TICKET # DOESN'T EXIST..");
                    missingticket = true;
                }
                if (!missingticket)
                {
                    monitor.TimeRequested = DateTime.Now;
                    db.Activities.Add(monitor);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.TicketNumber = new SelectList(db.OwnersInformations, "TicketNumber", "FirstName", monitor.TicketNumber);
            return(View(monitor));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Username, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    var employeeuser = new User
                    {
                        Email      = model.Email,
                        Username   = model.Username,
                        EmployeeId = user.Id
                    };
                    using (var db = new ValetLogEntities1())
                    {
                        db.Users.Add(employeeuser);
                        db.SaveChanges();
                    }
                    //string emailsubject = "Thank You for registering for FUAT!L!A";
                    //String body = $"Hey you have succefull registerred with bgvf gvbhbh{model.Username}";
                    //MessageSender.SendEmail(model.Email, emailsubject, body);

                    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));
        }