public async Task <IActionResult> Create([Bind("UserId,MembershipNumber,FirstName,LastName,Email,Active")] User user)
        {
            if (ModelState.IsValid)
            {
                user.UserId = Guid.NewGuid();
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MembershipNumber"] = new SelectList(_context.Membership, "MembershipNumber", "MembershipType", user.MembershipNumber);
            return(View(user));
        }
Exemplo n.º 2
0
        public async Task <bool> SubmitScore(Score scoreData)
        {
            try
            {
                Reservation reservation = null;
                if (scoreData.Reservation != null && scoreData.Reservation?.ResevationNumber != 0)
                {
                    reservation = await _context.Reservation.Where(x => x.ResevationNumber == long.Parse(scoreData.Reservation.ResevationNumber.ToString())).FirstOrDefaultAsync();
                }

                Score score = new Score()
                {
                    ScoreId       = Guid.NewGuid(),
                    ReservationId = reservation?.ReservationId,
                    Date          = scoreData.Date,
                    UserId        = scoreData.User.UserId,
                    TotalScore    = scoreData.TotalScore
                };

                await _context.Score.AddAsync(score);

                await _context.SaveChangesAsync();

                return(true);
            } catch (Exception ex)
            {
                return(false);
            }
        }
        public async Task <bool> CreateOneTimeReservation(ReservationDTO reservationData)
        {
            Reservation reservation = new Reservation()
            {
                ReservationId   = Guid.NewGuid(),
                UserId          = reservationData.User.UserId,
                StartDate       = reservationData.StartDate,
                EndDate         = reservationData.EndDate,
                Notes           = reservationData.Notes,
                NumberOfPlayers = reservationData.NumberOfPlayers,
                CreatedBy       = reservationData.CreatedBy,
                CreatedDateTime = DateTime.UtcNow,
            };

            await _context.Reservation.AddAsync(reservation);

            await _context.SaveChangesAsync();

            return(true);
        }