public async Task <IActionResult> Edit(int id, [Bind("Id,IdObject,Object,StartDate,EndDate,MaxParticipants,IsReserved")] Date date)
        {
            if (id != date.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(date);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DateExists(date.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(date));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,ObjectType,City,Street,BuildingNumber")] SportObject sportObject)
        {
            if (id != sportObject.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sportObject);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SportObjectExists(sportObject.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(sportObject));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,IdUser,IdDate,Acceptance")] Reservation reservation)
        {
            if (id != reservation.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var user = _context.Users.Find(reservation.IdUser);
                    if (user == null)
                    {
                        return(NotFound());
                    }
                    reservation.User = user;

                    var date = _context.Dates.Find(reservation.IdDate);

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

                    var sportObject = _context.SportObjects.Find(date.IdObject);
                    if (sportObject == null)
                    {
                        return(NotFound());
                    }

                    date.Object = sportObject;

                    reservation.Date = date;

                    _context.Update(reservation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReservationExists(reservation.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reservation));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,IdFrom,IdTo,Subject,Content")] Message message)
        {
            if (id != message.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var userTo = _context.Users
                                 .Find(message.IdTo);

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

                    message.UserTo = userTo;

                    _context.Update(message);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MessageExists(message.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(message));
        }