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()); }
public async Task <IActionResult> CreateEvent(Event @event) { _context.Add(@event); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
private async Task CheckClientAsync(User user) { if (!dc.Clients.Any()) { dc.Clients.Add(new Client { User = user }); await dc.SaveChangesAsync(); } }
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)); }
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)); }