public ActionResult ReadTuteur(Guid id)
        {
            TuteurModels model;

            using (TuteurRepository repository = new TuteurRepository())
            {
                Tutors x = repository.GetTutorById(id);
                IQueryable <Pupils> l = repository.GetPupilsById(id);
                if (x == null)
                {
                    return(HttpNotFound());
                }
                model = new TuteurModels
                {
                    id        = x.Id,
                    firstName = x.FirstName,
                    lastName  = x.LastName,
                    mail      = x.Mail,
                    postCode  = x.PostCode,
                    comment   = x.Comment,
                    town      = x.Town,
                    tel       = x.Tel,
                    address   = x.Address,
                    pupils    = getListEleves(l)
                };
            }
            return(View(model));
        }
        public ActionResult DeleteTuteur(Guid id)
        {
            TuteurModels model;

            using (TuteurRepository repository = new TuteurRepository())
            {
                Tutors x = repository.GetTutorById(id);
                if (x == null)
                {
                    return(HttpNotFound());
                }
                model = new TuteurModels
                {
                    id        = x.Id,
                    firstName = x.FirstName,
                    lastName  = x.LastName,
                    mail      = x.Mail,
                    postCode  = x.PostCode,
                    comment   = x.Comment,
                    town      = x.Town,
                    tel       = x.Tel,
                    address   = x.Address,
                    // eleves =
                };
            }


            return(View("DeleteTuteur", model));
        }
        public ActionResult CreateTuteur(TuteurModels model)
        {
            if (ModelState.IsValid)
            {
                using (TuteurRepository repository = new TuteurRepository())
                {
                    Tutors a = new Tutors
                    {
                        Id        = Guid.NewGuid(),
                        FirstName = model.firstName,
                        LastName  = model.lastName,
                        Mail      = model.mail,
                        PostCode  = model.postCode,
                        Comment   = model.comment,
                        Town      = model.town,
                        Tel       = model.tel,
                        Address   = model.address,
                        // eleves =
                    };

                    repository.Add(a);
                    repository.Save();
                }
                return(RedirectToAction("ReadTuteurs"));
            }
            return(View(model));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FullName,Adress,Login,Password,CardNumber,Language,Grade,Level")] Tutors tutors)
        {
            if (id != tutors.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tutors);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TutorsExists(tutors.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tutors));
        }
Ejemplo n.º 5
0
        private void TutorBuilder(ClientInformationDto payload)
        {
            var tutors = payload.Demographic.Tutors.ToArray();

            if (tutors.Length > 0)
            {
                if (tutors[0].Id != null)
                {
                    var tutor = _context.Tutors.FirstOrDefault(t => t.Id == tutors[0].Id);
                    if (!String.IsNullOrEmpty(tutors[0].Phone))
                    {
                        tutor.Name     = tutors[0].Name;
                        tutor.LastName = tutors[0].LastName;
                        tutor.Phone    = tutors[0].Phone;
                        _context.Tutors.Update(tutor);
                    }
                    else
                    {
                        _context.Tutors.Remove(tutor);
                    }
                }
                else
                {
                    if (!String.IsNullOrEmpty(tutors[0].Phone))
                    {
                        var newTutor = new Tutors();
                        newTutor.ClientId = payload.Demographic.Id.GetValueOrDefault();
                        newTutor.Name     = tutors[0].Name;
                        newTutor.LastName = tutors[0].LastName;
                        newTutor.Phone    = tutors[0].Phone;
                        _context.Tutors.Add(newTutor);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public ActionResult AddOrUpdate(TutorModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var isCreated = model.Id == Guid.Empty;
            var tutor     = new Tutors();

            if (!isCreated)
            {
                tutor = TutorRepository.GetById(model.Id);
            }

            tutor.Address   = model.Address;
            tutor.Comment   = model.Comment;
            tutor.FirstName = model.FirstName;
            tutor.LastName  = model.LastName;
            tutor.Mail      = model.Mail;
            tutor.PostCode  = model.PostCode;
            tutor.Tel       = model.Tel;
            tutor.Town      = model.Town;

            if (isCreated)
            {
                TutorRepository.Add(tutor);
            }
            TutorRepository.Save();

            return(Redirect(Url.Action("Get", "Tutor", new { id = tutor.Id })));
        }
Ejemplo n.º 7
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            Tutors tutors = tutorsRepository.GetById(id);

            tutorsRepository.Remove(tutors);
            tutorsRepository.Save();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
        public async Task <Tutors> CreateTutorsAsync(Tutors _tutor)
        {
            _tutor.CreatedDate = DateTime.Now;
            _dbContext.Tutors.Add(_tutor);
            await _dbContext.SaveChangesAsync();

            return(_tutor);
        }
Ejemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "Id,LastName,FirstName,Address,PostCode,Town,Tel,Mail,Comment")] Tutors tutors)
 {
     if (ModelState.IsValid)
     {
         tutorsRepository.SetEntryState(tutors, EntityState.Modified);
         tutorsRepository.Save();
         return(RedirectToAction("Index"));
     }
     return(View(tutors));
 }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("Id,FullName,Adress,Login,Password,CardNumber,Language,Grade,Level")] Tutors tutors)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tutors);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tutors));
        }
Ejemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "Id,LastName,FirstName,Address,PostCode,Town,Tel,Mail,Comment")] Tutors tutors)
 {
     if (ModelState.IsValid)
     {
         _tutorRepository.UpdateTutor(tutors);
         _tutorRepository.Save();
         //db.Entry(tutors).State = EntityState.Modified;
         //db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tutors));
 }
Ejemplo n.º 12
0
 public TutorModel Create(Tutors tutor)
 {
     return(new TutorModel()
     {
         Id = tutor.Id,
         Email = tutor.Email,
         UserName = tutor.UserName,
         FirstName = tutor.FirstName,
         LastName = tutor.LastName,
         Gender = tutor.Gender
     });
 }
Ejemplo n.º 13
0
        public ActionResult Create([Bind(Include = "Id,LastName,FirstName,Address,PostCode,Town,Tel,Mail,Comment")] Tutors tutors)
        {
            if (ModelState.IsValid)
            {
                tutors.Id = Guid.NewGuid();
                tutorsRepository.Add(tutors);
                tutorsRepository.Save();
                return(RedirectToAction("Index"));
            }

            return(View(tutors));
        }
Ejemplo n.º 14
0
        public ActionResult Details(string Id)
        {
            Tutors tutors = context.Find(Id);

            if (tutors == null)
            {
                return(HttpNotFound());
            }
            else
            {
                return(View(tutors));
            }
        }
Ejemplo n.º 15
0
        public List <ph_tutors> Tutor(int id)
        {
            List <ph_tutors> result = new List <ph_tutors>();

            if (id != 0)
            {
                var tutor = Tutors.GetAll();
                var ph    = Ph_Assigments.GetAll();
                var query = ph.FirstOrDefault(f => f.id_person == id);
                result = tutor.Where(f => query != null && f.id_phdAssignment == query.id_phdAssignment).ToList();
            }
            return(result);
        }
Ejemplo n.º 16
0
        public async Task <Tutors> UpdateTutorAsync(Tutors tutor)
        {
            var _tutor = await _dbContext.Tutors.Where(x => x.Id == tutor.Id).FirstOrDefaultAsync();

            _tutor.Experience = tutor.Experience;
            //GradeLevel = tutor.GradeLevel,
            _tutor.NameOfSchool = tutor.GradeLevel;
            //Concerns
            _tutor.PreviousSubjects = tutor.PreviousSubjects;
            _tutor.UpdatedDate      = DateTime.Now;
            await _dbContext.SaveChangesAsync();

            return(_tutor);
        }
Ejemplo n.º 17
0
        public ActionResult Create(Tutors tutor)
        {
            if (!ModelState.IsValid)
            {
                return(View(tutor));
            }
            else
            {
                context.Insert(tutor);
                context.Commit();

                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 18
0
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tutors tutors = tutorsRepository.GetById(id);

            if (tutors == null)
            {
                return(HttpNotFound());
            }
            return(View(tutors));
        }
Ejemplo n.º 19
0
        public void AddTutor(String ssn, String firstName, String lastName, String email, String password)
        {
            try
            {
                Tutor temp = new Tutor(ssn, firstName, lastName, email, password);
                dal.AddTutor(temp);
                Tutors.Add(temp);

                Status = temp.FullName + " was added to tutors!";
            }
            catch (Exception ex)
            {
                Status = ExceptionHandler.GetErrorMessage(ex);
            }
        }
Ejemplo n.º 20
0
        // GET: Tutors/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tutors tutors = _tutorRepository.GetTutorByID(id);

            //Tutors tutors = db.Tutors.Find(id);
            if (tutors == null)
            {
                return(HttpNotFound());
            }
            return(View(tutors));
        }
Ejemplo n.º 21
0
        public void DeleteTutor(String ssn)
        {
            try
            {
                Tutor temp = new Tutor();
                temp.Ssn = ssn;

                dal.DeleteTutor(temp);
                Tutors.Remove(temp);

                //Tutors = new ObservableCollection<Tutor>(dal.GetAllTutors());
                NotifyPropertyChanged("Tutors");
            }
            catch (Exception ex)
            {
                Status = ExceptionHandler.GetErrorMessage(ex);
            }
        }
Ejemplo n.º 22
0
 public static TutorModel ToModel(Tutors tutors)
 {
     return(new TutorModel
     {
         Id = tutors.Id,
         FirstName = tutors.FirstName,
         LastName = tutors.LastName,
         Address = tutors.Address,
         Comment = tutors.Comment,
         Mail = tutors.Mail,
         PostCode = tutors.PostCode,
         Tel = tutors.Tel,
         Town = tutors.Town,
         Pupils = tutors.Pupils.Select(p => new ModelWithNameAndId
         {
             Id = p.Id,
             Name = p.FirstName + " " + p.LastName
         })
     });
 }
        public ActionResult EditTuteur(TuteurModels model)
        {
            using (TuteurRepository repository = new TuteurRepository())
            {
                Tutors x = repository.GetTutorById(model.id);
                x.FirstName = model.firstName;
                x.LastName  = model.lastName;
                x.Mail      = model.mail;
                x.PostCode  = model.postCode;
                x.Comment   = model.comment;
                x.Town      = model.town;
                x.Tel       = model.tel;
                x.Address   = model.address;
                // eleves =

                if (ModelState.IsValid)
                {
                    repository.Save();
                }
                return(RedirectToAction("ReadTuteurs"));
            }
        }
Ejemplo n.º 24
0
        public ActionResult Create()
        {
            Tutors tutor = new Tutors();

            return(View(tutor));
        }
Ejemplo n.º 25
0
 public void SetEntryState(Tutors tutors, EntityState entityState)
 {
     db.Entry(tutors).State = entityState;
 }
Ejemplo n.º 26
0
 public void Remove(Tutors tutors)
 {
     db.Tutors.Remove(tutors);
 }
Ejemplo n.º 27
0
 public void Add(Tutors tutors)
 {
     db.Tutors.Add(tutors);
 }
Ejemplo n.º 28
0
        public void Seed()
        {
            if (_ctx.Courses.Count() > 0)
            {
                return;
            }

            try
            {
                foreach (var subjectName in subjects)
                {
                    var subject = new Subjects
                    {
                        Name = subjectName
                    };
                    _ctx.Subjects.Add(subject);
                    _ctx.SaveChanges();
                }

                for (int i = 0; i < tutorNames.Length; i++)
                {
                    var nameGenderMail = SplitValue(tutorNames[i]);
                    var tutor          = new Tutors
                    {
                        Email     = String.Format("{0}.{1}@{2}", nameGenderMail[0], nameGenderMail[1], nameGenderMail[3]),
                        UserName  = String.Format("{0}{1}", nameGenderMail[0], nameGenderMail[1]),
                        Password  = RandomString(8),
                        FirstName = nameGenderMail[0],
                        LastName  = nameGenderMail[1],
                        Gender    = ((Enums.Gender)Enum.Parse(typeof(Enums.Gender), nameGenderMail[2]))
                    };

                    _ctx.Tutors.Add(tutor);

                    var courseSubject = _ctx.Subjects.Where(s => s.Id == i + 1).Single();

                    foreach (var CourseDataItem in CoursesSeedData.Where(c => c.SubjectID == courseSubject.Id))
                    {
                        var course = new Courses
                        {
                            Name          = CourseDataItem.CourseName,
                            CourseSubject = courseSubject,
                            CourseTutor   = tutor,
                            Duration      = new Random().Next(3, 6),
                            Description   = String.Format("The course will talk in depth about: {0}", CourseDataItem.CourseName)
                        };
                        _ctx.Courses.Add(course);
                        Debug.WriteLine("Course Eklendi.\n");
                    }
                }

                _ctx.SaveChanges();

                for (int i = 0; i < studentNames.Length; i++)
                {
                    var nameGenderMail = SplitValue(studentNames[i]);
                    var student        = new Students()
                    {
                        Email            = String.Format("{0}.{1}@{2}", nameGenderMail[0], nameGenderMail[1], nameGenderMail[3]),
                        UserName         = String.Format("{0}{1}", nameGenderMail[0], nameGenderMail[1]),
                        Password         = RandomString(8),
                        FirstName        = nameGenderMail[0],
                        LastName         = nameGenderMail[1],
                        Gender           = ((Enums.Gender)Enum.Parse(typeof(Enums.Gender), nameGenderMail[2])),
                        DateofBirth      = DateTime.UtcNow.AddDays(-new Random().Next(7000, 8000)),
                        RegistrationDate = DateTime.UtcNow.AddDays(-new Random().Next(365, 730))
                    };
                    Debug.WriteLine(student.FirstName + " " + student.LastName + "");

                    _ctx.Students.Add(student);

                    int maxCoursesId = _ctx.Courses.Max(c => c.Id);

                    //To enroll in 4 courses randomly
                    for (int z = 0; z < 4; z++)
                    {
                        int randomCourseId = new Random().Next(1, maxCoursesId);

                        var enrollment = new Enrollments
                        {
                            Student        = student,
                            Course         = _ctx.Courses.Where(c => c.Id == randomCourseId).Single(),
                            EnrollmentDate = DateTime.UtcNow.AddDays(-new Random().Next(10, 30))
                        };
                        _ctx.Enrollments.Add(enrollment);
                    }
                }
                _ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                string message = ex.ToString();
                throw ex;
            }
        }
Ejemplo n.º 29
0
 public TutorStats(Tutors tutor, int numberOfClasses, int numberOfStudents)
 {
     Tutor            = tutor;
     NumberOfClasses  = numberOfClasses;
     NumberOfStudents = numberOfStudents;
 }
 public void Delete(Tutors s)
 {
     data.Tutors.Remove(s);
 }