public async Task <ActionResult> UpdateJob(int key, string values) { var newValue = await _MyDbContext.Jobs.Include(j => j.Message).FirstOrDefaultAsync(j => j.ID == key); JsonConvert.PopulateObject(values, newValue); SenderMail a = new SenderMail(); a.Start(newValue); _MyDbContext.Jobs.Update(newValue); await _MyDbContext.SaveChangesAsync(); return(Ok()); }
public async Task <ActionResult> InsertJob(string values) { var newJob = new MyJob(); JsonConvert.PopulateObject(values, newJob); await _MyDbContext.Jobs.AddAsync(newJob); await _MyDbContext.Messages.AddAsync(newJob.Message); await _MyDbContext.SaveChangesAsync(); SenderMail a = new SenderMail(); a.Start(newJob); return(Ok()); }