public async Task <IActionResult> PutCategory([FromRoute] int id, [FromBody] Category category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreateEvent(Event @event)
        {
            _context.Add(@event);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 3
0
 private async Task CheckClientAsync(User user)
 {
     if (!dc.Clients.Any())
     {
         dc.Clients.Add(new Client {
             User = user
         });
         await dc.SaveChangesAsync();
     }
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description,Slung")] City city)
        {
            if (ModelState.IsValid)
            {
                _context.Add(city);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(city));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,Address")] Client client)
        {
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

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