public ActionResult UpdateParent(int id, ParentViewModel collection) { DBSmartSchoolWebPortalEntities111 ent = new DBSmartSchoolWebPortalEntities111(); var parent = ent.Parents.Where(x => x.Id == id).First(); if (collection.Name == null) { collection.Name = parent.Name; } if (collection.Contact == null) { collection.Contact = parent.Contact; } if (collection.Email == null) { collection.Email = parent.Email; } if (collection.NIC == null) { collection.NIC = parent.NIC; } parent.Name = collection.Name; parent.Contact = collection.Contact; parent.Email = collection.Email; parent.UserName = parent.UserName; parent.Password = parent.Password; parent.NIC = collection.NIC; ent.SaveChanges(); return(RedirectToAction("AllParent")); }
public ActionResult LeaveRequestAccept(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var Request = db.LeavesRequests.Where(x => x.Id == id).First(); var Student = db.Students.Where(x => x.Id == Request.StudentId).First(); Request.Status = 1; db.SaveChanges(); //Sending mail to Student that his/her Leave Request is Accepted using (MailMessage mailMessage = new MailMessage(MailUserName, Student.Email)) { mailMessage.Subject = "Hi!"; mailMessage.Body = "This mail is from Smart School Web Portal admin! Your Leave Request for Date " + Request.Date + " is acceptted!"; mailMessage.IsBodyHtml = false; using (SmtpClient smtp = new SmtpClient()) { smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(MailUserName, MailPassword); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mailMessage); } } string message = "Email Sent to " + Student.UserName + " !"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult UpdateHostel(int id, HostelViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var hostel = db.Hostels.Where(x => x.Id == id).First(); if (collection.HostelName == null) { collection.HostelName = hostel.Name; } if (collection.HostelRent == 0) { collection.HostelRent = Convert.ToInt16(hostel.Rent); } if (collection.HostelLocation == null) { collection.HostelLocation = hostel.Location; } hostel.Name = collection.HostelName; hostel.Details = collection.HostelDetails; hostel.Rent = collection.HostelRent; hostel.Location = collection.HostelLocation; db.SaveChanges(); string message = "Hostel Updated!"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult MAddHostels(HostelViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); Hostel hostel = new Hostel(); hostel.Name = collection.HostelName; hostel.Location = collection.HostelLocation; hostel.Details = collection.HostelDetails; hostel.Rent = collection.HostelRent; if (collection.Image != null) { string filename = Path.GetFileNameWithoutExtension(collection.Image.FileName); string ext = Path.GetExtension(collection.Image.FileName); filename = filename + DateTime.Now.Millisecond.ToString(); filename = filename + ext; string filetodb = "/img/Hostels/" + filename; filename = Path.Combine(Server.MapPath("~/img/Hostels"), filename); collection.Image.SaveAs(filename); collection.ImagePath = filetodb; } else { collection.ImagePath = "/img/Hostels/MumtazHall.jpg"; } hostel.ImagePath = collection.ImagePath; db.Hostels.Add(hostel); db.SaveChanges(); return(View()); }
public ActionResult SRequestAcceptEnd(StudentViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); int i = StudentIdGlobal; var student = db.Students.Where(x => x.Id == StudentIdGlobal).First(); student.UserName = collection.UserName; student.Password = collection.Password; student.Status = 1; db.SaveChanges(); //Sending mail to Student with his/her UserName and Password using (MailMessage mailMessage = new MailMessage(MailUserName, student.Email)) { mailMessage.Subject = "Hi!"; mailMessage.Body = "This mail is from Smart School Web Portal admin! Your User Name is " + collection.UserName + " and Password is " + collection.Password; mailMessage.IsBodyHtml = false; using (SmtpClient smtp = new SmtpClient()) { smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(MailUserName, MailPassword); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mailMessage); } } string message = "Email Sent to " + student.UserName + " !"; return(RedirectToAction("STudentRequests", "Management", new { Message = message })); }
public ActionResult PayFees(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var sf = db.StudentFees.Where(x => x.Id == id).First(); sf.Status = "Paid"; db.SaveChanges(); string message = "Student fee Paid!"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult DeleteParent(int id) { DBSmartSchoolWebPortalEntities111 ent = new DBSmartSchoolWebPortalEntities111(); var parent = ent.Parents.Where(x => x.Id == id).First(); ent.Entry(parent).State = System.Data.Entity.EntityState.Deleted; ent.SaveChanges(); string message = "Parent is Deleted"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult ComplainNotice(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var complain = db.Complaints.Where(x => x.Id == id).First(); complain.Status = 1; db.SaveChanges(); string message = "Complain Noticed!"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult Change(ParentViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var user = db.Parents.Where(x => x.Id == LoginClass.LoginId).First(); user.UserName = collection.UserName; user.Password = collection.Password; db.SaveChanges(); string message = "User Name & Password Updated!"; return(RedirectToAction("Account", "Parent", new { Message = message })); }
public ActionResult DeleteHostel(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var hostel = db.Hostels.Where(x => x.Id == id).First(); db.Entry(hostel).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); string message = "Hostel is Deleted"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult UnPublishNews(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var news = db.News.Where(x => x.Id == id).First(); news.Status = 2; db.SaveChanges(); string message = "News UnPublished!"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult AddComplaint(ComplainViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); Complaint complaint = new Complaint(); complaint.ParentId = LoginClass.LoginId; complaint.Details = collection.Details; db.Complaints.Add(complaint); db.SaveChanges(); return(RedirectToAction("Account")); }
public ActionResult Register(StudentViewModel Collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); Student s = new Student(); s.Name = Collection.Name; s.Contact = Collection.Contact; s.RegisterationNumber = Collection.RegisterationNumber; s.Email = Collection.Email; db.Students.Add(s); db.SaveChanges(); return(View()); }
public ActionResult AddEvents(EventViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); Event eve = new Event(); eve.Desciption = collection.Description; eve.Date = collection.Date; db.Events.Add(eve); db.SaveChanges(); return(RedirectToAction("ViewEvents")); }
public ActionResult AddNews(NewsViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); News news = new News(); news.Date = DateTime.Now; news.Description = collection.Description; news.Title = collection.Title; db.News.Add(news); db.SaveChanges(); return(RedirectToAction("ViewNews")); }
public ActionResult SLeaveRequests(LeaveViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); LeavesRequest request = new LeavesRequest(); request.Reason = collection.Reason; request.Date = DateTime.Now; request.StudentId = LoginClass.LoginId; db.LeavesRequests.Add(request); db.SaveChanges(); return(View()); }
public ActionResult RequestHostel(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); HostelRequest request = new HostelRequest(); request.HostelId = id; request.StudentId = LoginClass.LoginId; db.HostelRequests.Add(request); db.SaveChanges(); string message = "Hostel Requested!"; return(RedirectToAction("Account", "Student", new { Message = message })); }
public ActionResult Attendance(ClassAttendanceViewModel Collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); ClassAttendance ClassAtt = new ClassAttendance(); ClassAtt.ClassId = Collection.ClassId; ClassAtt.SectionId = Collection.SectionId; ClassAtt.Date = Collection.Date; ClassIdGlobal = Collection.ClassId; SectionIdGlobal = Collection.SectionId; GlobalDate = Collection.Date; db.ClassAttendances.Add(ClassAtt); db.SaveChanges(); return(RedirectToAction("StudentAttendance")); }
public ActionResult PLeaveRequests(LeaveViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); LeavesRequest request = new LeavesRequest(); var Parent = db.Parents.Where(x => x.Id == LoginClass.LoginId).First(); var Student = db.Students.Where(x => x.Id == Parent.StudentId).First(); request.Reason = collection.Reason; request.Date = DateTime.Now; request.StudentId = Student.Id; db.LeavesRequests.Add(request); db.SaveChanges(); return(View()); }
public ActionResult Register(ParentViewModel Collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); Parent s = new Parent(); s.Name = Collection.Name; s.Contact = Collection.Contact; s.NIC = Collection.NIC; s.Email = Collection.Email; var Id = db.Students.Where(x => x.RegisterationNumber == Collection.RegNo).First(); s.StudentId = Id.Id; db.Parents.Add(s); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult Marked(int Status) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); StudentAttendance sd = new StudentAttendance(); var i = db.ClassAttendances.Where(x => x.ClassId == ClassIdGlobal && x.SectionId == SectionIdGlobal && x.Date == GlobalDate).First(); sd.ClassAttendanceId = i.Id; sd.StudentId = StudentIdGlobal; sd.Status = Status; db.StudentAttendances.Add(sd); db.SaveChanges(); return(RedirectToAction("StudentAttendance")); }
public ActionResult RegisterCourse(RegisteredCourseViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); RegisteredCourse course = new RegisteredCourse(); course.CourseId = collection.CourseId; var student = db.Students.Where(x => x.RegisterationNumber == collection.StudentId).First(); course.StudentId = student.Id; course.RegisterationDate = DateTime.Now; db.RegisteredCourses.Add(course); db.SaveChanges(); string message = "Course Registered!"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult AddFee(StudentFeeViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var student = db.Students.Where(x => x.RegisterationNumber == collection.StudentId).First(); StudentFee fee = new StudentFee(); fee.StudentId = student.Id; fee.Amount = collection.Amount; fee.Date = collection.Date; fee.Status = "UnPaid"; db.StudentFees.Add(fee); db.SaveChanges(); string message = "Student fee Added!"; return(RedirectToAction("Account", "Management", new { Message = message })); }
public ActionResult UpdateStudent(int id, StudentViewModel collection) { DBSmartSchoolWebPortalEntities111 ent = new DBSmartSchoolWebPortalEntities111(); Student student = ent.Students.Where(x => x.Id == id).First(); if (collection.Name == null) { collection.Name = student.Name; } if (collection.Contact == null) { collection.Contact = student.Contact; } if (collection.Email == null) { collection.Email = student.Email; } if (collection.UserName == null) { collection.UserName = student.UserName; } if (collection.Password == null) { collection.Password = student.Password; } if (collection.RegisterationNumber == null) { collection.RegisterationNumber = student.RegisterationNumber; } student.Name = collection.Name; student.Contact = collection.Contact; student.Email = collection.Email; student.RegisterationNumber = collection.RegisterationNumber; student.UserName = student.UserName; student.Password = student.Password; ent.SaveChanges(); return(RedirectToAction("ViewAllStudent")); }
public ActionResult AcceptRequestHostel(int id) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); var request = db.HostelRequests.Where(x => x.Id == id).First(); RegisteredHostel hostelreg = new RegisteredHostel(); hostelreg.StudentId = request.StudentId; hostelreg.HostelId = request.HostelId; hostelreg.RegisterationDate = DateTime.Now; request.Status = 1; var student = db.Students.Where(x => x.Id == request.StudentId).First(); db.RegisteredHostels.Add(hostelreg); db.SaveChanges(); //Sending mail to Student that his/her Hostel Request is accepted! using (MailMessage mailMessage = new MailMessage(MailUserName, student.Email)) { mailMessage.Subject = "Hi!"; mailMessage.Body = "This mail is from Smart School Web Portal admin! Your Hostel Request is Accepted!"; mailMessage.IsBodyHtml = false; using (SmtpClient smtp = new SmtpClient()) { smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(MailUserName, MailPassword); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mailMessage); } } string message = "Hostel Request Accepted!"; return(RedirectToAction("Account", "Management", new { Message = message })); }