public ActionResult Login()
 {
     DLSInterface.ClassEntered = -1;
     ViewBag.Message           = "";
     DLSInterface.logout();
     return(View());
 }
        public ActionResult Create(PersonViewModels model)
        {
            try
            {
                SE_ProjectEntities db = new SE_ProjectEntities();

                if (db.TeacherTbls.Any(t => t.Email.Equals(model.email)) || db.StudentTbls.Any(t => t.Email.Equals(model.email)))
                {
                    ViewBag.Message = "Email Already Taken!";
                }
                else
                {
                    if (model.isTeacher)
                    {
                        TeacherTbl t = new TeacherTbl();
                        t.Name     = model.name;
                        t.Email    = model.email;
                        t.Password = model.password;
                        DLSInterface.loggedEmail = t.Email;
                        db.TeacherTbls.Add(t);
                        db.SaveChanges();
                        ViewBag.Message = "Success!";
                    }
                    else
                    {
                        StudentTbl s = new StudentTbl();
                        s.Name     = model.name;
                        s.Email    = model.email;
                        s.Password = model.password;
                        DLSInterface.loggedEmail = s.Email;
                        db.StudentTbls.Add(s);
                        db.SaveChanges();
                        ViewBag.Message = "Success!";
                    }
                }
                if (DLSInterface.loggedEmail != null)
                {
                    Profile first = new Profile();
                    first.Email                   = DLSInterface.loggedEmail;
                    first.Name                    = null;
                    first.ProfilePicture          = null;
                    first.PhoneNumber             = null;
                    first.DateOfBirth             = null;
                    first.RelationshipStatus      = null;
                    first.Designation             = null;
                    first.NumberOfClassesEnrolled = DLSInterface.getNumberofClassesEnrolled(first.Email);
                    first.PersonalInfo            = null;
                    first.Gender                  = null;
                    db.Profiles.Add(first);
                    db.SaveChanges();
                    return(RedirectToAction("ViewClass", "Class"));
                }
                return(View());
            }
            catch
            {
                return(View());
            }
        }
 // GET: Announcement/Create
 public ActionResult Create()
 {
     if (DLSInterface.isTeacher(DLSInterface.loggedEmail) == false)
     {
         RedirectToAction("Index");
     }
     return(View());
 }
        // GET: Profile/Delete/5
        public ActionResult Delete()
        {
            int id = DLSInterface.GetIdByEmail(DLSInterface.loggedEmail);
            SE_ProjectEntities db = new SE_ProjectEntities();

            foreach (Post p in db.Posts)
            {
                if (p.email == DLSInterface.loggedEmail)
                {
                    db.Posts.Remove(p);
                }
            }
            foreach (Profile my in db.Profiles)
            {
                if (my.Email == DLSInterface.loggedEmail)
                {
                    db.Profiles.Remove(my);
                    break;
                }
            }

            if (db.TeacherTbls.Find(id) != null && db.TeacherTbls.Find(id).Email == DLSInterface.loggedEmail)
            {
                db.TeacherTbls.Remove(db.TeacherTbls.Find(id));

                foreach (TeacherClassOTM totm in db.TeacherClassOTMs)
                {
                    if (totm.Teacher_Id == id)
                    {
                        db.TeacherClassOTMs.Remove(totm);
                    }
                }
            }
            else
            {
                foreach (StudentClassOTM t in db.StudentClassOTMs)
                {
                    if (t.Student_Id == id)
                    {
                        db.StudentClassOTMs.Remove(t);
                    }
                }
                db.StudentTbls.Remove(db.StudentTbls.Find(id));
            }
            db.SaveChanges();
            DLSInterface.logout();
            return(RedirectToAction("Create", "Person"));
        }
        // GET: Profile
        public ActionResult Index()
        {
            int id = DLSInterface.GetIdByEmail(DLSInterface.loggedEmail);

            if (DLSInterface.loggedEmail == null)
            {
                RedirectToAction("Login", "Person");
            }
            SE_ProjectEntities db = new SE_ProjectEntities();
            Profile            p  = new Profile();

            foreach (Profile k in db.Profiles)
            {
                if (k.Email == DLSInterface.loggedEmail)
                {
                    p.Email = k.Email;
                    p.Name  = k.Name;
                    p.id    = k.id;
                    p.NumberOfClassesEnrolled = k.NumberOfClassesEnrolled;
                    p.ProfilePicture          = k.ProfilePicture;
                    p.PhoneNumber             = k.PhoneNumber;
                    p.DateOfBirth             = k.DateOfBirth;
                    p.RelationshipStatus      = k.RelationshipStatus;
                    p.Designation             = k.Designation;
                    p.PersonalInfo            = k.PersonalInfo;
                    p.Gender = k.Gender;
                    break;
                }
            }
            ProfileEditViewModels display = new ProfileEditViewModels();

            display.id                      = p.id;
            display.Email                   = p.Email;
            display.ProfilePicture          = p.ProfilePicture;
            display.PhoneNumber             = p.PhoneNumber;
            display.DateOfBirth             = p.DateOfBirth;
            display.RelationshipStatus      = p.RelationshipStatus;
            display.NumberOfClassesEnrolled = DLSInterface.getNumberofClassesEnrolled(DLSInterface.loggedEmail);
            display.Designation             = p.Designation;
            display.PersonalInfo            = p.PersonalInfo;
            display.Gender                  = p.Gender;
            display.Name                    = p.Name;
            DLSInterface.Profileid          = display.id;
            return(View(display));
        }
 public ActionResult Create(AnnouncementViewModels collection)
 {
     try
     {
         // TODO: Add insert logic here
         Announcement a = new Announcement();
         a.ClassId   = DLSInterface.ClassEntered;
         a.TeacherId = DLSInterface.GetIdByEmail(DLSInterface.loggedEmail);
         a.Text      = collection.Text;
         SE_ProjectEntities db = new SE_ProjectEntities();
         db.Announcements.Add(a);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Example #7
0
        public ActionResult Create(HttpPostedFileBase uploadFile)
        {
            byte[] tempFile = new byte[uploadFile.ContentLength];
            uploadFile.InputStream.Read(tempFile, 0, uploadFile.ContentLength);
            SE_ProjectEntities db = new SE_ProjectEntities();
            MaterialResource   s  = new MaterialResource();

            s.Content   = tempFile;
            s.Name      = uploadFile.FileName;
            s.Length    = uploadFile.ContentLength;
            s.Type      = uploadFile.ContentType;
            s.TeacherId = DLSInterface.GetIdByEmail(DLSInterface.loggedEmail);
            s.Classid   = DLSInterface.ClassEntered;
            db.MaterialResources.Add(s);
            db.SaveChanges();


            return(RedirectToAction("Index"));
        }