Exemplo n.º 1
0
        public ActionResult StudentDepartmentInformation(StudentDepartmentInformationModel model)
        {
            string UserName = (string)(Session["UserName"]);

            if (ModelState.IsValid)
            {
                int id = studentDepartmentInformation.AddStudentDepartmentInformation(model, UserName);
                if (id > 0)
                {
                    ModelState.Clear();
                    ViewBag.Success = "Data inserted";
                }
            }
            return(View());
        }
 public int AddStudentDepartmentInformation(StudentDepartmentInformationModel model, string UserName)
 {
     using (var context = new HallAutomationSystemEntities())
     {
         int Dept_Name = GetDepartmentId(model.Department_name);
         if (Dept_Name == 0)
         {
             return(0);
         }
         DepartmentInfo departmentInfo = new DepartmentInfo()
         {
             DepartmentId = Dept_Name,
             StudentId    = GetStudentId(UserName),
             Session      = model.Session,
             Cgpa         = model.Cgpa
         };
         context.DepartmentInfo.Add(departmentInfo);
         context.SaveChanges();
         return(departmentInfo.StudentId);
     }
 }