public int SaveAssetLog(AssetLogViewModel assetLog, int terminalId, int tenantId) { var newAssetLog = new AssetLog(); Mapper.Map(assetLog, newAssetLog); newAssetLog.AssetLogId = Guid.NewGuid(); newAssetLog.DateCreated = DateTime.UtcNow; newAssetLog.TerminalId = terminalId; newAssetLog.TenantId = tenantId; _currentDbContext.AssetLog.Add(newAssetLog); int res = _currentDbContext.SaveChanges(); return(res); }
public IHttpActionResult PostAssetLog(AssetLogViewModel assetLog) { string serialNo = assetLog.piAddress.Trim().ToLower(); Terminals terminal = TerminalServices.GetTerminalBySerial(serialNo); if (terminal == null) { return(Unauthorized()); } int res = TerminalServices.SaveAssetLog(assetLog, terminal.TerminalId, terminal.TenantId); if (res > 0) { return(Ok("Success")); } else { return(BadRequest("Unable to save records")); } }