Пример #1
0
        public async Task <IActionResult> PutProjectKeyIndicatorYear(Guid id, ProjectKeyIndicatorYear projectKeyIndicatorYear)
        {
            if (id != projectKeyIndicatorYear.Id)
            {
                return(BadRequest());
            }

            _context.Entry(projectKeyIndicatorYear).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProjectKeyIndicatorYearExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PutRole(Guid id, Role role)
        {
            if (id != role.Id)
            {
                return(BadRequest());
            }

            _context.Entry(role).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RoleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutOperationalCompany(Guid id, OperationalCompany operationalCompany)
        {
            if (id != operationalCompany.Id)
            {
                return(BadRequest());
            }

            _context.Entry(operationalCompany).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OperationalCompanyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #4
0
        public async Task <UserDto> PatchTask(UserDto user)
        {
            var sqlUser = await _context.Users.SingleOrDefaultAsync(x => x.Id == user.Id);

            var userSql = _mapper.Map(user, sqlUser);

            _context.Entry(userSql).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(user);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_context.Users.Any(e => e.Id == user.Id))
                {
                    return(null);
                }

                throw;
            }
        }