public async Task <IActionResult> PutProjectsEmployees(int id, ProjectsEmployees projectsEmployees) { if (id != projectsEmployees.IdTasksEmployees) { return(BadRequest()); } _context.Entry(projectsEmployees).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectsEmployeesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEmployees(short id, Employees employees) { if (id != employees.IdEmployee) { return(BadRequest()); } _context.Entry(employees).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeesExists(id)) { return(NotFound()); } else { throw; } } var response = new { status = "Ok", name = "Все ок" }; return(Ok(response)); }
public async Task <IActionResult> PutTasks(int id, Tasks tasks) { if (id != tasks.Idtask) { return(BadRequest()); } _context.Entry(tasks).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TasksExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Post([FromBody] emp emp) { _context.Employee.Add(emp); await _context.SaveChangesAsync(); return(CreatedAtAction("get employee", new { id = emp.Id }, emp)); }
public async Task <bool> SaveChangesAsync() { _logger.LogInformation($"Attempitng to save the changes in the context"); // Only return success if at least one row was changed return((await _context.SaveChangesAsync()) > 0); }