public async Task <IActionResult> Edit(int id, [Bind("CategoryId,CategoryName,CategoryEOLMonths,CategoryActive,CategoryComment")] Category category) { if (id != category.CategoryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.CategoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,CurrencyName,CurrensyToUSD,CurrencyComment")] Currency currency) { if (id != currency.Id) { return(NotFound()); } if (ModelState.IsValid) { try { currency.CurrensyToUSD /= 100; _context.Update(currency); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CurrencyExists(currency.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(currency)); }
public async Task <IActionResult> Edit(int id, [Bind("OfficeId,OfficeName,OfficeCountry,CurrencyId")] Office office) { if (id != office.OfficeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(office); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OfficeExists(office.OfficeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CurrencyId"] = new SelectList(_context.Currencies, "Id", "Id", office.CurrencyId); return(View(office)); }
public IActionResult ActivateCurrency(int id) { var selectedCurrency = _context.Currencies.Where(a => a.Id == id).FirstOrDefault(); selectedCurrency.CurrencyActive = true; _context.Update(selectedCurrency); _context.SaveChanges(); return(RedirectToAction(nameof(DeactivatedCurrencies))); }
public async Task <IActionResult> ActivateAsset(int id) { var asset = await _context.Assets.FirstOrDefaultAsync(a => a.AssetId == id); asset.AssetActive = true; _context.Update(asset); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(InactiveAssets))); }
public async Task <IActionResult> Edit(int id, [Bind("SupplierID,SupplierName,SupplierDescription,SupplierEmail,SupplierContactFirstName,SupplierContactLastName,SupplierContactEmail,SupplierCity,CountryID,SupplierAddress,SupplierActive")] Supplier supplier) { if (id != supplier.SupplierID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(supplier); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SupplierExists(supplier.SupplierID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CountryID"] = new SelectList(_context.Countries, "CountryId", "CountryDescription", supplier.CountryID); return(View(supplier)); }
public async Task <IActionResult> Edit(Guid id, [Bind("AssetId,MimeType,Country,FileName,CreatedBy,Email,Description,CreatedOn")] Asset asset) { if (id != asset.AssetId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(asset); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AssetExists(asset.AssetId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(asset)); }
public async Task <IActionResult> Edit(int id, [Bind("CatalogueID,ProductName,ProductDescription,CategoryID,CataloguePrice,SupplierProductID,SupplierID,Obsolete,CatalogueItemActive")] Catalogue catalogue) { if (id != catalogue.CatalogueID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(catalogue); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CatalogueExists(catalogue.CatalogueID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryID"] = new SelectList(_context.Categories, "CategoryId", "CategoryName", catalogue.CategoryID); ViewData["SupplierID"] = new SelectList(_context.Suppliers, "SupplierID", "SupplierName", catalogue.SupplierID); return(View(catalogue)); }
public async Task <IActionResult> Edit(int id, [Bind("CurrencyID,CurrencyName,CurrencyDescription,ExchangeRate,CurrencyDefault,CurrencyActive")] Currency currency) { if (id != currency.CurrencyID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(currency); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CurrencyExists(currency.CurrencyID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(currency)); }
public async Task <IActionResult> Edit(int id, [Bind("DepreciationID,DepreciationName,DepreciationDescription")] Depreciation depreciation) { if (id != depreciation.DepreciationID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(depreciation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepreciationExists(depreciation.DepreciationID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(depreciation)); }
public async Task <IActionResult> Edit(int id, [Bind("AssetID,CatalogueID,AssetPurchaseDate,AssetExpirationDate,AssetPrice,AssetValue,AssetActive,OfficeID")] Asset asset) { if (id != asset.AssetID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(asset); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AssetExists(asset.AssetID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CatalogueID"] = new SelectList(_context.Catalogues.Where(a => a.Obsolete == false), "CatalogueID", "ProductName", asset.CatalogueID); ViewData["OfficeID"] = new SelectList(_context.Offices.Where(a => a.OfficeActive == true), "OfficeID", "OfficeName", asset.OfficeID); return(View(asset)); }
public async Task <IActionResult> Edit(int id, [Bind("CountryId,CountryName,CountryDescription,CountryVisible")] Country country) { if (id != country.CountryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(country); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(country.CountryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(country)); }
public async Task <IActionResult> Edit(int id, [Bind("ReplacementID,CatalogueID,ReplacingID")] Replacement replacement) { if (id != replacement.ReplacementID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(replacement); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReplacementExists(replacement.ReplacementID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CatalogueID"] = new SelectList(_context.Catalogues.Where(a => a.Obsolete == true), "CatalogueID", "ProductName", replacement.CatalogueID); ViewData["ReplacingID"] = new SelectList(_context.Catalogues.Where(a => a.Obsolete == false), "CatalogueID", "ProductName", replacement.ReplacingID); return(View(replacement)); }
public async Task Update(T t) { if (t != null) { _ctx.Update(t); await _ctx.SaveChangesAsync(); } }
public async Task <IActionResult> Edit(int id, [Bind("CategoryId,CategoryName,CategoryEOLMonths,CategoryActive,CategoryComment,DepreciationID")] Category category) { if (id != category.CategoryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); // Update all Asset's expiration date when Category's EOL has changed var assets = await _context.Assets.Include(a => a.Catalogue).Where(a => a.Catalogue.CategoryID == category.CategoryId).ToListAsync(); foreach (var item in assets) { item.AssetExpirationDate = item.AssetPurchaseDate.AddMonths(category.CategoryEOLMonths); _context.Update(item); await _context.SaveChangesAsync(); } } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.CategoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DepreciationID"] = new SelectList(_context.Depreciations, "DepreciationID", "DepreciationDescription", category.DepreciationID); return(View(category)); }
private void UpdateInfo() { PrintList(); Console.WriteLine("which would you like to edit? \n"); int whichI = int.Parse(Console.ReadLine()); var asset = context.Assets.Include(s => s.CategoryObject).FirstOrDefault(s => s.AssetId == whichI); Console.WriteLine("\n\n\n\n"); Console.WriteLine(($"a) Assetname {asset.AssetName} b) Asset Model {asset.AssetModel} c) Price {asset.price} d) Category Name {asset.CategoryObject.CategoryName}")); Console.WriteLine("\nwhat would you like to edit? \n"); Console.WriteLine("A)Name B) Model C) Price D) Category"); string choice = Console.ReadLine().ToLower(); Console.WriteLine("Type new Value: "); string newValue = Console.ReadLine(); switch (choice) { case "a": asset.AssetName = newValue; break; case "b": asset.AssetModel = newValue; break; case "c": asset.price = float.Parse(newValue); break; case "d": asset.CategoryObject.CategoryName = newValue; break; default: break; } context.Update(asset); context.SaveChanges(); Console.ReadKey(); Start(); }