示例#1
0
        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());
        }
示例#2
0
        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));
        }
示例#3
0
        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());
        }
示例#4
0
        public async Task <IActionResult> Post([FromBody] emp emp)
        {
            _context.Employee.Add(emp);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("get employee", new { id = emp.Id }, emp));
        }
示例#5
0
        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);
        }