Example #1
0
    protected void NewAssignmentButton_Click(object sender, EventArgs e)
    {
        ApplicationDbContext dbContext = new ApplicationDbContext();

        Assignment assignment = new Assignment();

        assignment.Title          = NewAssignmentTitle.Text;
        assignment.PossiblePoints = int.Parse(NewAssignmentPossiblePoints.Text);
        assignment.Content        = NewAssignmentContent.Text;

        assignment.Course = dbContext.Courses.Where(c => c.Id == course.Id).FirstOrDefault();

        dbContext.Assignments.Add(assignment);

        dbContext.SaveChanges();

        AssignmentRepeater.DataBind();

        NewAssignmentTitle.Text          = "";
        NewAssignmentPossiblePoints.Text = "";
        NewAssignmentContent.Text        = "";

        HomePanel.Visible       = false;
        AssignmentPanel.Visible = true;

        ActivePanelLabel.Text = "Assignments";
    }
Example #2
0
    protected void DeleteAssignmentLink_Click(object sender, EventArgs e)
    {
        ApplicationDbContext dbContext = new ApplicationDbContext();

        Assignment assignment = (Assignment)Session["CurrentAssignment"];

        dbContext.Assignments.Remove(dbContext.Assignments.Where(a => a.Id == assignment.Id).FirstOrDefault());
        dbContext.SaveChanges();

        AssignmentTitleLabel.Text   = "";
        AssignmentContentLabel.Text = "";

        AssignmentRepeater.DataBind();

        HomePanel.Visible       = false;
        AssignmentPanel.Visible = true;

        ActivePanelLabel.Text = "Assignments";
    }