public async Task <IHttpActionResult> PutAgency(int id, AgencyModel agencyModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != agencyModel.Id) { return(BadRequest()); } db.Entry(agencyModel).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AgencyModelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> Create([Bind("Id,Name,Icon,Url")] Social social) { if (ModelState.IsValid) { _context.Add(social); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(social)); }
public async Task <IActionResult> Create([Bind("Id,Title,Slug,Text,Author,Date,Photo")] Blog blog) { if (ModelState.IsValid) { _context.Add(blog); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(blog)); }
public async Task <IActionResult> Create([Bind("Id,Address,Email,PhoneNumber")] Setting setting) { if (ModelState.IsValid) { _context.Add(setting); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(setting)); }
public async Task SeedAsync(AgencyDbContext dbContext, IServiceProvider serviceProvider) { if (dbContext == null) { throw new ArgumentNullException(nameof(dbContext)); } if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } var seeders = new List <ISeeder> { //new RolesSeeder(), }; foreach (var seeder in seeders) { await seeder.SeedAsync(dbContext, serviceProvider); await dbContext.SaveChangesAsync(); // logger.LogInformation($"Seeder {seeder.GetType().Name} done."); } }