Beispiel #1
0
        public Pupil Update(PupilDTO pupil)
        {
            var pupil1 = pupil.ToPupil();

            context.PupilsRepository.Update(pupil1);
            context.Save();
            return(pupil1);
        }
Beispiel #2
0
        public Pupil(PupilDTO dto, long schoolId)
        {
            PupilId   = dto.PupilId;
            FirstName = dto.FirstName;
            Surname   = dto.Surname;

            SchoolId = schoolId;
        }
Beispiel #3
0
        public Pupil(PupilDTO dto, long classRoomId)
        {
            PupilId   = dto.PupilId;
            FirstName = dto.FirstName;
            Surname   = dto.Surname;

            ClassRoomId = classRoomId;
        }
Beispiel #4
0
 internal PupilViewModel Map(PupilDTO pupil)
 {
     return(new PupilViewModel
     {
         Id = pupil.Id,
         Name = pupil.Name,
         SecondName = pupil.SecondName,
         Surname = pupil.Surname
     });
 }
 public PupilRecord GetPupilRecord(PupilDTO pupil)
 {
     return(new PupilRecord
     {
         Id = pupil.id,
         ForeName = pupil.Forename,
         Surname = pupil.Surname,
         ULN = pupil.ULN,
         UPN = pupil.UPN
     });
 }
      public IHttpActionResult GetPupil(string id)
      {
          PupilDTO pupil = pupilService.GetById(id).ToPupilDTO();;

          if (pupil != null)
          {
              return(Ok(pupil));
          }

          return(BadRequest());
      }
 public static Pupil ToPupil(this PupilDTO ucenik)
 {
     return(new Pupil
     {
         Id = ucenik.PupilId,
         FirstName = ucenik.FirstName,
         LastName = ucenik.LastName,
         UserName = ucenik.UserName,
         Parent = ucenik.Roditelj,
         Grade = ucenik.Grade
     });
 }
Beispiel #8
0
        public void Edit(PupilDTO pupil)
        {
            if (pupil == null)
            {
                throw new ValidationException("Не установлено id класса", "");
            }
            var mapper = new MapperConfiguration(cfg => cfg.CreateMap <PupilDTO, Pupil>()).CreateMapper();
            var _pupil = mapper.Map <PupilDTO, Pupil>(pupil);

            Database.Pupils.Update(_pupil);
            Database.Save();
        }
Beispiel #9
0
 public PupilViewModel Map(PupilDTO pupil)
 {
     return(new PupilViewModel
     {
         Id = pupil.Id,
         Surname = pupil.Surname,
         Name = pupil.Name,
         SecondName = pupil.SecondName,
         Birthday = pupil.Birthday,
         Gender = pupil.Gender,
         //new GradeProp = pupil.GradeProp,
         GradePropId = pupil.GradePropId
     });
 }
Beispiel #10
0
        public IActionResult Get(int?Id)
        {
            if (Id != null)
            {
                PupilDTO              _pupil = pupilService.GetById(Id.Value);
                PupilViewModel        pupil  = Map(_pupil);
                List <PupilViewModel> pupils = new List <PupilViewModel> {
                    pupil
                };
                return(View("View", pupils));
            }

            return(NotFound());
        }
        public ActionResult <PupilDTO> AddPupil([FromBody] PupilDTO pupil, long classroomId)
        {
            try
            {
                ClassRoom cls = _classRooms.GetById(classroomId);
                Pupil     pup = new Pupil(pupil, classroomId);
                cls.addPupil(pup);

                _classRooms.SaveChanges();

                return(new PupilDTO(pup));
            }
            catch (ArgumentNullException)
            {
                return(NotFound(new CustomErrorDTO("klas niet gevonden")));
            }
        }
Beispiel #12
0
        public ActionResult <PupilDTO> AddPupil([FromBody] PupilDTO dto, long schoolId)
        {
            try
            {
                School s = _schools.GetById(schoolId);
                Pupil  p = new Pupil(dto, schoolId);

                s.AddPupil(p);
                _schools.SaveChanges();

                return(new PupilDTO(p));
            }
            catch (ArgumentNullException)
            {
                return(NotFound(new CustomErrorDTO("School niet gevonden")));
            }
        }
        public ActionResult <PupilDTO> RemovePupil([FromBody] PupilDTO pupil, long classroomId)
        {
            try
            {
                ClassRoom cls = _classRooms.GetById(classroomId);
                Pupil     pup = cls.getPupilFromDto(pupil);
                cls.removePupil(pup);

                _classRooms.SaveChanges();

                return(new PupilDTO(pup));
            }
            catch (ArgumentNullException)
            {
                return(NotFound(new CustomErrorDTO("Leerling niet gevonden")));
            }
        }
        public ActionResult <PupilDTO> Put([FromBody] PupilDTO dto, long pupilId)
        {
            try
            {
                var p = _pupils.GetById(pupilId);

                p.FirstName = dto.FirstName;
                p.Surname   = dto.Surname;

                _pupils.SaveChanges();

                return(new PupilDTO(p));
            }
            catch (ArgumentNullException)
            {
                return(NotFound(new CustomErrorDTO("Leerling niet gevonden")));
            }
        }
        private List <SourceOfAllocation> GetSourceOfAllocations(PupilDTO pupil, string allocationYear)
        {
            var year        = int.Parse(allocationYear);
            var allocations = new List <SourceOfAllocation>();

            if (string.IsNullOrEmpty(pupil.SRC_LAESTAB_0) && string.IsNullOrEmpty(pupil.SRC_LAESTAB_1) &&
                string.IsNullOrEmpty(pupil.SRC_LAESTAB_2))
            {
                return(allocations);
            }

            if (pupil.Attendance_year_0 && pupil.DFESNumber == pupil.Core_Provider_0)
            {
                allocations.Add(new SourceOfAllocation(year--, pupil.SRC_LAESTAB_0.ToAllocation()));
            }
            else
            {
                allocations.Add(new SourceOfAllocation(year--,
                                                       string.IsNullOrEmpty(pupil.Core_Provider_0) ? Allocation.Unknown : Allocation.NotAllocated));
            }

            if (pupil.Attendance_year_1 && pupil.DFESNumber == pupil.Core_Provider_1)
            {
                allocations.Add(new SourceOfAllocation(year--, pupil.SRC_LAESTAB_1.ToAllocation()));
            }
            else
            {
                allocations.Add(new SourceOfAllocation(year--,
                                                       string.IsNullOrEmpty(pupil.Core_Provider_1) ? Allocation.Unknown : Allocation.NotAllocated));
            }

            if (pupil.Attendance_year_2 && pupil.DFESNumber == pupil.Core_Provider_2)
            {
                allocations.Add(new SourceOfAllocation(year--, pupil.SRC_LAESTAB_2.ToAllocation()));
            }
            else
            {
                allocations.Add(new SourceOfAllocation(year--,
                                                       string.IsNullOrEmpty(pupil.Core_Provider_2) ? Allocation.Unknown : Allocation.NotAllocated));
            }

            return(allocations);
        }
      public IHttpActionResult PutPupil(string id, [FromBody] PupilDTO pupil)
      {
          if (!ModelState.IsValid)
          {
              return(BadRequest(ModelState));
          }
          if (id != pupil.PupilId)
          {
              return(BadRequest());
          }

          Pupil savedPupil = pupilService.Update(pupil);

          if (savedPupil == null)
          {
              return(NotFound());
          }
          return(StatusCode(HttpStatusCode.NoContent));
      }
 public Pupil getPupilFromDto(PupilDTO pupil)
 {
     return(Pupils.FirstOrDefault(p => p.FirstName == pupil.FirstName && p.Surname == pupil.Surname));
 }
        private Pupil GetPupil(CheckingWindow checkingWindow, PupilDTO pupil, string allocationYear)
        {
            var sen       = _dataService.GetSENStatus().SingleOrDefault(x => x.Code == pupil.SENStatusCode);
            var pincl     = _dataService.GetPINCLs().SingleOrDefault(x => x.Code == pupil.P_INCL);
            var ethnicity = _dataService.GetEthnicities().SingleOrDefault(x => x.Code == pupil.EthnicityCode);
            var language  = _dataService.GetLanguages().SingleOrDefault(x => x.Code == pupil.FirstLanguageCode);
            var school    = _schoolService.GetByDFESNumber(checkingWindow, pupil.DFESNumber);

            var newPupil = new Pupil
            {
                Id            = pupil.id,
                URN           = pupil.URN,
                UPN           = pupil.UPN,
                ULN           = pupil.ULN,
                DfesNumber    = pupil.DFESNumber,
                Forename      = pupil.Forename,
                Surname       = pupil.Surname,
                DOB           = GetDateTime(pupil.DOB),
                Age           = pupil.Age ?? 0,
                Gender        = Gender.FromCode(pupil.Gender),
                AdmissionDate = pupil.ENTRYDAT != null?GetDateTime(pupil.ENTRYDAT.ToString()) : null as DateTime?,
                                    YearGroup = pupil.ActualYearGroup,
                                    Results   = pupil.performance?.Select(p => new Result
                {
                    SubjectCode           = p.SubjectCode,
                    ExamYear              = p.ExamYear,
                    TestMark              = p.TestMark,
                    ScaledScore           = p.ScaledScore,
                    QualificationTypeCode = p.QualificationTypeCode,
                    ExamDate              = GetDateTime(p.Exam_Date),
                    ExamNumber            = p.ExamNumber,
                    FineGrade             = p.FineGrade,
                    GradeCode             = p.GradeCode,
                    MatchReg              = p.MATCHREG,
                    RIncl                = p.R_INCL,
                    SeasonCode           = p.SeasonCode,
                    TierCode             = p.TierCode,
                    AwardingBodyNumber   = p.AwardingBodyNumber,
                    BoardSubjectNumber   = p.BoardSubjectNumber,
                    NationalCentreNumber = p.NationalCentreNumber,
                    QAN              = p.QAN,
                    SubLevelCode     = p.SubLevelCode,
                    PortlandResultID = p.PortlandResultID,
                }).ToList() ?? new List <Result>(Enumerable.Empty <Result>()),
                                    Allocations               = GetSourceOfAllocations(pupil, allocationYear),
                                    LookedAfterEver           = pupil.LookedAfterEver == 1,
                                    School                    = school,
                                    FreeSchoolMealsLast6Years = pupil.FSM6 == 1,
                                    PortlandStudentID         = pupil.PortlandStudentID
            };

            if (sen != null)
            {
                newPupil.SpecialEducationNeed = sen;
            }
            if (ethnicity != null)
            {
                newPupil.Ethnicity = ethnicity;
            }
            if (language != null)
            {
                newPupil.FirstLanguage = language;
            }
            if (ethnicity != null)
            {
                newPupil.Ethnicity = ethnicity;
            }
            if (pincl != null)
            {
                newPupil.PINCL = pincl;
            }

            if (pupil.ForvusIndex != null)
            {
                int.TryParse(pupil.ForvusIndex, out int forvusIndex);
                newPupil.ForvusIndex = forvusIndex;
            }

            return(newPupil);
        }
Beispiel #19
0
 public void UpdatePupil(PupilDTO pupil)
 {
     Database.Pupils.Update(Map(pupil));
 }
Beispiel #20
0
 public void CreatePupil(PupilDTO pupil)
 {
     Database.Pupils.Create(Map(pupil));
 }