Ejemplo n.º 1
0
        public async Task <IActionResult> PutAspirant([FromRoute] int id, [FromBody] Aspirant aspirant)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != aspirant.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] Prepod prepod)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            prepod.DepartmentsString = GetDepartmentsString(prepod);

            // // заполнение поля акронимами кафедр
            // prepod.DepartmentsString = String.Empty;
            // foreach (var item in prepod.Departments.OrderBy (o => o.Acronym)) {
            //     var dep = _context.Departments.FirstOrDefault (i => i.Id == item.Id);
            //     if (String.IsNullOrEmpty (prepod.DepartmentsString))
            //         prepod.DepartmentsString = dep?.Acronym;
            //     else
            //         prepod.DepartmentsString = prepod.DepartmentsString + ", " + dep?.Acronym;
            // }

            _context.Entry(prepod).State = EntityState.Modified;
            try {
                await EditAssignedDepartments(prepod);

                await _context.SaveChangesAsync();
            } catch (DbUpdateConcurrencyException) {
                // if (!DepartmentExists (id)) {
                //     return NotFound ();
                // } else {
                //     throw;
                // }
            }
            return(NoContent());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] Department department)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != department.Id)
            {
                return(BadRequest());
            }

            _context.Entry(department).State = EntityState.Modified;
            try {
                await EditAssignedSpecialities(department);

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