Example #1
0
        public ActionResult ContulMeu(string mail)
        {
            ResourcesRepository rr = new ResourcesRepository();
            var model = rr.GetUserByMail(mail);

            return(View(model));
        }
Example #2
0
        public ActionResult AdaugaPoza(HttpPostedFileBase file, string mail)
        {
            // Verify that the user selected a file
            if (file != null && file.ContentLength > 0)
            {
                // extract only the fielname
                var fileName = Path.GetFileName(file.FileName);
                //store the file in a new created folder
                //the new created folder bears the name of the logged in user = teacher
                var directoryPath = Server.MapPath("~/Content/Pictures/Profesori/" + mail);
                Directory.CreateDirectory(directoryPath);
                var path = Path.Combine(Server.MapPath("~/Content/Pictures/Profesori/" + mail), fileName);
                file.SaveAs(path);


                //update the user so that he now stores the picture
                string imageUrl = "~/Content/Pictures/Profesori/" + mail + "/" + fileName;

                var rr = new ResourcesRepository();
                rr.UpdateTeacher(mail, imageUrl);
                var user = rr.GetUserByMail(mail);
            }
            // redirect back to the index action to show the form once again
            return(RedirectToAction("Index", "Home"));
        }
Example #3
0
        public ActionResult PaginaProfesorului(string mail)
        {
            var rr   = new ResourcesRepository();
            var user = rr.GetUserByMail(mail);

            return(View(user));
        }
        public ActionResult PaginaElevului(string mail)
        {
            var rr           = new ResourcesRepository();
            var user         = rr.GetUserByMail(mail);
            var highschoolId = user.ScoalaDeProvenientaId;
            var highschool   = rr.GetHighSchoolById(highschoolId);

            return(View(highschool));
        }
Example #5
0
        public ActionResult SubmitToLesson(string materie, string mail)
        {
            var rr = new ResourcesRepository();

            var model = rr.GetUserByMail(mail);

            if (materie != null)
            {
                ViewData["materie"] = materie;

                return(View("../../Views/AddLesson/AddLesson", model));
            }
            else
            {
                return(View("../../Views/Cont/ContulMeu", model));
            }
        }
Example #6
0
 public ActionResult CautaUtilizator(string mail)
 {
     if (ModelState.IsValid)
     {
         ResourcesRepository rr = new ResourcesRepository();
         User          user     = rr.GetUserByMail(mail);
         UserInfoModel newUim   = new UserInfoModel();
         newUim.Nume    = user.Nume;
         newUim.Prenume = user.Prenume;
         newUim.Mail    = user.Mail;
         newUim.Parola  = user.Parola;
         //TODO change the schoolName
         newUim.ScoalaDeProvenienta = "Liceu1";
         return(View(newUim));
     }
     return(View());
 }
        public ActionResult AddLesson(HttpPostedFileBase file, string mail, string materie)
        {
            var rr = new ResourcesRepository();

            // Verify that the user selected a file
            if (file != null && file.ContentLength > 0)
            {
                ViewData["fileUp"] = null;
                // extract only the fielname
                var fileName = Path.GetFileName(file.FileName);
                // store the file inside ~/App_Data/uploads folder
                var subPath = "~/App_Data/uploads/" + mail;

                bool IsExists = System.IO.Directory.Exists(Server.MapPath(subPath));

                if (!IsExists)
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath(subPath));
                }

                var subPath2 = "~/App_Data/uploads/" + mail + "/" + materie;

                bool IsExists2 = System.IO.Directory.Exists(Server.MapPath(subPath2));

                if (!IsExists2)
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath(subPath2));
                }

                var path = Path.Combine(Server.MapPath("~/App_Data/uploads/"), mail + "/", materie, fileName);
                file.SaveAs(path);


                using (var db = new EducatieIncluzivaDBContext())
                {
                    var myTeacher = db.Teachers.SingleOrDefault(item => item.Mail == mail);
                    var curs      = from p in db.Courses
                                    where p.Nume.Equals(materie) && p.ProfesorId == myTeacher.UserId
                                    select p;

                    /*  Course cur = new Course();
                     * cur.Nume = materie;
                     * cur.ProfesorId = myTeacher.UserId;
                     */
                    Lesson l = new Lesson();
                    l.ProfesorOwner   = myTeacher;
                    l.ProfesorOwnerId = myTeacher.UserId;
                    l.Titlu           = fileName;

                    foreach (var c in curs)
                    {
                        c.Lectii.Add(l);
                        break;
                    }

                    /*  if (myTeacher.Materii != null)
                     * {
                     *    if (myTeacher.Materii.Contains(cur))
                     *    {
                     *        db.Lessons.Add(l);
                     *    }
                     *    else
                     *    {
                     *        Console.WriteLine("Nu exista");
                     *    }
                     * }
                     * else
                     * {
                     *    Console.WriteLine("e NULL");
                     * }
                     * /*
                     * if (myTeacher.Materii[0].Nume.Equals(materie))
                     * {
                     *    nr = 0;
                     * }
                     * else if (myTeacher.Materii[1].Nume.Equals(materie))
                     * {
                     *    nr = 1;
                     * }
                     * else
                     * {
                     *    nr = 2;
                     * }
                     * myTeacher.Materii[nr].Lectii.Add(l);
                     */
                    DbEntityEntry <Teacher> entry = db.Entry(myTeacher);
                    entry.State = EntityState.Modified;

                    db.SaveChanges();

                    ViewData["fileUp"]  = "incarcat";
                    ViewData["materie"] = materie;
                }
            }

            var model = rr.GetUserByMail(mail);

            // redirect back to the index action to show the form once again
            return(View("../../Views/AddLesson/AddLesson", model));
        }
Example #8
0
        public ActionResult Update(FormCollection te, string mail)
        {
            var rr    = new ResourcesRepository();
            var model = rr.GetUserByMail(mail);

            if (te.GetValue("teach.Nume").AttemptedValue.Equals("") ||
                te.GetValue("teach.Prenume").AttemptedValue.Equals("") ||
                te.GetValue("teach.Description").AttemptedValue.Equals(""))
            {
                TempData["alertMessage"] = "The user has to be alerted";
                return(View("../../Views/Cont/ContulMeu", model));
            }
            else
            {
                TempData["alertMessage"] = null;
                string numeCurs1 = te.GetValue("teach.Materii[0]").AttemptedValue;
                string numeCurs2 = te.GetValue("teach.Materii[1]").AttemptedValue;
                string numeCurs3 = te.GetValue("teach.Materii[2]").AttemptedValue;

                string nume        = te.GetValue("teach.Nume").AttemptedValue;
                string prenume     = te.GetValue("teach.Prenume").AttemptedValue;
                string description = te.GetValue("teach.Description").AttemptedValue;

                int    index = 0;
                string c1, c2, c3;
                c1 = "";
                c2 = "";
                c3 = "";

                using (var db = new EducatieIncluzivaDBContext())
                {
                    var curs = from p in db.Courses
                               where p.ProfesorId == model.UserId
                               select p;

                    foreach (var c in curs)
                    {
                        if (index == 0)
                        {
                            c1 = c.Nume;
                        }
                        else if (index == 1)
                        {
                            c2 = c.Nume;
                        }
                        else if (index == 2)
                        {
                            c3 = c.Nume;
                        }
                        index++;
                    }
                }
                //     if (c1.Equals("") || c2.Equals("") || c3.Equals(""))
                //      {
                if (!numeCurs1.Equals(""))// && c1.Equals(""))
                {
                    rr.UpdateTeacher(nume, prenume, mail, description,
                                     c1, numeCurs1);
                }
                if (!numeCurs2.Equals(""))//&& c2.Equals(""))
                {
                    rr.UpdateTeacher(nume, prenume, mail, description,
                                     c2, numeCurs2);
                }
                if (!numeCurs3.Equals(""))// && c3.Equals(""))
                {
                    rr.UpdateTeacher(nume, prenume, mail, description,
                                     c3, numeCurs3);
                }
                //    }

                /*                 else
                 *             {
                 *           if (numeCurs2.Equals(""))
                 *           {
                 *               rr.UpdateTeacher(nume, prenume, mail, description,
                 *                             c1,numeCurs1);
                 *           }
                 *           else if (numeCurs3.Equals(""))
                 *           {
                 *               rr.UpdateTeacher(nume, prenume, mail, description,
                 *                              c1, c2,
                 *                            numeCurs1, numeCurs2);
                 *           }
                 *           else
                 *           {
                 *               rr.UpdateTeacher(nume, prenume, mail, description,
                 *                                 c1,c2, c3,
                 *                                numeCurs1, numeCurs2, numeCurs3);
                 *           }
                 *           }*/
                return(View("../../Views/Cont/ContulMeu", model));
            }
        }