public IHttpActionResult PutParent(string id, ParentInfoDTO parent)
 {
     if (parentsService.ExistsID(id) == false)
     {
         return(NotFound());
     }
     return(Ok(parentsService.PutParent(id, parent)));
 }
        public ParentInfoDTO MakeParentInfoDTO(ParentModel parentModel)
        {
            ParentInfoDTO parent = new ParentInfoDTO(parentModel.Id, parentModel.FirstName, parentModel.LastName, parentModel.UserName, parentModel.Email, parentModel.PhoneNumber);

            foreach (StudentModel sm in parentModel.Students)
            {
                parent.StudentsWithSubjectsAndGrades.Add(studentsService.MakeStudentInfoDTO(sm));
            }

            return(parent);
        }
        public ParentInfoDTO PutParent(string id, ParentInfoDTO parent)
        {
            ParentModel parentFromDB = db.ParentsRepository.GetByID(id);

            parentFromDB.FirstName   = parent.FirstName;
            parentFromDB.LastName    = parent.LastName;
            parentFromDB.UserName    = parent.UserName;
            parentFromDB.Email       = parent.Email;
            parentFromDB.PhoneNumber = parent.MobilePhone;

            db.ParentsRepository.Update(parentFromDB);
            db.Save();

            logger.Info($"Informations about parent with id: {parentFromDB.Id} were changed");

            return(MakeParentInfoDTO(parentFromDB));
        }