Пример #1
0
        // GET: Bookings/Selected/5
        public async Task <IActionResult> Select(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var bookingLog = await dataContext.BookingLog
                             .Include(b => b.Customer)
                             .Include(b => b.Staff)
                             .Include(b => b.ActivityType)
                             .FirstOrDefaultAsync(m => m.BookingLogId == id);

            if (bookingLog == null)
            {
                return(NotFound());
            }

            //Get currently logged in user
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }
            int?customerID = GetCustomer(user.Id);

            bookingLog.CustomerId = customerID;
            //startdate

            await dataContext.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Create([Bind("StaffId,FirstName,LastName,EmailAddress,Street,MobilePhone")] Staff staff)
        {
            if (ModelState.IsValid)
            {
                dataContext.Add(staff);
                await dataContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(staff));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("PostalDistrictId,City,Zipcode")] PostalDistrict postalDistrict)
        {
            if (ModelState.IsValid)
            {
                _context.Add(postalDistrict);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(postalDistrict));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("VehicleId,VehicleModel,RegistrationDtl")] Vehicle vehicle)
        {
            if (ModelState.IsValid)
            {
                dataContext.Add(vehicle);
                await dataContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicle));
        }
Пример #5
0
        public async Task <IActionResult> Create([Bind("CustomerId,FirstName,LastName,EmailAddress,Street,DateBirth,MobilePhone,PostalDistrictId")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                dataContext.Add(customer);
                await dataContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PostalDistrictId"] = new SelectList(dataContext.PostalDistrict, "PostalDistrictId", "Zipcode");
            return(View(customer));
        }
Пример #6
0
        public async Task <IActionResult> Create([Bind("EvaluationId,Resulte,Title,Description,BookingLogId")] Evaluation evaluation)
        {
            if (ModelState.IsValid)
            {
                dataContext.Add(evaluation);
                await dataContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookingLogId"] = new SelectList(dataContext.BookingLog, "BookingLogId", "CustomerId", evaluation.BookingLogId);
            return(View(evaluation));
        }
        public async Task <IActionResult> Create([Bind("ActivityTypeId,Price,Title,StartDate,EndDate,BookingLogId,VehicleId")] ActivityType activityType)
        {
            if (ModelState.IsValid)
            {
                dataContext.Add(activityType);
                await dataContext.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //   ViewData["BookingLogId"] = new SelectList(dataContext.BookingLog, "BookingLogId", "BookingLogId", activityType.BookingLogId);
            ViewData["VehicleId"] = new SelectList(dataContext.Vehicle, "VehicleId", "VehicleModel", activityType.VehicleId);
            return(View(activityType));
        }
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");
            if (ModelState.IsValid)
            {
                var user = new IdentityUser {
                    UserName = Input.Email, Email = Input.Email
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    Models.Customer newCustomer = new Models.Customer()
                    {
                        AspNetUserId = user.Id,
                        EmailAddress = user.Email,
                        FirstName    = Input.FirstName,
                        LastName     = Input.LastName,
                        DateBirth    = Input.DateBirth,
                        Street       = Input.Street,
                        MobilePhone  = Input.MobilePhone
                    };

                    _smartDrivingContext.Customer.Add(newCustomer);
                    await _smartDrivingContext.SaveChangesAsync();

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { userId = user.Id, code = code },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(LocalRedirect(returnUrl));
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }