Example #1
0
 public HV_Students Create(string name, int age, string gender, int yearOfStudy, string bio, int groupId, int courseId,bool isAdmin,bool isGroupLeader,bool isGroupMember, bool isIndividual, string username, string password)
 {
     using (var u = GetDb())
     {
         var student = new HV_Students()
         {
             Stu_name = name,
             Stu_age = age, 
             Stu_gender = gender,
             Stu_yearOfStudy = yearOfStudy,
             Stu_bio = bio,
             Grp_Id = groupId,
             Course_Id = courseId,
             Stu_IsAdmin = isAdmin,
             Stu_IsGroupLeader = isGroupLeader,
             Stu_IsGroupMember = isGroupMember,
             Stu_IsIndividual = isIndividual,
             Stu_Password = password,
             Stu_Username = username
         };
         u.HV_Students.Add(student);
         u.SaveChanges();
         return student;
     }
 }
Example #2
0
 public HV_Students Delete (HV_Students student)
 {
     using (var u = GetDb())
     {
         u.HV_Students.Attach(student);
         u.HV_Students.Remove(student);
         u.SaveChanges();
         return student;
     }
 }
Example #3
0
 public ActionResult Login(HV_Students student, string returnUrl)
 {
     string username = student.Stu_Username;
     string password = student.Stu_Password;
     if (ModelState.IsValid)
     {
         var u = stu.CheckUserLogin(username, password);
         if (u != null )
         {
             FormsAuthentication.SetAuthCookie(student.Stu_Username, false);
             if (Url.IsLocalUrl(returnUrl))
             {
                 return Redirect(returnUrl);
             }
             return RedirectToAction("Index", "Home");
         }
         ModelState.AddModelError("", "Incorrect username or password");
         return View();
     }
     return RedirectToAction("Index", "Home");
 }