}// Student Assignment Submission

        public ActionResult SaveCommentHead(int LessonID, string Title, string Body)
        {
            var id = User.Identity.GetUserId();
            AspnetComment_Head commentHead = new AspnetComment_Head();
            string             EncrID      = LessonID + Title + Body + id;

            commentHead.EncryptedID = Encrpt.Encrypt(EncrID, true);


            var newString = Regex.Replace(commentHead.EncryptedID, @"[^0-9a-zA-Z]+", "s");

            string str = newString.Substring(0, 32);


            commentHead.EncryptedID = str;

            //Comment_Head commentHead = new Comment_Head();
            commentHead.Comment_Head = Title;
            commentHead.CommentBody  = Body;
            commentHead.LessonId     = LessonID;
            commentHead.CreatedBy    = id;

            commentHead.CreationDate = GetLocalDateTime.GetLocalDateTimeFunction();
            db.AspnetComment_Head.Add(commentHead);
            db.SaveChanges();


            var UserId          = User.Identity.GetUserId();
            var UserName        = db.AspNetUsers.Where(x => x.Id == UserId).FirstOrDefault().Name;
            var NotificationObj = new AspNetNotification();

            NotificationObj.Description = UserName + " asked a Question";
            NotificationObj.Subject     = "Student Comment ";
            NotificationObj.SenderID    = UserId;
            NotificationObj.Time        = GetLocalDateTime.GetLocalDateTimeFunction();
            NotificationObj.Url         = "/TeacherCommentsOnCourses/CommentsPage1/" + commentHead.Id;

            db.AspNetNotifications.Add(NotificationObj);
            db.SaveChanges();


            int?TopicId   = db.AspnetLessons.Where(x => x.Id == LessonID).FirstOrDefault().TopicId;
            int?SubjectId = db.AspnetSubjectTopics.Where(x => x.Id == TopicId).FirstOrDefault().SubjectId;

            var AllTeachers = db.Teacher_GenericSubjects.Where(x => x.SubjectId == SubjectId).Select(x => x.TeacherId);

            var UnionTeachers = AllTeachers.Distinct();

            var AllEmployeesUserId = from employee in db.AspNetEmployees
                                     where AllTeachers.Contains(employee.Id)
                                     select new
            {
                employee.UserId,
            };



            SEA_DatabaseEntities db2 = new SEA_DatabaseEntities();

            foreach (var receiver in AllEmployeesUserId)
            {
                var notificationRecieve = new AspNetNotification_User();
                notificationRecieve.NotificationID = NotificationObj.Id;
                notificationRecieve.UserID         = Convert.ToString(receiver.UserId);
                notificationRecieve.Seen           = false;
                db2.AspNetNotification_User.Add(notificationRecieve);
                try
                {
                    db2.SaveChanges();
                }

                catch (Exception ex)
                {
                    var Msg = ex.Message;
                }
            }


            return(Json("", JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "Id,Title,Description,SubjectID,CourseType,NotesType,Price,CreationDate,Pages,PerPagePrice,photoCopierHidden")] AspNetNote aspNetNote)
        {
            if (aspNetNote.NotesType == "Notes")
            {
                aspNetNote.NotesType = Request.Form["NotesType"];

                aspNetNote.CourseType       = Request.Form["CourseType"];
                aspNetNote.Pages            = Convert.ToDouble(Request.Form["Pages"]);
                aspNetNote.PerPagePrice     = Convert.ToDouble(Request.Form["perPagePrice"]);
                aspNetNote.BindingPrice     = Convert.ToDouble(Request.Form["bindingPrice"]);
                aspNetNote.GrandTotal       = Convert.ToDouble(Request.Form["grandTotalHidden"]);
                aspNetNote.OAPrice          = Convert.ToDouble(Request.Form["oAHidden"]);
                aspNetNote.PhotoCopierPrice = Convert.ToDouble(Request.Form["photoCopierHidden"]);
                aspNetNote.CreationDate     = DateTime.Now;

                if (ModelState.IsValid)
                {
                    string EncrID = aspNetNote.Id + aspNetNote.SubjectID + aspNetNote.Price.ToString();
                    aspNetNote.EncryptedID = Encrpt.Encrypt(EncrID, true);
                    aspNetNote.EncryptedID.Replace('/', 's').Replace('-', 's').Replace('+', 's').Replace('%', 's').Replace('&', 's');

                    db.AspNetNotes.Add(aspNetNote);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            else if (aspNetNote.NotesType == "Books")
            {
                aspNetNote.NotesType        = Request.Form["NotesType"];
                aspNetNote.OABookPercentage = Convert.ToDouble(Request.Form["OABookPercentage"]);
                aspNetNote.BindingPrice     = Convert.ToDouble(Request.Form["bindingPrice"]);
                aspNetNote.OAPrice          = Convert.ToDouble(Request.Form["oAHidden"]);
                aspNetNote.PhotoCopierPrice = Convert.ToDouble(Request.Form["photoCopierHidden"]);
                aspNetNote.GrandTotal       = Convert.ToDouble(Request.Form["grandTotalHidden"]);

                aspNetNote.CourseType = Request.Form["CourseType"];

                string EncrID = aspNetNote.Id + aspNetNote.SubjectID + aspNetNote.Price.ToString();
                aspNetNote.EncryptedID = Encrpt.Encrypt(EncrID, true);


                var newString = Regex.Replace(aspNetNote.EncryptedID, @"[^0-9a-zA-Z]+", "s");

                // Lesson.EncryptedID.Replace('/', 's').Replace('-','s').Replace('+','s').Replace('%','s').Replace('&','s');
                aspNetNote.EncryptedID = newString;



                //   aspNetNote.EncryptedID.Replace('/', 's').Replace('-', 's').Replace('+', 's').Replace('%', 's').Replace('&', 's');



                aspNetNote.CreationDate = DateTime.Now;
                if (ModelState.IsValid)
                {
                    db.AspNetNotes.Add(aspNetNote);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            } //else if
            else
            {
                ModelState.AddModelError("NotesType", "Please Select Notes Type");
            }



            ViewBag.SubjectID = new SelectList(db.AspNetSubjects, "Id", "SubjectName", aspNetNote.SubjectID);
            return(View(aspNetNote));
        }
        public ActionResult Create(LessonViewModel LessonViewModel)
        {
            AspnetLesson Lesson = new AspnetLesson();

            Lesson.Name            = LessonViewModel.LessonName;
            Lesson.Video_Url       = LessonViewModel.LessonVideoURL;
            Lesson.TopicId         = LessonViewModel.TopicId;
            Lesson.DurationMinutes = LessonViewModel.LessonDuration;
            Lesson.IsActive        = LessonViewModel.IsActive;
            Lesson.CreationDate    = LessonViewModel.CreationDate;
            Lesson.Description     = LessonViewModel.LessonDescription;
            Lesson.OrderBy         = LessonViewModel.OrderBy;
            Lesson.CreationDate    = DateTime.Now;

            string EncrID = Lesson.Name + Lesson.Description + Lesson.Id;

            Lesson.EncryptedID = Encrpt.Encrypt(EncrID, true);


            var newString = Regex.Replace(Lesson.EncryptedID, @"[^0-9a-zA-Z]+", "s");

            // Lesson.EncryptedID.Replace('/', 's').Replace('-','s').Replace('+','s').Replace('%','s').Replace('&','s');

            Lesson.EncryptedID = newString;
            db.AspnetLessons.Add(Lesson);
            db.SaveChanges();



            //Lesson_Session lessonSession = new Lesson_Session();
            //lessonSession.LessonId = Lesson.Id;
            //lessonSession.SessionId = LessonViewModel.SessionId;
            //lessonSession.StartDate = LessonViewModel.StartDate;
            //lessonSession.DueDate = LessonViewModel.DueDate;
            //db.Lesson_Session.Add(lessonSession);

            //db.SaveChanges();



            HttpPostedFileBase Assignment  = Request.Files["Assignment"];
            HttpPostedFileBase Attachment1 = Request.Files["Attachment1"];
            HttpPostedFileBase Attachment2 = Request.Files["Attachment2"];
            HttpPostedFileBase Attachment3 = Request.Files["Attachment3"];

            if (Assignment.ContentLength > 0)
            {
                var fileName = Path.GetFileName(Assignment.FileName);
                Assignment.SaveAs(Server.MapPath("~/Content/StudentAssignments/") + fileName);
                AspnetStudentAssignment studentAssignment = new AspnetStudentAssignment();

                studentAssignment.FileName = fileName;

                studentAssignment.Name = LessonViewModel.AssignmentName;


                string DueDate = Convert.ToString(LessonViewModel.AssignmentDueDate);


                if (DueDate == "1/1/0001 12:00:00 AM")
                {
                    studentAssignment.DueDate = null;
                }
                else
                {
                    studentAssignment.DueDate = LessonViewModel.AssignmentDueDate;
                }


                studentAssignment.Description  = LessonViewModel.AssignmentDescription;
                studentAssignment.CreationDate = DateTime.Now;
                studentAssignment.LessonId     = Lesson.Id;

                db.AspnetStudentAssignments.Add(studentAssignment);
                db.SaveChanges();
            }

            if (Attachment1.ContentLength > 0)
            {
                var fileName = Path.GetFileName(Attachment1.FileName);
                Attachment1.SaveAs(Server.MapPath("~/Content/StudentAttachments/") + fileName);

                AspnetStudentAttachment studentAttachment1 = new AspnetStudentAttachment();

                studentAttachment1.Name         = LessonViewModel.AttachmentName1;
                studentAttachment1.Path         = fileName;
                studentAttachment1.CreationDate = DateTime.Now;
                studentAttachment1.LessonId     = Lesson.Id;
                db.AspnetStudentAttachments.Add(studentAttachment1);
                db.SaveChanges();
            }
            if (Attachment2.ContentLength > 0)
            {
                var fileName = Path.GetFileName(Attachment2.FileName);
                Attachment2.SaveAs(Server.MapPath("~/Content/StudentAttachments/") + fileName);

                AspnetStudentAttachment studentAttachment2 = new AspnetStudentAttachment();

                studentAttachment2.Name         = LessonViewModel.AttachmentName2;
                studentAttachment2.Path         = fileName;
                studentAttachment2.CreationDate = DateTime.Now;
                studentAttachment2.LessonId     = Lesson.Id;
                db.AspnetStudentAttachments.Add(studentAttachment2);

                db.SaveChanges();
            }

            if (Attachment3.ContentLength > 0)
            {
                var fileName = Path.GetFileName(Attachment3.FileName);
                Attachment3.SaveAs(Server.MapPath("~/Content/StudentAttachments/") + fileName);

                AspnetStudentAttachment studentAttachment3 = new AspnetStudentAttachment();

                studentAttachment3.Name         = LessonViewModel.AttachmentName3;
                studentAttachment3.Path         = fileName;
                studentAttachment3.CreationDate = DateTime.Now;
                studentAttachment3.LessonId     = Lesson.Id;
                db.AspnetStudentAttachments.Add(studentAttachment3);
                db.SaveChanges();
            }

            if (LessonViewModel.LinkUrl1 != null)
            {
                AspnetStudentLink link1 = new AspnetStudentLink();

                link1.URL          = LessonViewModel.LinkUrl1;
                link1.CreationDate = DateTime.Now;
                link1.LessonId     = Lesson.Id;
                db.AspnetStudentLinks.Add(link1);
                db.SaveChanges();
            }

            if (LessonViewModel.LinkUrl2 != null)
            {
                AspnetStudentLink link2 = new AspnetStudentLink();

                link2.URL          = LessonViewModel.LinkUrl2;
                link2.CreationDate = DateTime.Now;
                link2.LessonId     = Lesson.Id;
                db.AspnetStudentLinks.Add(link2);
                db.SaveChanges();
            }


            if (LessonViewModel.LinkUrl3 != null)
            {
                AspnetStudentLink link3 = new AspnetStudentLink();

                link3.URL          = LessonViewModel.LinkUrl3;
                link3.CreationDate = DateTime.Now;
                link3.LessonId     = Lesson.Id;
                db.AspnetStudentLinks.Add(link3);
                db.SaveChanges();
            }



            return(RedirectToAction("ViewTopicsAndLessons", "AspnetSubjectTopics"));
        }