Beispiel #1
0
        public IActionResult Create(int Id)
        {
            if (SignInManager.IsSignedIn(User))
            {
                var vehicleOwner = (from owner in _context.VehicleOwner
                                    where owner.Email.Equals(User.Identity.Name)
                                    select owner).FirstOrDefault();

                //Create a New service Booking record
                ServiceBookingRecord record = new ServiceBookingRecord();

                record.ServiceId      = Id;
                record.VehicleOwnerId = vehicleOwner.Id;

                _context.Add(record);
                _context.SaveChanges();

                var createdServiceBooking = _context.ServiceBookingRecord.
                                            Include(sr => sr.VehicleOwner)
                                            .Include(sr => sr.Service)
                                            .Where(sr => sr.Id == record.Id).FirstOrDefault();
                return(View(createdServiceBooking));
            }


            return(View());
        }
        public async Task <IActionResult> Create([Bind("Id,Name,ContactNumber,Email")] VehicleOwner vehicleOwner)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vehicleOwner);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicleOwner));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("Id,ServiceName,ServiceCharge,Description")] Service service)
        {
            if (ModelState.IsValid)
            {
                _context.Add(service);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(service));
        }