public int Add(AssignmentRoutineViewModel arvm) { tblAssignmentRoutine tb = new tblAssignmentRoutine(); tb.Assignment_Name = arvm.Assignment_Name; tb.Teacher_Id = arvm.Teacher_Id; tb.Assignment_Release_Date = arvm.Assignment_Release_Date; tb.Deadline = arvm.Deadline; tb.Section_Id = arvm.Section_Id; tb.Faculty_Id = arvm.Faculty_Id; tb.Semester_Id = arvm.Semester_Id; tb.YearBatchId = arvm.Year_Batch_Id; _db.tblAssignmentRoutines.Add(tb); _db.SaveChanges(); tblStudentRoutineRelation tsr = new tblStudentRoutineRelation(); var studnet = _db.tblStudents.Where(s => s.Faculty_Id == tb.Faculty_Id && s.Section_Id == tb.Section_Id && s.Semester_Id == tb.Semester_Id && s.YearBatchId == tb.YearBatchId).ToList(); foreach (var item in studnet) { tsr.RoutineId = tb.Routine_Id; tsr.StudentId = item.Student_Id; _db.tblStudentRoutineRelations.Add(tsr); _db.SaveChanges(); } return(0); }
public int Add(StudentViewModel svm) { try { tblStudent tb = new tblStudent(); //var keyNew = Helper.GeneratePassword(10); //var password = Helper.EncodePassword(keyNew, keyNew); //objNewUser.VCode = keyNew; tb.Name = svm.Name; tb.Email = svm.Email; tb.Password = CreateRandomPassword(5);/*stu.Password;*/ //tb.VCode = keyNew; tb.Gender = svm.Gender; tb.Phone = svm.Phone; tb.Address = svm.Address; tb.YearBatchId = svm.Year_Batch_Id; tb.Faculty_Id = svm.Faculty_Id; tb.Section_Id = svm.Section_Id; tb.Semester_Id = svm.Semester_Id; _db.tblStudents.Add(tb); return(_db.SaveChanges()); } catch (Exception ex) { throw ex; } }
public int Add(TeacherViewModel tvm) { try { tblTeacher tb = new tblTeacher(); tb.Name = tvm.Name; tb.Email = tvm.Email; tb.Password = CreateRandomPassword(5); tb.Phone = tvm.Phone; tb.Address = tvm.Address; _db.tblTeachers.Add(tb); _db.SaveChanges(); tblMainLog tml = new tblMainLog(); var principal = System.Security.Claims.ClaimsPrincipal.Current; string Name = principal.FindFirst(ClaimsIdentity.DefaultNameClaimType).Value; str = "New Teacher Added With Name- '" + tvm.Name + "' " + ", Email- '" + tvm.Email + "' " + ", Phone- '" + tvm.Phone + "' " + "and Address- '" + tvm.Address + "Added by Admin"; tml.Description = str; tml.AdminName = Name; tml.Date = System.DateTime.Now; tml.EntityId = 4; tml.ItemId = tb.Teacher_Id; _db.tblMainLogs.Add(tml); return(_db.SaveChanges()); } catch (Exception ex) { throw ex; } }
public int Add(Admin adm) { try { tblAdmin tb = new tblAdmin(); tb.Name = adm.Name; tb.Email = adm.Email; tb.Password = adm.Password; tb.Role = adm.Role; _db.tblAdmins.Add(tb); return(_db.SaveChanges()); } catch (Exception ex) { throw ex; } }
public int Add(SectionViewModel svm) { tblSection tb = new tblSection(); tb.Sec_Name = svm.Sec_Name; _db.tblSections.Add(tb); _db.SaveChanges(); tblMainLog tml = new tblMainLog(); var principal = System.Security.Claims.ClaimsPrincipal.Current; string Name = principal.FindFirst(ClaimsIdentity.DefaultNameClaimType).Value; str = "New Section '" + svm.Sec_Name + "' " + "Added by Admin"; tml.Description = str; tml.AdminName = Name; tml.Date = System.DateTime.Now; tml.EntityId = 8; tml.ItemId = tb.Section_Id; _db.tblMainLogs.Add(tml); return(_db.SaveChanges()); }
public int Add(FacultyViewModel fvm) { tblFaculty tb = new tblFaculty(); tb.Faculty_Name = fvm.Faculty_Name; _db.tblFaculties.Add(tb); _db.SaveChanges(); tblMainLog tml = new tblMainLog(); var principal = System.Security.Claims.ClaimsPrincipal.Current; string Name = principal.FindFirst(ClaimsIdentity.DefaultNameClaimType).Value; str = "New Faculty '" + fvm.Faculty_Name + "' " + "Added by Admin"; tml.Description = str; tml.AdminName = Name; tml.Date = System.DateTime.Now; tml.EntityId = 6; tml.ItemId = tb.Faculty_Id; _db.tblMainLogs.Add(tml); return(_db.SaveChanges()); }
public int Add(YearBatchViewModel yvm) { tblYearBatch tb = new tblYearBatch(); tb.Year_Batch = yvm.Year_Batch; _db.tblYearBatches.Add(tb); _db.SaveChanges(); tblMainLog tml = new tblMainLog(); var principal = System.Security.Claims.ClaimsPrincipal.Current; string Name = principal.FindFirst(ClaimsIdentity.DefaultNameClaimType).Value; str = "New Yearbatch '" + yvm.Year_Batch + "' " + "Added by Admin"; tml.Description = str; tml.AdminName = Name; tml.Date = System.DateTime.Now; tml.EntityId = 5; tml.ItemId = tb.YearBatchId; _db.tblMainLogs.Add(tml); return(_db.SaveChanges()); }
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 ChangePassword(int?studentid, ChangePasswordViewModel cvm) { try { tblStudent tb = _db.tblStudents.Where(s => s.Student_Id == studentid && s.Password == cvm.OldPassword).FirstOrDefault(); if (tb != null) { tb.Password = cvm.ConfirmNewPassword; } return(_db.SaveChanges()); } catch (Exception ex) { throw ex; } }