Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Characteristic,Title,Price,SuitesNumber,Size,Cep,City,District,PhoneNumber,ParkingSpace,Leasing,Sale")] House house)
        {
            if (id != house.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(house);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HouseExists(house.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(house));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(CreateInvoiceViewModel viewModel)
        {
            viewModel.Invoice = new Invoice();

            viewModel.Invoice.Date       = DateTime.Today;
            viewModel.Invoice.EndDate    = DateTime.Today.AddDays(14);
            viewModel.Invoice.Paid       = false;
            viewModel.Invoice.CustomerID = viewModel.SelectedCustomer ?? -1;

            double Total = 0;

            if (ModelState.IsValid)
            {
                _context.Add(viewModel.Invoice);
                await _context.SaveChangesAsync();

                List <ReservationInvoice> newInvoices = new List <ReservationInvoice>();
                foreach (int reservationID in viewModel.SelectedReservations)
                {
                    Reservation reservation = _context.Reservation.Find(reservationID);
                    Total = Total + reservation.Price;
                    newInvoices.Add(new ReservationInvoice
                    {
                        ReservationID = reservationID,
                        InvoiceID     = viewModel.Invoice.InvoiceID
                    });
                }

                viewModel.Invoice.TotalPrice = Total;
                _context.Update(viewModel.Invoice);
                await _context.SaveChangesAsync();

                Invoice invoice = await _context.Invoice.Include(x => x.ReservationInvoices)
                                  .SingleOrDefaultAsync(x => x.InvoiceID == viewModel.Invoice.InvoiceID);

                invoice.ReservationInvoices.AddRange(newInvoices);
                _context.Update(invoice);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //zaken terug opvullen
            return(View(viewModel));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("LocationID,Name,Place,Adress")] Location location)
        {
            if (id != location.LocationID)
            {
                return(View("~/Home/CustomNotFound"));
            }

            if (ModelState.IsValid)
            {
                _context.Update(location);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(location));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("ProfessionID,Description")] Profession profession)
        {
            if (id != profession.ProfessionID)
            {
                return(View("CustomNotFound"));
            }

            if (ModelState.IsValid)
            {
                _context.Update(profession);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(profession));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, EditRoomViewModel viewModel)
        {
            if (id != viewModel.Room.RoomID)
            {
                return(View("CustomNotFound"));
            }

            if (ModelState.IsValid)
            {
                _context.Update(viewModel.Room);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            viewModel.Locations = new SelectList(_context.Location, "LocationID", "NameAndPlace", viewModel.Room.LocationID);
            return(View(viewModel));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, EditReservationViewModel viewModel)
        {
            if (id != viewModel.Reservation.ReservationID)
            {
                return(View("CustomNotFound"));
            }

            if (ModelState.IsValid)
            {
                _context.Update(viewModel.Reservation);
                await _context.SaveChangesAsync();

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

            return(View(viewModel));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Edit(int id, [Bind("CustomerID,Firstname,Lastname,ProfessionID,UserID")] Customer customer)
        {
            if (id != customer.CustomerID)
            {
                return(View("CustomNotFound"));
            }

            if (ModelState.IsValid)
            {
                _context.Update(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserID"]       = new SelectList(_context.Users, "Id", "Id", customer.UserID);
            ViewData["ProfessionID"] = new SelectList(_context.Profession, "ProfessionID", "Description", customer.ProfessionID);
            return(View(customer));
        }