public async Task <long> getStartDateRoll(long id) { builder = new UriBuilder(_configuration["productionOrdersHistStates"] + "?ProductionOrderId=" + id); if ((await client.GetAsync(builder.ToString())).StatusCode != HttpStatusCode.OK) { throw new System.ArgumentException("Parameter not found", "Production Order corrupted"); } var states = JsonConvert.DeserializeObject <List <HistState> >(await client.GetStringAsync(builder.ToString())); HistState state = states.Where(x => x.state == "active").FirstOrDefault(); Console.WriteLine(builder.ToString()); return(state.date); }
public async Task <HistState> addHistStates(int productionOrderId, string state) { try { HistState histState = new HistState(); histState.date = DateTime.Now.Ticks; histState.state = state; histState.productionOrderId = productionOrderId; _context.HistStates.Add(histState); await _context.SaveChangesAsync(); return(histState); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(null); } }