public ActionResult UploadAssig(string id, FileDataVM model) { if (!ModelState.IsValid) { return(View(model)); } byte[] uploadedFile = new byte[model.File.InputStream.Length]; model.File.InputStream.Read(uploadedFile, 0, uploadedFile.Length); var assig = db.Event_tbl.Find(id); // now you could pass the byte array to your model and store wherever // you intended to store it File_tbl fl = new File_tbl() { FileName = model.File.FileName, UploadOn = DateTime.Now, File = uploadedFile, CourseID = assig.CourseID, AssignmentID = assig.ID }; db.File_tbl.Add(fl); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult ForgetPassword(string Email, string UserID) { if (Email != null && UserID != null) { //check if user is student if (db.Student_tbl.Any(m => m.Email == Email && m.ID == UserID)) { //give admin authorization to reset the password var std = db.Student_tbl.Where(m => m.Email == Email && m.ID == UserID).FirstOrDefault(); std.ForgetPassword = true; db.SaveChanges(); //add notification to admin to reset password return(RedirectToAction("Create", "Notification", new { mthd = "Index", cntlr = "Home", course_id = UserID, subject = "Recover account of " + Email + "&", role_not = "Admin" })); } //check if user is lecturer else if (db.Lecturer_tbl.Any(m => m.Email == Email && m.ID == UserID)) { //give admin authorization to reset the password db.Lecturer_tbl.Where(m => m.Email == Email && m.ID == UserID).FirstOrDefault().ForgetPassword = true; db.SaveChanges(); //add notification to admin to reset password return(RedirectToAction("Create", "Notification", new { mthd = "Index", cntlr = "Home", course_id = UserID, subject = Email + " Forgot the password and ID is ", role_not = "Admin" })); } //check if user is admin else if (db.Admin_tbl.Any(m => m.Email == Email && m.ID == UserID)) { //give admin authorization to reset the password db.Admin_tbl.Where(m => m.Email == Email && m.ID == UserID).FirstOrDefault().ForgetPassword = true; db.SaveChanges(); //add notification to admin to reset password return(RedirectToAction("Create", "Notification", new { mthd = "Index", cntlr = "Home", course_id = UserID, subject = Email + " Forgot the password and ID is ", role_not = "Admin" })); } } return(View()); }
public ActionResult Create(Question_tbl question_tbl) { if (ModelState.IsValid) { db.Question_tbl.Add(question_tbl); db.SaveChanges(); return(RedirectToAction("Create", "Exam")); } ViewBag.CourseID = new SelectList(db.Course_tbl, "ID", "Name"); return(PartialView(question_tbl)); }
public void SaveData(Models.AuthorModel authorModel) { var data = new Author() { AuthorID = authorModel.AuthorID, AuthorName = authorModel.AuthorName, Description = authorModel.Description, }; context.Authors.Add(data); context.SaveChanges(); }
public void SaveData(Models.AssesionMappingModel assesionMappingModel) { var data = new AssesionMapping() { AssesionID = assesionMappingModel.AssesionID, BookID = assesionMappingModel.BookID, Status = assesionMappingModel.Status, }; context.AssesionMappings.Add(data); context.SaveChanges(); }
public void SaveData(Models.BookCategoryModel bookCategoryModel) { var data = new BookCategory() { BookCategoryID = bookCategoryModel.BookCategoryID, BookCategoryName = bookCategoryModel.BookCategoryName, Description = bookCategoryModel.Description, }; context.BookCategories.Add(data); context.SaveChanges(); }
public void SaveData(Models.SubjectModel subjectModel) { var data = new Subject() { SubjectID = subjectModel.SubjectID, SubjectName = subjectModel.SubjectName, Remarks = subjectModel.Remarks, }; context.Subjects.Add(data); context.SaveChanges(); }
public void SaveData(Models.MemberCategoryModel memberCategoryModel) { var data = new MemberCategory() { StaffMemberID = memberCategoryModel.StaffMemberID, MemberCategoryName = memberCategoryModel.MemberCategoryName, Remarks = memberCategoryModel.Remarks }; context.MemberCategories.Add(data); context.SaveChanges(); }
public ActionResult Create(Course_tbl course_tbl) { if (ModelState.IsValid) { db.Course_tbl.Add(course_tbl); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Prof = new SelectList(db.Lecturer_tbl.Where(m => m.Role == "Prof"), "ID", "Name"); ViewBag.Assistant = new SelectList(db.Lecturer_tbl.Where(m => m.Role == "Assistant"), "ID", "Name"); return(View(course_tbl)); }
public void SaveData(Models.FineModel fineModel) { var data = new Fine() { FineID = fineModel.FineID, LateDays = fineModel.LateDays, StaffMemberID = fineModel.StaffMemberID, Amount = fineModel.Amount, Remarks = fineModel.Remarks, }; context.Fines.Add(data); context.SaveChanges(); }
public ActionResult Create(Lecturer_tbl lecturer_tbl) { var salt = GenerateSalt(); if (ModelState.IsValid) { lecturer_tbl.Password = Convert.ToBase64String(ComputeHMAC_SHA256(Encoding.UTF8.GetBytes(lecturer_tbl.Password), salt)); lecturer_tbl.Salt = salt; db.Lecturer_tbl.Add(lecturer_tbl); db.SaveChanges(); return(RedirectToAction("UploadImage", "Lecturer", new { id = lecturer_tbl.ID })); } return(View(lecturer_tbl)); }
public ActionResult Create([Bind(Include = "Id,Title,Author,Tag,Image,Year_of_publishing")] BookTbl bookTbl) { try { if (ModelState.IsValid) { db.BookTbls.Add(bookTbl); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception e) { } return(View("Create", bookTbl)); }
public void SaveData(Models.BookModel bookModel) { var data = new Book() { BookID = bookModel.BookID, BookName = bookModel.BookName, BookCategoryID = bookModel.BookCategoryID, AuthorID = bookModel.AuthorID, SubjectID = bookModel.SubjectID, Remarks = bookModel.Remarks }; context.Books.Add(data); context.SaveChanges(); }
public ActionResult Details(string id, string mark01, string mark02, string mark03, string mark04, string mark05, string mark06, string mark07, string mark08, string mark09, string mark10) { var ans = db.Answer_tbl.Find(id); var st = db.Student_tbl.Find(ans.Stu_Code); if (st != null) { var res = db.Result_tbl.Where(m => m.StudentID == st.ID && m.Exam_ID == ans.Exam_ID).FirstOrDefault(); if (ans.Ans_6 == null && ans.Ans_7 == null) { res.Achieved_Mark = int.Parse(mark01) + int.Parse(mark02) + int.Parse(mark03) + int.Parse(mark04) + int.Parse(mark05); } else { res.Achieved_Mark = int.Parse(mark01) + int.Parse(mark02) + int.Parse(mark03) + int.Parse(mark04) + int.Parse(mark05) + int.Parse(mark06) + int.Parse(mark07) + int.Parse(mark08) + int.Parse(mark09) + int.Parse(mark10); } db.Entry(res).State = EntityState.Modified; db.SaveChanges(); } //Add notification return(RedirectToAction("Create", "Notification", new { mthd = "Index", cntlr = "Result", course_id = ans.Exam_ID, subject = "New Result is added for Course ", role_not = "Student" })); //return RedirectToAction("Index", "Result"); }
public ActionResult DeleteConfirmed(string id) { Attendance_tbl attendance_tbl = db.Attendance_tbl.Find(id); db.Attendance_tbl.Remove(attendance_tbl); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { File_tbl file_tbl = db.File_tbl.Find(id); db.File_tbl.Remove(file_tbl); db.SaveChanges(); return(RedirectToAction("Index")); }
public void SaveData(Models.MemberModel memberModel) { var data = new Member() { MemberID = memberModel.MemberID, MemberName = memberModel.MemberName, StaffMemberID = memberModel.StaffMemberID, MemberAddress = memberModel.MemberAddress, ContactNo = memberModel.ContactNo, EmailAddress = memberModel.EmailAddress, UserName = memberModel.UserName, Password = memberModel.Password, Status = memberModel.Status }; context.Members.Add(data); context.SaveChanges(); }
public void SaveData(Models.BookIssueRetModel bookIssueRetModel) { var data = new BookIssueRet() { BookIssueReturnID = bookIssueRetModel.BookIssueReturnID, MemberID = bookIssueRetModel.MemberID, AssesionID = bookIssueRetModel.AssesionID, IssueDate = bookIssueRetModel.IssueDate, DueDate = bookIssueRetModel.DueDate, ReturnDate = bookIssueRetModel.ReturnDate, FineAmount = bookIssueRetModel.FineAmount, Status = bookIssueRetModel.Status, StaffMemberID = bookIssueRetModel.StaffMemberID, Remarks = bookIssueRetModel.Remarks }; context.BookIssueRets.Add(data); context.SaveChanges(); }
public ActionResult Create(Student_tbl student_tbl) { var salt = GenerateSalt(); if (ModelState.IsValid) { student_tbl.Password = Convert.ToBase64String(ComputeHMAC_SHA256(Encoding.UTF8.GetBytes(student_tbl.Password), salt)); student_tbl.Salt = salt; student_tbl.ForgetPassword = false; str = student_tbl.ID; db.Student_tbl.Add(student_tbl); db.SaveChanges(); return(RedirectToAction("UploadImage")); } ViewBag.Attend_Courses = new SelectList(db.Attendance_tbl, "ID", "StudentID", student_tbl.Attend_Courses); ViewBag.Registered_Courses = new SelectList(db.RegisteredCourses_tbl, "ID", "Course01", student_tbl.Registered_Courses); ViewBag.Results = new SelectList(db.Result_tbl, "ID", "CourseID", student_tbl.Results); return(View(student_tbl)); }
// GET: Notification/Create public ActionResult Create(string mthd, string cntlr, string course_id, string subject, string role_not, Notification_tbl notification_tbl) { if (ModelState.IsValid) { string Not_id; do { Random rnd = new Random(); Not_id = "Not" + (rnd.Next(100001)).ToString(); } while (db.Notification_tbl.Find(Not_id) != null); notification_tbl.NotificationID = Not_id; notification_tbl.Description = subject + course_id; notification_tbl.Role = role_not; db.Notification_tbl.Add(notification_tbl); db.SaveChanges(); return(RedirectToAction(mthd, cntlr)); } return(null); }
public ActionResult Create(Admin_tbl admin_tbl) { var salt = GenerateSalt(); if (ModelState.IsValid) { admin_tbl.Password = Convert.ToBase64String(ComputeHMAC_SHA256(Encoding.UTF8.GetBytes(admin_tbl.Password), salt)); admin_tbl.Salt = salt; db.Admin_tbl.Add(admin_tbl); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(admin_tbl)); }
public ActionResult Create(RegisteredCourses_tbl registeredCourses_tbl) { if (ModelState.IsValid) { //if(registeredCourses_tbl.Course01 != null) //{ // registeredCourses_tbl.Course01 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course01).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course02 != null) //{ // registeredCourses_tbl.Course02 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course02).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course03 != null) //{ // registeredCourses_tbl.Course03 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course03).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course04 != null) //{ // registeredCourses_tbl.Course04 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course04).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course05 != null) //{ // registeredCourses_tbl.Course05 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course05).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course06 != null) //{ // registeredCourses_tbl.Course06 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course06).FirstOrDefault().ID; //} //if (registeredCourses_tbl.Course07 != null) //{ // registeredCourses_tbl.Course07 = db.Course_tbl.Where(m => m.Name == registeredCourses_tbl.Course07).FirstOrDefault().ID; //} db.RegisteredCourses_tbl.Add(registeredCourses_tbl); var std = db.Student_tbl.Find(registeredCourses_tbl.ID); std.Registered_Courses = registeredCourses_tbl.ID; db.SaveChanges(); CreateAttendance(registeredCourses_tbl); return(RedirectToAction("Index", "Home")); } return(View(registeredCourses_tbl)); }
public void InsertIntoEmployee(AllEmployeeDetails Emp) { _dbcontext.AllEmployeeDetails.Add(Emp); _dbcontext.SaveChanges(); }
public IHttpActionResult PutAttendance_tbl() { if (!ModelState.IsValid) { return(BadRequest("This is the invaild part")); } // =================================== Send Json data in request body ====================== var bodyStream = new StreamReader(HttpContext.Current.Request.InputStream); //bodyStream.BaseStream.Seek(0, SeekOrigin.Begin); var bodyText = bodyStream.ReadToEnd(); //=================================== Save JSON data in file in server ===================== string fname = "h:\\root\\home\\phicommsees-001\\www\\db\\jsonfiles\\path.json"; System.IO.File.WriteAllText(fname, bodyText); //Save file on server //fname = @"D:\path.json"; //postedFile.SaveAs(fname); var json = File.ReadAllText(fname); var Att_VM = JsonConvert.DeserializeObject <AttVM>(json); for (int i = 0; i < Att_VM.StudentID.Length; i++) { var std_ID = Att_VM.StudentID[i]; var attendance_tbl = db.Attendance_tbl.Where(s => s.CourseID == Att_VM.CourseID && s.StudentID == std_ID).FirstOrDefault(); if (attendance_tbl != null) { attendance_tbl.No_of_Attendances += 1; db.Entry(attendance_tbl).State = EntityState.Modified; db.SaveChanges(); } } //========================== JSON File ==================================================== //if (HttpContext.Current.Request.Files.Count == 0) // throw new HttpResponseException(new HttpResponseMessage() // { // ReasonPhrase = "Files are required", // StatusCode = HttpStatusCode.BadRequest // }); //foreach (string file in HttpContext.Current.Request.Files) //{ // string fname; // var postedFile = HttpContext.Current.Request.Files[file]; // fname = postedFile.FileName; // if (!(postedFile.ContentType == "application/json" || postedFile.ContentType == "application/xml")) // { // throw new System.Web.Http.HttpResponseException(new HttpResponseMessage() // { // ReasonPhrase = "Wrong content type", // StatusCode = HttpStatusCode.BadRequest // }); // } // // =================================== JSON File =========================================== // //Save file on server // fname = "h:\\root\\home\\phicommsees-001\\www\\db\\jsonfiles\\" + fname; // postedFile.SaveAs(fname); // var json = File.ReadAllText(fname); // var Att_VM = JsonConvert.DeserializeObject<AttVM>(json); // for(int i = 0; i < Att_VM.StudentID.Length; i++) // { // var std_ID = Att_VM.StudentID[i]; // var attendance_tbl = db.Attendance_tbl.Where(s => s.CourseID == Att_VM.CourseID && s.StudentID == std_ID).FirstOrDefault(); // if(attendance_tbl != null) // { // attendance_tbl.No_of_Attendances += 1; // db.Entry(attendance_tbl).State = EntityState.Modified; // db.SaveChanges(); // } // } //} return(StatusCode(HttpStatusCode.Accepted)); }
public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Exam_tbl exam_tbl = db.Exam_tbl.Find(id); if (exam_tbl == null) { return(HttpNotFound()); } var st = db.Student_tbl.FirstOrDefault(m => m.Email == User.Identity.Name); //check if student registered in this course of exam var reg = db.RegisteredCourses_tbl.Find(st.ID); bool isregistered = false; if (reg.Course01 == id || reg.Course02 == id || reg.Course03 == id || reg.Course04 == id || reg.Course05 == id || reg.Course06 == id || reg.Course07 == id) { isregistered = true; } var pretended_ans_ID = st.ID + id; var ans = db.Answer_tbl.FirstOrDefault(m => m.Ans_ID == pretended_ans_ID); var res = db.Result_tbl.FirstOrDefault(m => m.StudentID == st.ID && m.Exam_ID == id); //calculate the difference in time //TimeSpan difftm = exam_tbl.AvailabilityTime.Value - DateTime.Now; int diff = DateTime.Compare(exam_tbl.AvailabilityTime.Value, DateTime.Now); if (diff < 0 && ans == null && isregistered) { //create res and ans paper and leave it blank var result = new Result_tbl(); result.Exam_ID = id; result.ID = "R0" + db.Result_tbl.Count().ToString(); result.StudentID = st.ID; result.CourseID = exam_tbl.Course_ID; result.Title = exam_tbl.Type; //create answer paper var Ans = new Answer_tbl() { Ans_ID = st.ID + id, Exam_ID = id, Stu_Code = st.ID }; Ans.Ans_1 = string.Empty; Ans.Ans_2 = string.Empty; Ans.Ans_3 = string.Empty; Ans.Ans_4 = string.Empty; Ans.Ans_5 = string.Empty; if (exam_tbl.Type != "Quiz") { Ans.Ans_6 = string.Empty; Ans.Ans_7 = string.Empty; Ans.Ans_8 = string.Empty; Ans.Ans_9 = string.Empty; Ans.Ans_10 = string.Empty; } db.Result_tbl.Add(result); db.Answer_tbl.Add(Ans); db.SaveChanges(); return(RedirectToAction("Index", "Result")); } if (ans != null || res != null || isregistered == false) { return(RedirectToAction("Index", "Result")); } return(View(exam_tbl)); }