public void Update(ResourceManagementModel item) { var newItem = new ResourceEF( item.Id, item.Name, item.PriceBase, item.Price, item.Performance, item.StockId); _db.Entry(newItem).State = EntityState.Modified; }
public void Create(ResourceManagementModel item) { var newItem = new ResourceEF( item.Id, item.Name, item.PriceBase, item.Price, item.Performance, item.StockId); _db.Resources.Add(newItem); }
public IActionResult EditResource(ResourceManagementModel resource) { try { // TODO: Add update logic here if (ModelState.IsValid) { _resourceManagementService.UpdateResource(resource); } return(RedirectToAction(nameof(Index))); } catch { return(RedirectToAction(nameof(EditResource))); } }
public void UpdateResource(ResourceManagementModel resource) { _resourceUOW.Resources.Update(resource); _resourceUOW.Save(); }
private TableEditorModel GetTableModel(IEnumerable <ResourceManagementModel> entities, ResourceManagementModel entity) { var entityType = typeof(ResourceManagementModel); var tableModel = new TableEditorModel("Resources", entityType, "Id", entities, entity); var stocks = _resourceManagementService.GetStocks().OrderBy(s => s.Name); _tableEditorService.AddColumn(tableModel, "Id", null); _tableEditorService.AddColumn(tableModel, "Name", null, ControlType.Input, null); _tableEditorService.AddColumn(tableModel, "PriceBase", null, ControlType.Input, null); _tableEditorService.AddColumn(tableModel, "Price", null, ControlType.Input, null); _tableEditorService.AddColumn(tableModel, "Performance", null, ControlType.Input, null); _tableEditorService.AddColumn(tableModel, "StockId", null, ControlType.Select, new SelectList(stocks, "Id", "Name")); return(tableModel); }