// GET: Student public ActionResult Index() { StudentEntities te = new StudentEntities(); var stud = te.Students.ToList(); return(Json(stud, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage Put(int id, [FromBody] Student employee) { using (StudentEntities db = new StudentEntities()) { try { var entity = db.Students.FirstOrDefault(e => e.ID == id); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Student with id=" + id.ToString() + "not found to update")); } else { entity.Name = employee.Name; entity.Gender = employee.Gender; entity.Age = employee.Age; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, entity)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } } }
public int UpdateStudent(Stu s, int type) { int result = 0; Student student = new Student(); if (type == 1) { student = en.Students.Where(x => x.ID == s.ID).FirstOrDefault(); } student.NRIC = s.NRIC; student.Name = s.StudentName; student.Birthday = s.Birthday; student.AvailableDate = s.AvailableDate; student.Gender = s.Gender; student.English = s.English; student.Math = s.Math; student.Science = s.Science; using (StudentEntities context = new StudentEntities()) { if (type == 0) { context.Students.Add(student); } else { context.Entry(student).State = System.Data.Entity.EntityState.Modified; } context.SaveChanges(); } return(result); }
public JsonResult GetStudentRecordsByParent(DateTime startTime, DateTime endTime) { using (StudentEntities studentEntities = new StudentEntities()) { var childs = studentEntities.Stu_FamilyStuRel.Where(p => p.JZID == userId).Select(p => p.XSID).ToList(); if (childs.Count == 0) { return(Json("", JsonRequestBehavior.AllowGet)); } var url = System.Configuration.ConfigurationManager.AppSettings["APIHttp"]; JsonServiceClient client = new JsonServiceClient(url + "/SNSAPI/"); List <UserActiveEntryDto> result = new List <UserActiveEntryDto>(); foreach (var child in childs) { result.AddRange(client.Get(new GetUserAction() { ObjectType = "考勤", UID = child.ToString(), Date = startTime, DateBak = endTime, PageSize = Int32.MaxValue, CurPage = 0 })); } return(Json(result.Select(p => new { p.UName, p.Comment, p.Date }).OrderBy(p => p.Date).ToList(), JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id, FormCollection collection) { //try //{ // // TODO: Add delete logic here // return RedirectToAction("Index"); //} //catch //{ // return View(); //} try { using (var context = new StudentEntities()) { Student item = context.Students.Find(id); if (item != null) { context.Students.Remove(item); context.SaveChanges(); } } return(RedirectToAction("Index")); } catch (Exception) { return(View()); } }
public ActionResult Create(Student1 obj) { StudentEntities studobj = new StudentEntities(); studobj.Student1.Add(obj); studobj.SaveChanges(); var department = new List <SelectListItem> { new SelectListItem { Text = "CS", Value = "1" }, new SelectListItem { Text = "ECE", Value = "2" }, new SelectListItem { Text = "EEE", Value = "3" } }; ViewBag.Department = department; //Student user = new Student(); //UpdateModel(user); return(View()); }
public Student GetStudent(int id) { using (StudentEntities context = new StudentEntities()) { return(context.Students.Where(x => x.ID == id).FirstOrDefault()); } }
// GET: Student public ActionResult Index() { //StudentEntity //return View(); using (var context = new StudentEntities()) { List <Student> students = context.Students.ToList(); List <StudentModel> lstST = new List <StudentModel>(); foreach (var item in students) { //StudentModel s = new StudentModel( { // DOB = item.DOB.Value, StudentAddress = item.StudentAddress, StudentAge = item.StudentAge.Value , StudentEmail = item.StudentEmail, StudentId = item.StudentId, StudentMobileNo = item.StudentMobileNo.Value, StudentName= item.StudentName //}) StudentModel s = new StudentModel(); s.DOB = item.DOB.Value; s.StudentAddress = item.StudentAddress; s.StudentAge = item.StudentAge.Value; s.StudentEmail = item.StudentEmail; s.StudentId = item.StudentId; s.StudentMobileNo = item.StudentMobileNo.Value; s.StudentName = item.StudentName; lstST.Add(s); } return(View(lstST)); } }
public List <StudentDetail> GetStudentDetail() { using (var dbContext = new StudentEntities()) { var students = (from p in dbContext.StudentDetails join f in dbContext.Students on p.Student_ID equals f.Student_ID join s in dbContext.Subjects on p.Subject_ID equals s.SubjectID select new { StudentDetials_ID = p.StudentDetials_ID, Marks = p.Marks, //Class = p.Class, First_Name = f.First_Name, Last_Name = f.Last_Name, Subject_Name = s.Subject_Name }).ToList().Select(x => new StudentDetail() { First_Name = x.First_Name, Last_Name = x.Last_Name, Marks = x.Marks, //Class = x.Class, Subject_Name = x.Subject_Name, StudentDetials_ID = x.StudentDetials_ID }); return(students.ToList()); } }
// GET: City public ActionResult Index() { StudentEntities te = new StudentEntities(); var city = te.CityLists.ToList(); return(Json(city, JsonRequestBehavior.AllowGet)); }
public ActionResult GridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] Testiranje2.Models.Ispit item) { var model = db.Ispits; if (ModelState.IsValid) { try { using (StudentEntities se = new StudentEntities()) { se.Entry(item).State = EntityState.Modified; se.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_GridViewPartial", model.ToList())); }
public string EditStudentDetails(StudentDetail detail) { using (var dbContext = new StudentEntities()) { using (DbContextTransaction transaction = dbContext.Database.BeginTransaction()) { try { var studentDetails = dbContext.StudentDetails.Where(x => x.StudentDetials_ID == detail.StudentDetials_ID).FirstOrDefault(); var student = dbContext.Students.Where(x => x.Student_ID == studentDetails.Student_ID).FirstOrDefault(); var subject = dbContext.Subjects.Where(x => x.SubjectID == studentDetails.Subject_ID).FirstOrDefault(); if (studentDetails != null) { studentDetails.Marks = detail.Marks; studentDetails.Class = detail.Class; student.First_Name = detail.First_Name; student.Last_Name = detail.Last_Name; subject.Subject_Name = detail.Subject_Name; dbContext.Entry(studentDetails).State = EntityState.Modified; dbContext.Entry(student).State = EntityState.Modified; dbContext.Entry(subject).State = EntityState.Modified; dbContext.SaveChanges(); transaction.Commit(); } } catch (Exception ex) { transaction.Rollback(); return(ex.Message); } } } return("success"); }
public ActionResult Index() { StudentEntities obj = new StudentEntities(); List <SelectListItem> listitem = new List <SelectListItem>(); foreach (tblCity city in obj.tblCities) { SelectListItem selectlistitem = new SelectListItem() { Text = city.Name, Value = city.ID.ToString(), Selected = city.IsSelected }; listitem.Add(selectlistitem); } CitiesViewModel CitiesViewModel = new CitiesViewModel(); CitiesViewModel.Cities = listitem; return(View(CitiesViewModel)); }
public IEnumerable <Student> GetEmployees() { using (StudentEntities db = new StudentEntities()) { return(db.Students.ToList()); } }
public List <Student> GetStudents() { using (StudentEntities ss = new StudentEntities()) { return(ss.Students.ToList()); } }
public void CreateStudent(Student student) { StudentEntities db = new StudentEntities(); db.Student.Add(student); try { db.SaveChanges(); } catch (DbUpdateException error) { log.Error(error); throw; } catch (DbEntityValidationException error) { log.Error(error); throw; } catch (NotSupportedException error) { log.Error(error); throw; } catch (ObjectDisposedException error) { log.Error(error); throw; } catch (InvalidOperationException error) { log.Error(error); throw; } }
public ActionResult GetByid(int Id) { StudentEntities te = new StudentEntities(); var stud = te.Students.Where(x => x.StudentID == Id).ToList(); return(Json(stud, JsonRequestBehavior.AllowGet)); }
/* * The controller will retrieve all the actions based on the browser requests. * In this case, it will make the requests to the database using the models and * givin back an answer to the view.**/ // GET: Students public JsonResult GetStudent() { using (var database = new StudentEntities()) { List <Student> listStudents = database.Students.ToList(); return(Json(listStudents, JsonRequestBehavior.AllowGet)); } }
public PartialViewResult Menu() { var entities = new StudentEntities(); var list = new SiteActionData(); list.SiteActionList = entities.GetSiteActions(1).ToList(); return(PartialView("_Menu", list)); }
public ActionResult GetData() { using (StudentEntities db = new StudentEntities()) { List <Student> students = db.Students.ToList <Student>(); return(Json(new { data = students }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { using (StudentEntities db = new StudentEntities()) { Student student = db.Students.Where(x => x.ID == id).FirstOrDefault <Student>(); db.Students.Remove(student); db.SaveChanges(); return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetSchoolGrades() { using (StudentEntities studentEntities = new StudentEntities()) { var grades = studentEntities.View_Basic_SchClass.Where(p => p.XXID == user.xxid) .Select(p => new { p.NJDM, p.NJMC }).Distinct() .ToList(); return(Json(grades, JsonRequestBehavior.AllowGet)); } }
public ActionResult ManageTeachers() { var db = new StudentEntities(); List <Teacher> teachers = null; teachers = (from teacher in db.SchoolUsers where teacher.IsActive == true && teacher.RoleId == 2 select new Teacher { Id = teacher.Id, FirstName = teacher.FirstName, LastName = teacher.LastName, MName = teacher.MName, FName = teacher.FName, Gender = teacher.Gender, DOB = teacher.DOB, MobileNo = teacher.MobileNo, Village = teacher.Village, Mandal = teacher.Mandal, District = teacher.District, Municipality = teacher.Municipality, Habitation = teacher.Habitation, BloodGroup = teacher.BloodGroup, Caste = teacher.Caste, Religion = teacher.Religion, MotherTongue = teacher.MotherTongue, AdharNo = teacher.AdharNo, PInstituteName = teacher.PInstituteName, PIdentificationNo = teacher.PIdentificationNo, PhotoName = teacher.PhotoName, DOJ = teacher.DOJ, ClassNmae = teacher.ClassNmae, Section = teacher.Section, RollNo = teacher.RollNo, AdmissionNo = teacher.AdmissionNo, AFee = teacher.AFee, HFee = teacher.HFee, TFee = teacher.TFee, TotalFee = teacher.TotalFee, Email = teacher.Email, IsActive = teacher.IsActive, RoleId = teacher.RoleId, Qualification = teacher.Qualification, Experience = teacher.Experience, Designed = teacher.Designed, Subject = teacher.Subject, WorkType = teacher.WorkType, WorkHourPerDay = teacher.WorkHourPerDay, WorkHourPerMonth = teacher.WorkHourPerMonth }).ToList(); var teacherModel = new TeacherModel(); teacherModel.TeacherList = teachers; return(View(teacherModel)); }
public JsonResult GetSchoolClasses(string NJDM) { using (StudentEntities studentEntities = new StudentEntities()) { var classes = studentEntities.Basic_ZZJX0202.Where(p => p.XXID == user.xxid && p.NJDM == NJDM) .Select(p => new { p.BJID, p.XZBMC }).OrderBy(p => p.XZBMC) .ToList(); return(Json(classes, JsonRequestBehavior.AllowGet)); } }
public ActionResult EditStudent(int ID) { StudentEntities entities = new StudentEntities(); var Studentdata = entities.StudentDetails.Where(x => x.StudentDetials_ID == ID).FirstOrDefault(); if (Studentdata != null) { return(View(Studentdata)); } return(View()); }
public static DbContext context = GetDbContext(); //new ModelFirstDbHmEntities();// private static DbContext GetDbContext() { DbContext dbContext = (DbContext)CallContext.GetData("dbContext"); if (dbContext == null) { dbContext = new StudentEntities(); CallContext.SetData("dbContext", dbContext); } return(dbContext); }
public JsonResult GetChildList(Guid jzid) { UCHomeEntities uc = new UCHomeEntities(); StudentEntities stu = new StudentEntities(); List <Guid> rel = stu.Stu_FamilyStuRel.Where(f => f.JZID == user.userid).Select(f => f.XSID).ToList(); List <View_Simple_StuInfo> stulist = uc.View_Simple_StuInfo.Where(s => rel.Contains(s.xsid)).ToList(); return(Json(stulist, JsonRequestBehavior.AllowGet)); }
public List <ChildrenScores> GetStuScoreses() { UCHomeBasePage ucHomeBasePage = new UCHomeBasePage(); if (Session["stuscore"] == null) { StudentInfoService stuService = new StudentInfoService(); List <ChildrenScores> childrenscores = new List <ChildrenScores>(); if (usertype.ToLower() == "s") { IList <StudentInformation.StudentScores> stuScoreList = GetStudentScore(loginId, xxid, null, null, "", "").OrderBy(s => s.SchYear).ThenBy(s => s.SchTerm).ThenBy(s => s.ExamTypeCode).ToList(); List <StuScores> stuscoress = new List <StuScores>(); foreach (StudentInformation.StudentScores items in stuScoreList) { StuScores stuscores = OrderByScores(items); stuscoress.Add(stuscores); } childrenscores.Add(new ChildrenScores { xsid = loginId, XM = username, stuscores = stuscoress }); } else if (usertype.ToLower() == "p") { StudentEntities stu = new StudentEntities(); List <Stu_FamilyStuRel> family = stu.Stu_FamilyStuRel.Where(f => f.JZID == loginId).ToList(); foreach (Stu_FamilyStuRel item in family) { Guid xsid = item.XSID; UserInfo userInfo = ucHomeBasePage.GetUserInfoByRequestId(xsid); Guid schid = userInfo.xxid; IList <StudentInformation.StudentScores> stuScoreList = GetStudentScore(xsid, schid, null, null, "", "").OrderBy(s => s.SchYear).ThenBy(s => s.SchTerm).ThenBy(s => s.ExamTypeCode).ToList(); List <StuScores> stuscoress = new List <StuScores>(); foreach (StudentInformation.StudentScores items in stuScoreList) { StuScores stuscores = OrderByScores(items); stuscoress.Add(stuscores); } childrenscores.Add(new ChildrenScores { xsid = xsid, XM = userInfo.username, stuscores = stuscoress }); } } Session["stuscore"] = childrenscores; return(childrenscores); } return(Session["stuscore"] as List <ChildrenScores>); }
//Get record by id public ActionResult Edit(int id) { StudentEntities db = new StudentEntities(); var result = from x in db.Students.ToList() where x.Id == id select x; Student std = new Student(); foreach (var x in result) { std = x; } return(View(std)); }
public ActionResult EditTeacher(int id) { var db = new StudentEntities(); var teacherModel = (from teacher in db.SchoolUsers where teacher.Id == id select new Teacher { Id = teacher.Id, FirstName = teacher.FirstName, LastName = teacher.LastName, MName = teacher.MName, FName = teacher.FName, Gender = teacher.Gender, DOB = teacher.DOB, MobileNo = teacher.MobileNo, Village = teacher.Village, Mandal = teacher.Mandal, District = teacher.District, Municipality = teacher.Municipality, Habitation = teacher.Habitation, BloodGroup = teacher.BloodGroup, Caste = teacher.Caste, Religion = teacher.Religion, MotherTongue = teacher.MotherTongue, AdharNo = teacher.AdharNo, PInstituteName = teacher.PInstituteName, PIdentificationNo = teacher.PIdentificationNo, PhotoName = teacher.PhotoName, DOJ = teacher.DOJ, ClassNmae = teacher.ClassNmae, Section = teacher.Section, RollNo = teacher.RollNo, AdmissionNo = teacher.AdmissionNo, AFee = teacher.AFee, HFee = teacher.HFee, TFee = teacher.TFee, TotalFee = teacher.TotalFee, Email = teacher.Email, IsActive = teacher.IsActive, RoleId = teacher.RoleId, Qualification = teacher.Qualification, Experience = teacher.Experience, Designed = teacher.Designed, Subject = teacher.Subject, WorkType = teacher.WorkType, WorkHourPerDay = teacher.WorkHourPerDay, WorkHourPerMonth = teacher.WorkHourPerMonth }).FirstOrDefault(); TempData["Teacher"] = teacherModel; return(RedirectToAction("Teacher")); }