public async Task <IActionResult> Create([Bind("Id,ObjectType,City,Street,BuildingNumber")] SportObject sportObject)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sportObject);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(sportObject));
        }
        public async Task <IActionResult> Create([Bind("Id,IdObject,StartDate,EndDate,MaxParticipants,IsReserved")] Date date)
        {
            if (ModelState.IsValid)
            {
                var sportObject = _context.SportObjects
                                  .Find(date.IdObject);

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

                date.Object = sportObject;
                _context.Add(date);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(date));
        }
        public async Task <IActionResult> Create([Bind("Id,IdFrom,IdTo,Subject,Content")] Message message)
        {
            if (ModelState.IsValid)
            {
                var userTo = _context.Users
                             .Find(message.IdTo);

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

                message.UserTo = userTo;

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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(message));
        }
        public async Task <IActionResult> Create([Bind("Id,IdUser,IdDate,Acceptance")] Reservation reservation)
        {
            if (ModelState.IsValid)
            {
                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.Add(reservation);
                await _context.SaveChangesAsync();

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