public ActionResult Edit(Guid?id, Guid?courseId)
        {
            if (!id.HasValue || !courseId.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (!isCourseCreator(courseId))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }

            var assignment = db.Assignments.Include("Course").FirstOrDefault(i => i.Id == id);

            if (assignment == null)
            {
                return(HttpNotFound());
            }

            var model = new AssignmentForm {
                Id          = assignment.Id,
                CourseId    = assignment.CourseId,
                Deadline    = assignment.Deadline,
                Description = assignment.Description,
                Title       = assignment.Title
            };

            return(View(model));
        }
        public ActionResult Edit(AssignmentForm model)
        {
            if (ModelState.IsValid)
            {
                var assignment = db.Assignments.Include("Course").SingleOrDefault(i => i.Id == model.Id);
                if (assignment == null)
                {
                    return(HttpNotFound());
                }

                if (!isCourseCreator(assignment.Course))
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
                }

                assignment.Deadline    = model.Deadline;
                assignment.Description = model.Description;
                assignment.Title       = model.Title;

                db.Entry(assignment).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index", "Assignment", new { id = assignment.CourseId }));
            }

            return(View(model));
        }
Example #3
0
        private void ShowDialogForm(Assignment label)
        {
            AssignmentForm frm = new AssignmentForm(label);

            frm.ShowDialog();
            frm.Dispose();
        }
Example #4
0
        private void settingsButton_Click(object sender, EventArgs e)
        {
            AssignmentForm assignmentForm = new AssignmentForm(Assignment);

            if (assignmentForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Assignment = assignmentForm.Assignment;
            SetString(Assignment);
        }
        public ActionResult Create(Guid id)
        {
            if (!isCourseCreator(id))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var model = new AssignmentForm {
                CourseId = id,
                Deadline = DateTime.Now
            };

            return(View(model));
        }
        private void assignmentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AssignmentForm assignmentForm = new AssignmentForm(Scope.LocalVariables);

            if (assignmentForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (assignmentForm.Assignment == null)
            {
                return;
            }
            AssignmentBlock assignmentBlock = new AssignmentBlock(assignmentForm.Assignment, true);

            ScopePanel.Controls.Add(assignmentBlock);
            UpdateScope();
        }
Example #7
0
        private void assignmentsBx_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int index = this.assignmentsBx.IndexFromPoint(e.Location);

            if (index != System.Windows.Forms.ListBox.NoMatches)
            {
                string name = assignmentsBx.SelectedItem.ToString();
                Quiz   quiz = Program.Database.getAssignmentFromName(name, currentClass.rowId);
                if (currentUser.Role == UserTypes.Teacher)
                {
                    AssignmentForm form = AssignmentForm.editAssignmentForm(quiz);
                    form.Show();
                }
                else
                {
                    AssignmentForm form = AssignmentForm.studentAssignmentForm(quiz, currentUser.rowId);
                    form.Show();
                }
            }
        }
        public async Task <ActionResult> Create(AssignmentForm model)
        {
            var course = db.Courses.Find(model.CourseId);

            if (!course.IsCourseActive)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (!isCourseCreator(course))
            {
                return(RedirectToAction("Index", "Home"));
            }

            else if (ModelState.IsValid)
            {
                var assignment = new Assignment {
                    DateAdded   = DateTime.Now,
                    Title       = model.Title,
                    Description = model.Description,
                    Deadline    = model.Deadline
                };
                db.Assignments.Add(assignment);

                course.Assignments.Add(assignment);
                db.Entry(course).State = EntityState.Modified;

                db.SaveChanges();

                var emails = db.UserCourses
                             .Where(uc => uc.CourseId == model.CourseId && uc.IsActive && uc.DateJoin != null)
                             .Include(uc => uc.User)
                             .Select(uc => uc.User)
                             .Select(u => u.Email);

                //Send email to participants if there any
                if (emails != null || emails.Any())
                {
                    var mail = new MailMessage()
                    {
                        Subject = course.Heading + " dersine " + model.Title + " ödevi eklendi.",
                        Body    = ViewRenderer.RenderView("~/Views/Mail/NewAssignment.cshtml", new ViewDataDictionary()
                        {
                            { "title", model.Title },
                            { "deadline", model.Deadline },
                            { "description", model.Description },
                            { "course", course.Heading },
                            { "courseId", assignment.Id }
                        })
                    };

                    mail.IsBodyHtml = true;
                    foreach (var receiver in emails.ToList())
                    {
                        mail.Bcc.Add(receiver);
                    }

                    await ms.SendAsync(mail);
                }

                return(RedirectToAction("Index", "Assignment", new { id = model.CourseId }));
            }

            return(View(model));
        }
Example #9
0
        private void addAssignmentBtn_Click(object sender, EventArgs e)
        {
            AssignmentForm form = AssignmentForm.uploadAssignmentForm(currentClass.rowId);

            form.Show();
        }