Exemplo n.º 1
0
        public async Task <IActionResult> PutTournement([FromRoute] int id, [FromBody] Tournement tournement)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tournement.Id)
            {
                return(BadRequest());
            }

            _context.Entry(tournement).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TournementExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,RegistrationStartDate,RegistrationEndDate,TournementStartDate,TournementEndDate")] Tournement tournement)
        {
            if (id != tournement.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tournement);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TournementExists(tournement.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tournement));
        }
Exemplo n.º 3
0
        public static TournementViewModel GetWithTournementModel(Tournement tournement)
        {
            TournementViewModel tournementViewModel = new TournementViewModel()
            {
                Id   = tournement.Id,
                Name = tournement.Name,
                RegistrationStartDate = tournement.TournementStartDate
            };

            return(tournementViewModel);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Name,RegistrationStartDate,RegistrationEndDate,TournementStartDate,TournementEndDate")] Tournement tournement)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tournement);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tournement));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> PostTournement([FromBody] TournementViewModel tournement)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var toSave = new Tournement()
            {
                Id     = tournement.Id,
                Name   = tournement.Name,
                Nation = _context.Nations.Where(s => s.Name == tournement.Nation)?.FirstOrDefault(),
            };

            _context.Tournements.Add(toSave);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTournement", new { id = tournement.Id }, tournement));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,Name,RegistrationStartDate,RegistrationEndDate,TournementStartDate,TournementEndDate")] TournementViewModel model)
        {
            var tournement = new Tournement();

            if (ModelState.IsValid)
            {
                tournement.Id   = model.Id;
                tournement.Name = model.Name;
                tournement.RegistrationEndDate   = model.RegistrationEndDate;
                tournement.RegistrationStartDate = model.RegistrationStartDate;
                tournement.TournementEndDate     = model.TournementEndDate;
                tournement.TournementStartDate   = model.TournementStartDate;
                _context.Add(tournement);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tournement));
        }
Exemplo n.º 7
0
 public ContestentsListViewModel(Contestent c, string userName, string userID, Tournement t)
 {
     ContestentId          = c.Id;
     UserName              = userName;
     EnlistDate            = c.EnlistDate;
     TournementName        = t.Name;
     RegistrationStartDate = t.RegistrationStartDate;
     RegistrationEndDate   = t.RegistrationEndDate;
     TournementStartDate   = t.TournementStartDate;
     TournementEndDate     = t.TournementEndDate;
     TournementId          = t.Id;
     UsersId = userID;
 }