public async Task InsertAsync(PassItem newPassItem) { await throwPassItemIfNotExistAsync(newPassItem.UserId, newPassItem.Name); _context.PassItems.Add(newPassItem); await _context.SaveChangesAsync(); }
public async Task <IActionResult> PutWorker(int id, WorkerDto workerDto) { var worker = _mapper.Map <Worker>(workerDto); if (id != worker.WorkerId) { return(BadRequest()); } _context.Entry(worker).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WorkerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProject(int id, RoleDto role) { if (id != role.RoleId) { return(BadRequest()); } _context.Entry(role).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAssignment(int id, AssignmentDto assignmentDto) { var assignment = _mapper.Map <Assignment>(assignmentDto); if (id != assignment.AssignmentId) { return(BadRequest()); } _context.Entry(assignment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AssignmentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Comment> > PostComment(CommentDto commentDto) { var comment = _mapper.Map <Comment>(commentDto); _context.Comments.Add(comment); await _context.SaveChangesAsync(); return(CreatedAtAction("GetComment", new { id = comment.CommentId }, comment)); }