public async Task <IActionResult> PutReminder(int id, Reminder reminder) { if (id != reminder.id) { return(BadRequest()); } DateTime now = DateTime.Now; reminder.CreatedOn = now; _context.Reminders.Add(reminder); _context.Entry(reminder).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReminderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutReminderItem(long id, ReminderItem reminderItem) { if (id != reminderItem.Id) { return(BadRequest()); } if (!ReminderItemExists(id)) { return(NotFound()); } _context.Entry(reminderItem).State = EntityState.Modified; await _context.SaveChangesAsync(); return(Ok(reminderItem)); }
public async Task <int> SaveAsync(Event newEvent) { if (newEvent == null) { throw new Exception("received an empty product"); } await _context.Events.AddAsync(newEvent); await _context.SaveChangesAsync(); return(newEvent.Id); }
public async Task <int> CreateMotReminder(ReminderRequest model) { var expiryDate = DateTime.Parse(model.MotExpiryDate); var dueDate = expiryDate.AddYears(1).AddDays(-30); var tableRow = new TableModels.Reminder { Email = model.Email, Manufacturer = model.Manufacturer, Model = model.Model, MotExpiryDate = expiryDate, Registration = model.Registration, ReminderDueDate = dueDate }; dataContext.Reminders.Add(tableRow); await dataContext.SaveChangesAsync(); return(tableRow.Id); }