public int Add(SubmittedAssignmentViewModel sub)
        {
            tblSubmittedAssignment tb = new tblSubmittedAssignment();

            tb.Routine_Id          = sub.Routine_Id;
            tb.Student_Id          = sub.Student_Id;
            tb.Submitted_Date      = System.DateTime.Now;
            tb.Checked_Status      = 0;
            tb.Feedback_Status     = 0;
            tb.Marking             = 0;
            tb.Assignmnet_Location = 0;
            _db.tblSubmittedAssignments.Add(tb);
            _db.SaveChanges();
            tblLog tl = new tblLog();

            tl.Date                  = DateTime.Now;
            tl.ActivityId            = 1;
            tl.SubmittedAssignmentId = tb.ID;
            _db.tblLogs.Add(tl);
            return(_db.SaveChanges());
        }
        public int Update(SubmittedAssignmentViewModel sub)
        {
            ////tblSubmittedAssignment tb = _db.tblSubmittedAssignments.Where(a => a.ID == sub.Id).FirstOrDefault();
            ////tb.Routine_Id = sub.Routine_Id;
            ////tb.Student_Id = sub.Student_Id;
            ////tb.Submitted_Date = tb.Submitted_Date;
            ////tb.Checked_Status = sub.Checked_Status;
            ////tb.Feedback_Status = sub.Feedback_Status;
            ////tb.Assignmnet_Location = sub.Assignmnet_Location;
            ////tb.Marking = sub.Marking;
            ////_db.SaveChanges();
            ////tblLog tl = new tblLog();
            ////if (tb.Assignmnet_Location == 1)
            ////{
            ////    tl.Date = DateTime.Now;
            ////    tl.ActivityId = 2;
            ////    tl.SubmittedAssignmentId = tb.ID;
            ////    _db.tblLogs.Add(tl);
            ////    return _db.SaveChanges();
            ////}
            ////else if (tb.Assignmnet_Location == 0)
            ////{
            ////    tl.Date = DateTime.Now;
            ////    tl.ActivityId = 3;
            ////    tl.SubmittedAssignmentId = tb.ID;
            ////    _db.tblLogs.Add(tl);
            ////    return _db.SaveChanges();
            ////}
            ////else if (tb.Assignmnet_Location == 2)
            ////{
            ////    tl.Date = DateTime.Now;
            ////    tl.ActivityId = 4;
            ////    tl.SubmittedAssignmentId = tb.ID;
            ////    _db.tblLogs.Add(tl);
            ////    return _db.SaveChanges();
            ////}
            ////else
            ////{
            ////    tl.Date = DateTime.Now;
            ////    tl.ActivityId = 4;
            ////    tl.SubmittedAssignmentId = tb.ID;
            ////    _db.tblLogs.Add(tl);
            ////    return _db.SaveChanges();
            ////}
            tblSubmittedAssignment tb = _db.tblSubmittedAssignments.Where(a => a.ID == sub.Id).FirstOrDefault();
            tblLog tl = new tblLog();

            if (tb.Assignmnet_Location == 0 && sub.Assignmnet_Location == 1)
            {
                tl.Date                  = DateTime.Now;
                tl.ActivityId            = 2;
                tl.SubmittedAssignmentId = tb.ID;
                _db.tblLogs.Add(tl);
            }
            if (tb.Assignmnet_Location == 1 && sub.Assignmnet_Location == 0)
            {
                tl.Date                  = DateTime.Now;
                tl.ActivityId            = 3;
                tl.SubmittedAssignmentId = tb.ID;
                _db.tblLogs.Add(tl);
            }
            if (tb.Assignmnet_Location == 0 && sub.Assignmnet_Location == 2)
            {
                tl.Date                  = DateTime.Now;
                tl.ActivityId            = 4;
                tl.SubmittedAssignmentId = tb.ID;
                _db.tblLogs.Add(tl);
            }
            if (tb.Assignmnet_Location == 2 && sub.Assignmnet_Location == 0)
            {
                tl.Date                  = DateTime.Now;
                tl.ActivityId            = 5;
                tl.SubmittedAssignmentId = tb.ID;
                _db.tblLogs.Add(tl);
            }
            tb.Routine_Id          = sub.Routine_Id;
            tb.Student_Id          = sub.Student_Id;
            tb.Submitted_Date      = tb.Submitted_Date;
            tb.Checked_Status      = sub.Checked_Status;
            tb.Feedback_Status     = sub.Feedback_Status;
            tb.Marking             = sub.Marking;
            tb.Assignmnet_Location = sub.Assignmnet_Location;
            return(_db.SaveChanges());
        }