public bool AddAdvertisement(string AdvertisementHeader, string AdvertisementBody, string AdvertisementYear, int CourseID, string Author)
        {
            var advertisement = new Advertisement();
            advertisement.AdvertisementID = 1;
            advertisement.AdvertisementHeader = AdvertisementHeader;
            advertisement.AdvertisementBody = AdvertisementBody;
            advertisement.AdvertisementYear = int.Parse(AdvertisementYear);
            advertisement.CourseID = CourseID;
            advertisement.Author = Author;
            advertisement.AdvertisementDateTime = DateTime.Now;

            using (CourseContext _db = new CourseContext())
            {
                // add to course

                var course = (from c in _db.Courses
                               where c.CourseID.Equals(CourseID)
                               select c).First();

                course.Advertisements.Add(advertisement);

                // Add Courses to DB.
                _db.Advertisements.Add(advertisement);
                _db.SaveChanges();
            }
            // Success.
            return true;
        }
Esempio n. 2
0
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            var manager = new UserManager();
            var user = new ApplicationUser() { UserName = UserName.Text };
            IdentityResult result = manager.Create(user, Password.Text);
            if (result.Succeeded)
            {

                result = manager.AddToRole(user.Id, "Student");

                var std = new Student();
                std.FirstName = FirstName.Text;
                std.LastName = lastName.Text;
                std.UserId = user.Id;
                std.BirthDate = DateTime.Now;

                CourseContext cc = new CourseContext();
                cc.Students.Add(std);
                cc.SaveChanges();

                IdentityHelper.SignIn(manager, user, isPersistent: false);
                IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);

            }
            else
            {
                ErrorMessage.Text = result.Errors.FirstOrDefault();
            }
        }
Esempio n. 3
0
        public void GetPosts()
        {
            Project project = projects.ElementAt(1);

            CourseContext cc = new CourseContext();
            var posts = from p in cc.Posts
                        where p.
        }
Esempio n. 4
0
 public IQueryable<Team> GetTeams()
 {
     string user = HttpContext.Current.User.Identity.GetUserId();
     CourseContext cc = new CourseContext();
     var student = (from s in cc.Students
                   where s.UserId.Equals(user)
                   select s).First();
     return student.Teams.AsQueryable();
 }
Esempio n. 5
0
        public IQueryable<Project> getProjects()
        {
            CourseContext cc = new CourseContext();

            var query = from p in cc.Projects
                        select p;

            return query;
        }
        public IQueryable<Advertisement> GetAdvertisements()
        {
            CourseContext cc = new CourseContext();
            int academicYear = 1;

            if (string.IsNullOrWhiteSpace(Request.QueryString["aYear"]))
            {
                academicYear = 1;
            }
            else
            {
                academicYear = int.Parse(Request.QueryString["aYear"]);
            }

            if (academicYear == 1)
            {
                var query = from c in cc.Advertisements
                            where c.AdvertisementYear == 1
                            select c;

                return query;
            }
            else if (academicYear == 2)
            {
                var query = from c in cc.Advertisements
                            where c.AdvertisementYear == 2
                            select c;

                return query;
            }
            else if (academicYear == 3)
            {
                var query = from c in cc.Advertisements
                            where c.AdvertisementYear == 3
                            select c;

                return query;
            }
            else if (academicYear == 4)
            {
                var query = from c in cc.Advertisements
                            where c.AdvertisementYear == 4
                            select c;

                return query;
            }
            else
            {
                var query = from c in cc.Advertisements
                            where c.AdvertisementYear == 5
                            select c;

                return query;
            }
            return null;
        }
Esempio n. 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     int TeamId = int.Parse(Request.QueryString["TeamId"]);
     CourseContext cc = new CourseContext();
     var projectsquery = from p in cc.Projects
                 where p.TeamId.Equals(TeamId)
                 select p;
     ProjectsNum = projectsquery.ToList().Count;
     projects = projectsquery.ToList();
 }
Esempio n. 8
0
        public IQueryable<Homework> GetHomeworks()
        {
            int teamId = int.Parse(Request.QueryString["teamId"]);
            CourseContext cc = new CourseContext();

            var homeworks = from p in cc.Projects
                           join h in cc.Homeworks on p.HomId equals h.HomId
                           select h;
            return homeworks;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     int HomId = int.Parse(Request.QueryString["HomId"]);
     CourseContext cc= new CourseContext();
     var homework = (from c in cc.Homeworks
                 where c.HomId.Equals(HomId)
                 select c).First();
     HomworkNameLabel.Text = homework.HomeworkName ;
     HomworkDescLabel.Text = homework.HomeworkDesc;
     DueDateLabel.Text = "Due Date:"+ homework.DueDate.ToShortDateString();
 }
Esempio n. 10
0
        public bool AddPost(string PostText, string AuthorId)
        {
            var post = new Post();
            post.AuthorId = AuthorId;
            post.PostDate = DateTime.Now;
            post.PostText = PostText;

            using (CourseContext _db = new CourseContext())
            {
                // Add Courses to DB.
                _db.Posts.Add(post);
                _db.SaveChanges();
            }
            return true;
        }
Esempio n. 11
0
        public bool AddHomework(string HomeworkName , string HomeworkDecs, DateTime DueDate ,int CourseId )
        {
            var homework = new Homework();
            homework.CourseId = CourseId;
            homework.Date = DateTime.Now;
            homework.DueDate = DueDate;
            homework.HomeworkDesc = HomeworkDecs;
            homework.HomeworkName = HomeworkName;
            using (CourseContext _db = new CourseContext())
            {

                // Add Courses to DB.
                _db.Homeworks.Add(homework);
                _db.SaveChanges();
            }
            // Success.
            return true;
        }
Esempio n. 12
0
        public bool AddCourse(string CourseName, string CourseDesc, string CourseTeacher, string CourseYear, string CourseDep)
        {
            var myCourse = new Course();
            myCourse.CourseName = CourseName;
            myCourse.CourseDescription = CourseDesc;
             // alu
            myCourse.CourseYear = int.Parse(CourseYear);
            myCourse.CourseDepartement = CourseDep;

            using (CourseContext _db = new CourseContext())
            {
                // Add Courses to DB.
                _db.Courses.Add(myCourse);
                _db.SaveChanges();
            }
            // Success.
            return true;
        }
Esempio n. 13
0
        protected void AddQuestionButton_Click(object sender, EventArgs e)
        {
            int CourseId = int.Parse(Request.QueryString["CourseId"]);
            string userId = HttpContext.Current.User.Identity.GetUserId();
            CourseContext cc = new CourseContext();
            var student = from c in cc.Students
                        where c.UserId == userId
                        select c;
            using (CourseContext _db = new CourseContext())
            {
                var question = new Question();
                question.AuthorId = userId;
                question.CourseId= CourseId;
                question.QuesBody =  AddQuestionBody.Text;
                question.QuesHeader = AddQuestionHeader.Text;

                _db.Questions.Add(question);
                _db.SaveChanges();
            }
        }
Esempio n. 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string userId = User.Identity.GetUserId();

            using (CourseContext cc = new CourseContext())
            {
                 var std = (from s in cc.Students
                           where s.UserId == userId
                           select s).First();

                FirstName.Text = std.FirstName;
                LastName.Text = std.LastName;
                BirthDate.Text = std.BirthDate.ToShortDateString();
                Email.Text = std.Email;
                Departement.Text = std.Departement;
                ACMPoints.Text = std.ACMPoints.ToString();
                Bio.Text = std.Bio;

            }
        }
Esempio n. 15
0
        public bool AddComment(string CommText, int PostId, string AuthorId)
        {
            var comment = new Comment();
            comment.AuthorId = AuthorId;
            comment.CommDate = DateTime.Now;
            comment.CommText = CommText;
            comment.PostId = PostId;

            using (CourseContext _db = new CourseContext())
            {
                var post = (from p in _db.Posts
                               where  p.PostId.Equals(PostId)
                               select p).First();
                post.Comments.Add(comment);
                // Add Courses to DB.
                _db.Comments.Add(comment);
                _db.SaveChanges();
            }
            // Success.
            return true;
        }
Esempio n. 16
0
        protected void RemoveCourseButton_Click(object sender, EventArgs e)
        {
            using (var _db = new Project2.Models.CourseContext())
            {
                int courseId = Convert.ToInt16(DropDownRemoveCourse.SelectedValue);
                var myItem = (from c in _db.Courses where c.CourseID == courseId select c).FirstOrDefault();
                if (myItem != null)
                {
                    _db.Courses.Remove(myItem);
                    _db.SaveChanges();

                    // Reload the page.
                    string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
                    Response.Redirect(pageUrl + "?CourseAction=remove");
                }
                else
                {
                    LabelRemoveStatus.Text = "Unable to locate Course.";
                }
            }
        }
Esempio n. 17
0
        public bool AddCourse(string CourseName, string CourseDesc, string CourseTeacherFN,string CourseTeacherLN, string CourseYear, string CourseDep)
        {
            var myCourse = new Course();
            myCourse.CourseName = CourseName;
            myCourse.CourseDescription = CourseDesc;
            myCourse.CourseYear = int.Parse(CourseYear);
            myCourse.CourseDepartement = CourseDep;

            using (CourseContext _db = new CourseContext())
            {
                var teacher = (from t in _db.Teachers
                              where t.FirstName.Equals(CourseTeacherFN)&& t.LastName.Equals(CourseTeacherLN)
                              select t).First();
                myCourse.Teachers.Add(teacher);
                teacher.Courses.Add(myCourse);
                // Add Courses to DB.
                _db.Courses.Add(myCourse);
                _db.SaveChanges();
            }
            // Success.
            return true;
        }
Esempio n. 18
0
        protected void FollowButton_OnClick(object sender, EventArgs e)
        {
            CourseContext cc = new CourseContext();

            string userId = Context.User.Identity.GetUserId();

            var query = from s in cc.Students
                where s.UserId == userId
                select s;

            var query2 = from c in cc.Courses
                where c.CourseName == courseName.Text
                select c;

            foreach (var std in query)
            {
                foreach (var cou in query2)
                {
                    std.Courses.Add(cou);
                }
            }

            cc.SaveChanges();
        }
Esempio n. 19
0
 public IQueryable GetCourses()
 {
     var _db = new Project2.Models.CourseContext();
     IQueryable query = _db.Courses;
     return query;
 }