public async Task <IActionResult> PutSpecializationDB(Guid id, SpecializationDB specializationDB)
        {
            if (id != specializationDB.id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #2
0
        public async Task <IActionResult> PutPosition(Guid id, Position position)
        {
            if (id != position.id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #3
0
        internal async Task <Cadet> UpdateCadetAsync(Guid id, Cadet cadetDTO)
        {
            var cadets = await _context.Cadet.Where(c => c.id == id)
                         .Include(c => c.GroupDB)
                         .Include(c => c.GroupDB.ProfessionDB)
                         .Include(c => c.GroupDB.SpecializationDB)
                         .FirstOrDefaultAsync();

            if (cadets == null || cadets.id != id)
            {
                return(null);
            }
            cadets = UpdateCadetInDB(cadetDTO, cadets);



            _context.Entry(cadets).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();

                return(cadetDTO);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CadetDBExists(id))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }
        }
Example #4
0
        internal async Task <LessonDTO> AddlessonAsync(LessonDTO lessonDTO)
        {
            var lectural = await _context.Lectural.Where(c => c.id == lessonDTO.lecturalId).FirstOrDefaultAsync();

            var gr = await _context.Discipline.Where(c => c.name == lessonDTO.disciplineName).FirstOrDefaultAsync();

            var lessonType = await _context.LessonType.Where(c => c.nameOfType == lessonDTO.lessonType).FirstOrDefaultAsync();

            if (gr == null || lectural == null || lessonType == null)
            {
                return(null);
            }
            LessonDB lessonDB = new LessonDB(lectural, gr, lessonType, lessonDTO);

            try
            {
                _context.Lesson.Add(lessonDB);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LessonDTOExists(lessonDB.id))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            return(lessonDTO);
        }
        public async Task <IActionResult> PutAcademicTitle(Guid id, AcademicTitle academicTitle)
        {
            if (id != academicTitle.id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #6
0
        public async Task <IActionResult> PutMilitaryRank(Guid id, MilitaryRank militaryRank)
        {
            if (id != militaryRank.id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        internal async Task <TTDTOOut> UpdateTimeTibleAsync(Guid id, TTDTOOut tTDTOOut)
        {
            var timetableDB = await _context.Timetable.Where(c => c.id == id)
                              .Include(c => c.refLectural)
                              .Include(C => C.LessonDB)
                              .Include(c => c.GroupDB)
                              .Include(c => c.DisciplineDB)
                              .FirstOrDefaultAsync();

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

            try
            {
                await _context.SaveChangesAsync();

                return(tTDTOOut);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TimetableDBExists(id))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Disease")] Patient patient)
        {
            if (ModelState.IsValid)
            {
                _context.Add(patient);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(patient));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Speciality")] Doctor doctor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(doctor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(doctor));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Address,Phones")] Hospital hospital)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hospital);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hospital));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Designation,BirthDate,Salary,Grade,Email,Website,CellPhone")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
Example #12
0
        public async Task <IActionResult> Create([Bind("Id,Name,Age,Country,Occupation")] Person person)
        {
            if (ModelState.IsValid)
            {
                _context.Add(person);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(person));
        }
Example #13
0
        public async Task <GroupDTO> UpdateGroupAsync(Guid id, GroupDTO groupDTO)
        {
            var grups = await _context.Group.Where(c => c.id == id)
                        .Include(c => c.ProfessionDB)
                        .Include(c => c.SpecializationDB)
                        .FirstOrDefaultAsync();

            if (grups == null || grups.id != id)
            {
                return(null);
            }

            grups.id            = grups.id;
            grups.numberOfGroup = groupDTO.numberOfGroup;
            grups.info          = groupDTO.info;
            grups.CountCadets   = groupDTO.CountCadets;

            if (groupDTO.nameOfSpecialization != grups.SpecializationDB.SpecializationCode)
            {
                SpecializationDB spec = _context.Specialization.Where(c => c.nameOfSpecialization == groupDTO.nameOfSpecialization).FirstOrDefault();
                grups.SpecializationDB = spec;
                grups.ProfessionDBid   = spec.id;
            }
            if (groupDTO.ProfessionLastName != grups.ProfessionDB.nameOfProffession)
            {
                ProfessionDB prof = _context.Profession.Where(c => c.nameOfProffession == groupDTO.ProfessionLastName).FirstOrDefault();
                grups.ProfessionDB   = prof;
                grups.ProfessionDBid = prof.id;
            }

            _context.Entry(grups).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();

                return(groupDTO);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GroupDBExists(id))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }
        }
        internal async Task <DisciplineDTOTimetable> AddDisciplineAsync(DisciplineDTOTimetable discipline)
        {
            var specializationDB = _context.Specialization.Where(c => c.nameOfSpecialization == discipline.SpecializationDB).FirstOrDefault();

            if (specializationDB == null)
            {
                return(null);
            }
            DisciplineDB disciplineDBDB = new DisciplineDB(discipline, specializationDB);

            try
            {
                _context.Discipline.Add(disciplineDBDB);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!DisciplineDBExists(discipline.id))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            return(discipline);
        }
        public async Task <LecturalDTO> UpdateLecturalAsync(Guid id, LecturalDTO lecturalDTO)
        {
            var lectural = await _context.Lectural.Where(c => c.id == id)
                           .Include(c => c.Position)
                           .Include(c => c.MilitaryRank)
                           .Include(c => c.AcademicTitle)
                           .Include(c => c.AcademicDegree)
                           .FirstOrDefaultAsync();

            if (lectural == null || lectural.id != id)
            {
                return(null);
            }

            lectural.id         = lecturalDTO.id;
            lectural.firstName  = lecturalDTO.firstName;
            lectural.lastName   = lecturalDTO.lastName;
            lectural.middleName = lecturalDTO.middleName;

            lectural.birthDay       = lecturalDTO.birthDay;
            lectural.pathPhotoSmall = lecturalDTO.pathPhotoSmall;
            lectural.pathPhotoBig   = lecturalDTO.pathPhotoBig;
            lectural.serialAndNumderMilitaryDocs = lecturalDTO.serialAndNumderMilitaryDocs;
            lectural.serialAndNumderCivilyDocs   = lecturalDTO.serialAndNumderCivilyDocs;
            lectural.dateOfStartService          = lecturalDTO.dateOfStartService;
            lectural.isMarried       = lecturalDTO.isMarried;
            lectural.countOfChildren = lecturalDTO.countOfChildren;
            lectural.info            = lecturalDTO.info;

            if (lectural.AcademicDegree != null)
            {
                if (lectural.AcademicDegree.name != lecturalDTO.AcademicDegree)
                {
                    AcademicDegree academicDegree = _context.AcademicDegree.Where(c => c.name == lecturalDTO.AcademicDegree).FirstOrDefault();
                    lectural.AcademicDegree = academicDegree;
                }
            }
            else
            {
                AcademicDegree academicDegree = _context.AcademicDegree.Where(c => c.name == lecturalDTO.AcademicDegree).FirstOrDefault();
                lectural.AcademicDegree = academicDegree;
            }
            if (lectural.AcademicTitle != null)
            {
                if (lectural.AcademicTitle.name != lecturalDTO.AcademicTitle)
                {
                    AcademicTitle academicTitle = _context.AcademicTitle.Where(c => c.name == lecturalDTO.AcademicTitle).FirstOrDefault();
                    lectural.AcademicTitle = academicTitle;
                }
            }
            else
            {
                AcademicTitle academicTitle = _context.AcademicTitle.Where(c => c.name == lecturalDTO.AcademicTitle).FirstOrDefault();
                lectural.AcademicTitle = academicTitle;
            }

            if (lectural.Position != null)
            {
                if (lectural.Position.name != lecturalDTO.Position)
                {
                    Position position = _context.Position.Where(c => c.name == lecturalDTO.Position).FirstOrDefault();
                    lectural.Position = position;
                }
            }
            else
            {
                Position position = _context.Position.Where(c => c.name == lecturalDTO.Position).FirstOrDefault();
                lectural.Position = position;
            }
            if (lectural.MilitaryRank != null)
            {
                if (lectural.MilitaryRank.name != lecturalDTO.MilitaryRank)
                {
                    MilitaryRank militaryRank = _context.MilitaryRank.Where(c => c.name == lecturalDTO.MilitaryRank).FirstOrDefault();
                    lectural.MilitaryRank = militaryRank;
                }
            }
            else
            {
                MilitaryRank militaryRank = _context.MilitaryRank.Where(c => c.name == lecturalDTO.MilitaryRank).FirstOrDefault();
                lectural.MilitaryRank = militaryRank;
            }


            _context.Entry(lectural).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();

                return(lecturalDTO);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LecturalExists(id))
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }
        }