public ActionResult AssignAssetToUser([FromBody] AssignAsset asset) { try { _db.AssignAsset.Add(asset); _db.SaveChanges(); Asset a = _db.Asset.Find(asset.AssetId); a.IsAvailable = false; _db.Asset.Update(a); _db.SaveChanges(); return(Ok()); } catch (Exception) { return(BadRequest()); } }
public async Task <Employee> AddEmployee(Employee employee) { await _db.Employee.AddAsync(employee); _db.SaveChanges(); return(await _db.Employee.FindAsync(employee.EmployeeId)); }
public ActionResult AddAsset([FromBody] List <Asset> listOfAssets) { foreach (var item in listOfAssets) { _db.Asset.Add(item); } _db.SaveChanges(); return(Ok()); }