public async Task <IActionResult> Put(int id, TimeTableRecord record) { if (!ModelState.IsValid) { return(new StatusCodeResult(400)); } var dataRecord = await _context.TimeTableRecords.SingleOrDefaultAsync(x => x.Id == id); if (dataRecord != null) { dataRecord.Day = record.Day; dataRecord.Description = record.Description; dataRecord.Month = record.Month; dataRecord.Time = record.Time; dataRecord.Title = record.Title; dataRecord.Year = record.Year; dataRecord.Repeating = record.Repeating; dataRecord.UsersAttached = record.UsersAttached; await _context.SaveChangesAsync(); } else { return(new StatusCodeResult(400)); } return(Ok(dataRecord)); }
public async Task <IActionResult> Post(TimeTableRecord record) { if (!ModelState.IsValid) { return(new StatusCodeResult(400)); } var recordNew = new TimeTableRecord() { Day = record.Day, Month = record.Month, Year = record.Year, Time = record.Time, Description = record.Description, Title = record.Title, UserId = record.UserId, Repeating = record.Repeating }; await _context.AddAsync(recordNew); _context.SaveChanges(); return(new StatusCodeResult(200)); }