public async Task <IActionResult> PutSCxItemAsync(Guid id, SCxItem sCxItem) { if (id != sCxItem.Id) { return(BadRequest()); } else if (!SCxItemExists(id)) { return(NotFound()); } else { _context.Entry(sCxItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(NoContent()); } }
/// <summary> /// This method gets called by the runtime and configures the Database context. /// </summary> public SCxViewController(SCxItemContext context) { _context = context; if (!_context.SCxItems.Any()) { // If no data - setup test data for the last 31 days. foreach (SCxItem sCxItem in SCxItem.AddThisMonthsSCxData(0)) { _context.SCxItems.Add(sCxItem); } _context.SaveChangesAsync(); } }
/// <summary> /// This method gets called by the runtime and configures the Database context. /// </summary> public SCxItemsController(SCxItemContext context) { _context = context; if (!_context.SCxItems.Any()) { // If no data - setup test data for the past 3 years. for (var month = 0; month <= 36; month++) { foreach (SCxItem sCxItem in SCxItem.AddThisMonthsSCxData(month)) { _context.SCxItems.Add(sCxItem); } _context.SaveChangesAsync(); } } }
public async Task <IActionResult> CreateConfirmed([FromForm, Bind("Id,TimeStamp,Type,Dept,Food,Supplier,CheckUBD,Temperature,Comment,SignOff")] SCxItem sCxItem) { if (ModelState.IsValid) { try { if (SCxItemExists(sCxItem.Id)) { return(BadRequest("BadRequest:CreateConfirmed - id Already Exists.")); } else { _context.Add(sCxItem); await _context.SaveChangesAsync(); } } catch (Exception) { throw; } return(RedirectToAction(nameof(Index))); } return(View(sCxItem)); }