Example #1
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Car).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarExists(Car.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Example #2
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            var Car = await _context.Car.Where(c => c.Id == CarBookingz.CarId).SingleOrDefaultAsync();

            CarBookingz.TotalPrice  = Car.DailyRate * ((CarBookingz.EndDate - CarBookingz.StartDate).Days + 1);
            CarBookingz.CreatedDate = DateTime.Now.Date;

            _context.Attach(CarBookingz).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarBookingzExists(CarBookingz.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Car.Add(Car);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Example #4
0
        public async Task <ActionResult> OnPostAsync()
        {
            int StatusId = await _context.Status.Where(s => s.Name == SelectedAction).Select(s => s.Id).SingleOrDefaultAsync();

            var CarBoo = await _context.CarBookingz.Where(cb => cb.Id == SelectedId).SingleOrDefaultAsync();

            if (CarBoo == null)
            {
                return(NotFound());
            }
            CarBoo.StatusId = StatusId;
            _context.CarBookingz.Update(CarBoo);
            await _context.SaveChangesAsync();

            return(Redirect("/Bookings/Index"));
        }
Example #5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CarBookingz = await _context.CarBookingz.FindAsync(id);

            if (CarBookingz != null)
            {
                _context.CarBookingz.Remove(CarBookingz);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }