public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Gender,Size,Type,Colour,Quantity,Price")] Catalog catalog) { if (id != catalog.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(catalog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CatalogExists(catalog.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(catalog)); }
private async Task SeedCatalogTagsAsync(IProgress <int> recordsProgressHandler) { var sw = new Stopwatch(); sw.Start(); _logger.LogInformation("----- Adding CatalogTags"); var tagsText = await File.ReadAllTextAsync(Path.Combine(_setupPath, "CatalogTags.txt")); var tags = JsonConvert.DeserializeObject <List <CatalogFullTag> >(tagsText); _logger.LogInformation("----- Adding tags to CatalogItems"); int i = 0; foreach (var tag in tags) { var entity = await _dbContext.CatalogItems.FirstOrDefaultAsync(ci => ci.Id == tag.ProductId); if (entity == null) { continue; } entity.TagsJson = JsonConvert.SerializeObject(tag); _dbContext.Update(entity); recordsProgressHandler.Report(++i); } await _dbContext.SaveChangesAsync(); _logger.LogInformation("----- {TotalRows} CatalogTags Added ({TotalSeconds:n3}s)", i, sw.Elapsed.TotalSeconds); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Price,AvailableStock")] CatalogItem catalogItem) { if (id != catalogItem.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(catalogItem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CatalogItemExists(catalogItem.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(catalogItem)); }
public async Task <IActionResult> Edit(int id, [Bind("id,name,credits,prereqs,courseNum,offeredIn,description,department")] Course course) { if (id != course.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(course); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(course.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(course)); }
public async Task <IActionResult> Edit(int id, [Bind("TranslationID,Danish,Swedish,Norwegian,English,German,Spanish,Italian,Croatian")] Translation translation) { if (id != translation.TranslationID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(translation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TranslationExists(translation.TranslationID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(translation)); }
public async Task <IActionResult> UpdateProduct([FromBody] CatalogItem productToUpdate) { var catalogItem = await catalogContext.CatalogItems.SingleOrDefaultAsync(w => w.Id == productToUpdate.Id); if (catalogItem == null) { return(NotFound()); } catalogItem = productToUpdate; catalogContext.Update(catalogItem); await catalogContext.SaveChangesAsync(); return(CreatedAtAction(nameof(GetItemById), new { id = productToUpdate.Id })); }
public async Task <IActionResult> UpdateProduct([FromBody] CatalogItem productToUpdate) { var catalogItem = await _catalogContext.CatalogItems .SingleOrDefaultAsync(i => i.Id == productToUpdate.Id); if (catalogItem == null) { return(NotFound(new { Message = $"Item with id {productToUpdate.Id} not found." })); } catalogItem = productToUpdate; _catalogContext.Update(catalogItem); await _catalogContext.SaveChangesAsync(); return(CreatedAtAction(nameof(GetItemById), new { id = productToUpdate.Id })); }
public async Task <IActionResult> Edit(int id, Order order) { var dbOrder = await _context .Orders .Include(o => o.OrderItems) .FirstOrDefaultAsync(m => m.Id == id); if (id != order.Id && dbOrder == null) { return(NotFound()); } dbOrder.AdminComments = order.AdminComments; dbOrder.Status = order.Status; if (ModelState.IsValid) { try { _context.Update(dbOrder); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(order.Id)) { return(NotFound()); } else { throw; } } return(Redirect("/Admin/Manage/Index")); } return(View(dbOrder)); }
public async Task <bool> UpdateCatalogItemAsync(CatalogItem catalogItem) { catalogContext.Update(catalogItem); return(await catalogContext.SaveChangesAsync() > 0); }
public void Update(Categoria categoria) { _context.Update <Categoria>(categoria); _context.SaveChanges(); }
public void Update(Empresa empresa) { _context.Update <Empresa>(empresa); _context.SaveChanges(); }