public IActionResult ProcessKeyLog([FromBody] List <amModel> itemList) { if (itemList == null) { return(BadRequest()); } using (var db = new amContext()) { db.DeleteDataSuccessSendToServer(); itemList.ForEach(item => db.CreateData(item)); } return(CreatedAtRoute("api/amController/ProcessKeyLog", new { id = itemList[0].amModelId }, itemList)); }
public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables() ; Configuration = builder.Build(); using (var db = new amContext()) { db.Database.EnsureCreated(); db.Database.Migrate(); } }
public IActionResult ProcessCaptureImage([FromBody] List <amCapture> itemList) { if (itemList == null) { return(BadRequest()); } ; using (var db = new amContext()) { db.DeleteImageSuccessSendToServer(); itemList.ForEach(item => db.SaveImageData(item)); } return(Ok()); //return Ok(itemList); //return CreatedAtRoute("api/amController/ProcessCaptureImage", new { id = itemList[0].amCaptureId }, itemList); }
public amController(amContext context) { _context = context; if (_context.amModel.Count() == 0 && _context.amCapture.Count() == 0) { _context.amModel.Add(new amModel()); _context.amCapture.Add(new amCapture()); _context.SaveChanges(); } else if (_context.amModel.Count() == 0 && _context.amCapture.Count() != 0) { _context.amModel.Add(new amModel()); _context.SaveChanges(); } else if (_context.amModel.Count() != 0 && _context.amCapture.Count() == 0) { _context.amCapture.Add(new amCapture()); _context.SaveChanges(); } }