예제 #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);
        }