Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,NumOfRooms,NumOfPersons,Description,Parking,Wifi,Accessibility,AirConditioning,Balcony,Comment")] ApartmentAmenities apartmentAmenities)
        {
            if (id != apartmentAmenities.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(apartmentAmenities);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ApartmentAmenitiesExists(apartmentAmenities.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                var apartmentId = _context.Apartment.Include(l => l.Amenities).Where(a => a.Amenities.Id == id).Select(i => i.Id).FirstOrDefault();

                return(RedirectToAction("EditControl", "Apartments", new { id = apartmentId }));
            }
            return(View(apartmentAmenities));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Address,City,x,y")] Location location)
        {
            if (id != location.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(location);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocationExists(location.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                var apartmentId = _context.Apartment.Include(l => l.Location).Where(a => a.Location.Id == id).Select(i => i.Id).FirstOrDefault();

                return(RedirectToAction("EditControl", "Apartments", new { id = apartmentId }));
            }
            return(View(location));
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ApartmentId,QuantityAdult,QuantityChild,CheckIn,CheckOut")] Order order)
        {
            if (id != order.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(order));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("OrderPaymentId,CC_Number,CC_Exp,CC_CVV")] OrderPayment orderPayment)
        {
            if (id != orderPayment.OrderPaymentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderPayment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderPaymentExists(orderPayment.OrderPaymentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(orderPayment));
        }
Example #5
0
        public async Task <IActionResult> Edit(int id, [Bind("ApartmentId,AvailabilityId")] ApartmentAvailability apartmentAvailability)
        {
            if (id != apartmentAvailability.AvailabilityId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(apartmentAvailability);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ApartmentAvailabilityExists(apartmentAvailability.AvailabilityId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApartmentId"]    = new SelectList(_context.Apartment, "Id", "Id", apartmentAvailability.ApartmentId);
            ViewData["AvailabilityId"] = new SelectList(_context.Availability, "Id", "Id", apartmentAvailability.AvailabilityId);
            return(View(apartmentAvailability));
        }
Example #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,NotAvailable")] Availability availability)
        {
            if (id != availability.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(availability);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AvailabilityExists(availability.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(availability));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,PriceAdult,PriceChild,Amenties,Policy,Location,Image,ApartmentAvailabilities")] Apartment apartment)
        {
            if (id != apartment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(apartment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ApartmentExists(apartment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(apartment));
        }
Example #8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,password,FirstName,LastName,Phone,Mail,Username")] User user)
        {
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Example #9
0
        public async Task <IActionResult> Edit(int id, IFormFile file1, IFormFile file2, IFormFile file3, IFormFile file4, Image image)
        {
            if (id != image.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    string path_Root = _appEnvironment.WebRootPath;

                    if (file1 != null && file1.Length != 0)
                    {
                        string path_to_Images1 = path_Root + "\\User_Files\\Images\\" + file1.FileName;
                        using (var stream = new FileStream(path_to_Images1, FileMode.Create))
                        {
                            await file1.CopyToAsync(stream);
                        }
                        image.BedRoom = "/User_Files/Images/" + Path.GetFileName(file1.FileName);
                    }
                    else
                    {
                        image.BedRoom = _context.Image.Where(i => i.Id == id).Select(i => i.BedRoom).FirstOrDefault();
                    }
                    if (file2 != null && file2.Length != 0)
                    {
                        string path_to_Images2 = path_Root + "\\User_Files\\Images\\" + file2.FileName;
                        using (var stream = new FileStream(path_to_Images2, FileMode.Create))
                        {
                            await file2.CopyToAsync(stream);
                        }
                        image.DiningRoom = "/User_Files/Images/" + Path.GetFileName(file2.FileName);
                    }
                    else
                    {
                        image.DiningRoom = _context.Image.Where(i => i.Id == id).Select(i => i.DiningRoom).FirstOrDefault();
                    }
                    if (file3 != null && file3.Length != 0)
                    {
                        string path_to_Images3 = path_Root + "\\User_Files\\Images\\" + file3.FileName;
                        using (var stream = new FileStream(path_to_Images3, FileMode.Create))
                        {
                            await file3.CopyToAsync(stream);
                        }
                        image.Ketchen = "/User_Files/Images/" + Path.GetFileName(file3.FileName);
                    }
                    else
                    {
                        image.Ketchen = _context.Image.Where(i => i.Id == id).Select(i => i.Ketchen).FirstOrDefault();
                    }
                    if (file4 != null && file4.Length != 0)
                    {
                        string path_to_Images4 = path_Root + "\\User_Files\\Images\\" + file4.FileName;
                        using (var stream = new FileStream(path_to_Images4, FileMode.Create))
                        {
                            await file4.CopyToAsync(stream);
                        }
                        image.LivingRoom = "/User_Files/Images/" + Path.GetFileName(file4.FileName);
                    }
                    else
                    {
                        image.LivingRoom = _context.Image.Where(i => i.Id == id).Select(i => i.LivingRoom).FirstOrDefault();
                    }
                    _context.Update(image);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ImageExists(image.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                var apartmentId = _context.Apartment.Include(l => l.Image).Where(a => a.Image.Id == id).Select(i => i.Id).FirstOrDefault();

                return(RedirectToAction("EditControl", "Apartments", new { id = apartmentId }));
            }
            return(View(image));
        }