public Tool Edit(Tool tool, ToolUpdateModel model) { tool.Name = model.Name; tool.Description = model.Description; tool.Quantity = model.Quantity; tool.ImageTool = model.Image; return(tool); }
public Tool Update(string id, ToolUpdateModel model) { var repo = uow.GetService <IToolRepository>(); var tool = repo.Get().Where(s => s.ToolId == id).FirstOrDefault(); if (tool != null) { var updatedTool = repo.Edit(tool, model); return(repo.Update(updatedTool).Entity); } return(null); }
public IActionResult Update([FromQuery] string id, [FromBody] ToolUpdateModel model) { try { Tool updated = _uow.GetService <ToolDomain>().Update(id, model); if (updated != null) { _uow.SaveChanges(); return(Success(updated.ToolId)); } return(BadRequest()); } catch (Exception ex) { return(Error(ex.Message)); } }