public async Task <ActionResult <TimeRecording> > PostTimeRecording(TimeRecording timeRecording) { _context.TimeRecordings.Add(timeRecording); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTimeRecording", new { id = timeRecording.Id }, timeRecording)); }
public async Task <IActionResult> PutTimeRecording(int id, TimeRecording timeRecording) { if (id != timeRecording.Id) { return(BadRequest()); } _context.Entry(timeRecording).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TimeRecordingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <TimeRecording> > PostTimeRecording2(int clientId, int lawyerId, int matterId, int categoryId, string description, string to, string from) { Client client = _context.Clients.Where(client => client.Id == clientId).FirstOrDefault(); Lawyer lawyer = _context.Lawyers.Where(lawyer => lawyer.Id == lawyerId).FirstOrDefault(); Matter matter = _context.Matters.Where(matter => matter.Id == matterId).FirstOrDefault(); TimeRecording timeRecording = new TimeRecording { StartDate = DateTime.Parse(to), EndDate = DateTime.Parse(from), Client = client, Lawyer = lawyer, Matter = matter, Category = (Category)categoryId, Description = description }; _context.TimeRecordings.Add(timeRecording); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTimeRecording", new { id = timeRecording.Id }, timeRecording)); }