private void UpdateAssets(IList <AssetDto> input) { // First modification for all assets. input[0].Tag = "CRD-X-00004"; input[0].ModifiedBy = "userX"; input[1].Description = "Modified description"; input[1].Price = 11.12M; input[1].ModifiedBy = "userX"; input[2].Price = 12.34M; input[2].InstallDate = DateTime.Now.AddDays(3); input[2].PaidBy = "userX"; input[2].ModifiedBy = "userX"; _assetRepo.Update(input); AddToHistory(input); // And a second modification for one asset; input[1].Description = "Yet another modified description"; input[1].IctsReference = "Ref0123456789"; input[1].ModifiedBy = "userY"; _assetRepo.Update(input[1]); AddToHistory(new[] { input[1] }); }
public static int Update(int id, IAsset asset) { if (asset.Id <= 0) { throw new ArgumentException("Asset Id must be 0."); } if (asset.Id != id) { throw new ArgumentException("Asset Id must match Id."); } using (AssetRepository repo = new AssetRepository()) { return(repo.Update(id, asset)); } }
public Asset Save([FromBody] Asset model) { if (model.Id == 0) { model.BranchId = _branchContext.Branch.Id; model.CreateDate = DateTime.Now; model.UserId = _sessionContext.UserId; } ModelState.Clear(); TryValidateModel(model); ModelState.Validate(); if (model.Id > 0) { _repository.Update(model); } else { _repository.Insert(model); } return(model); }
public void UpdateAsset(params Asset[] Assets) { /* Validation and error handling omitted */ _assetRepository.Update(Assets); }