Ejemplo n.º 1
0
        /// <summary>
        /// get login Student information by stuID
        /// </summary>
        public StudentInfoModel getStudentInfoByID(string stuID)
        {
            StudentInfoModel stu  = null;
            string           comd = "select stuid,stuname,stupwd,schoolid,headpath,collegeid,professionid,stuclass,entrance,nowborrows,nowscredit from StudentInfo where stuID = @stuID";

            SqlParameter[] ps = { new SqlParameter("@stuID", stuID) };
            SQLHelper      h  = new SQLHelper();

            using (SqlDataReader read = h.getDataReader(comd, ps))
            {
                if (read.HasRows)
                {
                    while (read.Read())
                    {
                        stu              = new StudentInfoModel();
                        stu.StuID        = read["stuID"].ToString();
                        stu.StuName      = read["stuName"].ToString();
                        stu.StuPwd       = read["stuPwd"].ToString();
                        stu.SchoolID     = read["schoolID"].ToString();
                        stu.CollegeID    = read["collegeID"].ToString();
                        stu.ProfessionID = read["professionID"].ToString();
                        stu.StuClass     = read["stuClass"].ToString();
                        stu.NowBorrows   = Convert.ToInt32(read["nowBorrows"]);
                        stu.NowsCredit   = Convert.ToInt32(read["nowsCredit"]);
                        stu.HeadPath     = read["headPath"].ToString();
                        stu.Entrance     = Convert.ToDateTime(read["entrance"]);
                    }
                }
            }
            return(stu);
        }
Ejemplo n.º 2
0
 public StudentInfoModel DepartmentId(string DepartmentId)
 {
     try
     {
         var query  = "SELECT * FROM tblStudentInfo WHERE DepartmentId='" + DepartmentId + "'";
         var reader = _sDB.ExecuteReader(query, _connectionString);
         if (reader.HasRows)
         {
             reader.Read();
             var StudentInfoModel = new StudentInfoModel()
             {
                 Id           = Convert.ToInt32(reader["Id"]),
                 StudentId    = Convert.ToInt32(reader["StudentId"]),
                 DepartmentId = Convert.ToInt32(reader["DepartmentId"]),
                 CourseId     = Convert.ToInt32(reader["CourseId"]),
             };
             return(StudentInfoModel);
         }
         return(null);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
        public List <StudentInfoModel> GetAllStudents()
        {
            var getAllStudents = from allStudents in _context.tblStudent
                                 select allStudents;

            //var getAllStudents = _context.tblStudent.Where(student => student.).FirstOrDefault();

            List <StudentInfoModel> studentsList = new List <StudentInfoModel>();

            foreach (var singleStudent in getAllStudents)
            {
                StudentInfoModel student = new StudentInfoModel()
                {
                    StudentID     = singleStudent.StudentID,
                    FirstName     = singleStudent.FirstName,
                    LastName      = singleStudent.LastName,
                    ContactNumber = singleStudent.ContactNumber,
                    EmailAddress  = singleStudent.EmailAddress
                };

                studentsList.Add(student);
            }

            return(studentsList);
            //return _context.tblStudent.ToList();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// ----   begin log in
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            lblP.Visible = false;
            lblU.Visible = false;
            MainForm main = new MainForm();

            if (this.rdoUser.Checked == true)
            {
                StudentInfoModel student = new StudentInfoModel();

                if (checkStudent(out student))
                {
                    getLoginStudent login = new getLoginStudent(main.getLoginStudent);
                    login(student);
                    main.Show();
                    this.Hide();
                }
            }
            else
            {
                AdminInfoModel admin = new AdminInfoModel();

                if (checkAdmin(out admin))
                {
                    getLoginAdmin login = new getLoginAdmin(main.getLoginAdmin);
                    login(admin);
                    main.Show();

                    this.Hide();
                }
            }
        }
        public static List <StudentInfoModel> GetStudents()
        {
            try
            {
                IEnumerable <tblStudent> lstStudents = _unitOfWork.StudentRepository.Get();

                List <StudentInfoModel> studentsList = new List <StudentInfoModel>();

                foreach (var singleStudent in lstStudents)
                {
                    StudentInfoModel student = new StudentInfoModel()
                    {
                        StudentID     = singleStudent.StudentID,
                        FirstName     = singleStudent.FirstName,
                        LastName      = singleStudent.LastName,
                        ContactNumber = singleStudent.ContactNumber,
                        EmailAddress  = singleStudent.EmailAddress
                    };

                    studentsList.Add(student);
                }
                return(studentsList);
            }
            catch (Exception e)
            {
                string currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                ErrorLogger.LogException(e, currentFile);
                List <StudentInfoModel> studentsList = new List <StudentInfoModel>();
                return(studentsList);
            }
        }
Ejemplo n.º 6
0
 public JsonResult UpdateStudentInfo(StudentInfoModel model)
 {
     try
     {
         var result = StudentBusiness.UpdateStudentInfo(model);
         if (result != null)
         {
             if (Request.Files.Count > 0)
             {
                 UploadStudentResume(result.studentId);
             }
         }
         var response = new ApiRespnoseWrapper {
             status = ApiRespnoseStatus.Success, results = new ArrayList()
             {
                 result
             }
         };
         return(new JsonResult {
             Data = response, JsonRequestBehavior = JsonRequestBehavior.AllowGet
         });
     }
     catch (Exception ex)
     {
         return(CommonBusiness.GetErrorResponse(ex.Message));
     }
 }
Ejemplo n.º 7
0
 public static StudentInfoModel UpdateStudentInfo(StudentInfoModel model)
 {
     using (var context = new MakeMyJobsEntities())
     {
         StudentInfoModel studentInfo = new StudentInfoModel();
         int updated = 0;
         var user    = context.Users.FirstOrDefault(x => x.UserId == model.userId && x.IsActive == 1);
         var student = context.Students.FirstOrDefault(x => x.StudentId == model.studentId);
         if (user == null || student == null)
         {
             return(null);
         }
         else
         {
             user.Email            = model.email;
             updated              += context.SaveChanges();
             student.FirstName     = model.firstName;
             student.LastName      = model.lastName;
             student.ContactNumber = model.contactNumber;
             student.DateOfBirth   = model.dateOfBirth;
             student.CollegeName   = model.collegeName;
             student.Address       = model.address;
             student.State         = model.state;
             student.Country       = model.country;
             student.ZipCode       = model.zipCode;
             updated              += context.SaveChanges();
         }
         return(GetUpdatedStudentInfo(user.UserId, student.StudentId));
     }
 }
Ejemplo n.º 8
0
 public static StudentInfoModel GetStudentInfoForEdit(int id)
 {
     using (var context = new MakeMyJobsEntities())
     {
         if (context.Students.Any(x => x.UserId == id))
         {
             StudentInfoModel studentInfoModel = context.Students.Join(context.Users, s => s.UserId, u => u.UserId, (s, u) => new StudentInfoModel()
             {
                 studentId     = s.StudentId,
                 userId        = s.UserId,
                 firstName     = s.FirstName,
                 lastName      = s.LastName,
                 collegeName   = s.CollegeName,
                 contactNumber = s.ContactNumber,
                 dateOfBirth   = s.DateOfBirth,
                 resume        = s.Resume,
                 dateJoined    = s.DateJoined,
                 address       = s.Address,
                 state         = s.State,
                 country       = s.Country,
                 email         = u.Email,
                 zipCode       = s.ZipCode
             }).FirstOrDefault(x => x.userId == id);
             return(studentInfoModel);
         }
         else
         {
             return(null);
         }
     }
 }
Ejemplo n.º 9
0
        public async Task <MessageModel <string> > PostAddStudent(StudentInfoModel studentInfo)
        {
            if (ModelState.IsValid)
            {
                var addStudent = await _studentInfoService.Add(new StudentInfo()
                {
                    Name          = studentInfo.Name,
                    StudentNumber = studentInfo.StudentNumber,
                    Sex           = studentInfo.Sex,
                    Age           = studentInfo.Age,
                });

                return(new MessageModel <string>()
                {
                    msg = "添加学生信息成功",
                    status = 200,
                    success = true,
                    response = addStudent.ToString()
                });
            }
            else
            {
                return(new MessageModel <string>()
                {
                    msg = "添加学生信息失败",
                    success = false,
                });
            }
        }
Ejemplo n.º 10
0
        private void btnupdate_Click(object sender, EventArgs e)
        {
            StudentInfoModel stu = new StudentInfoModel();

            stu = (StudentInfoModel)dgvStudent.CurrentRow.DataBoundItem;
            StudentInfoBLL stubll = new StudentInfoBLL();

            stubll.updateStudentInfo(stu);
        }
Ejemplo n.º 11
0
        public IActionResult GetStudentById([FromBody] StudentInfoModel model)
        {
            var student = _student.GetStudentById(model.Id);

            if (student == null)
            {
                return(BadRequest());
            }

            return(Ok(MapStudentObject(student)));
        }
        private IActionResult GetTestStudentById(int studentId)
        {
            var studentInfoModel = new StudentInfoModel
            {
                Id = studentId
            };

            _studentDataMock.Setup(x => x.GetStudentById(It.IsAny <int>()))
            .Returns(new User());

            return(_studentController.GetStudentById(studentInfoModel));
        }
Ejemplo n.º 13
0
        // GET: Student
        public ActionResult Index()
        {
            List <StudentInfoModel> studentInfoModels = new StudentInfoModel().GetStudentList();

            if (studentInfoModels != null && studentInfoModels.Count > 0)
            {
                return(View(studentInfoModels));
            }
            else
            {
                return(View(new List <StudentInfoModel>()));
            }
        }
Ejemplo n.º 14
0
 public bool Save(StudentInfoModel category)
 {
     try
     {
         var query       = "INSERT INTO tblStudentInfo (StudentId, DepartmentId, CourseId) VALUES('" + category.StudentId + "','" + category.DepartmentId + "','" + category.CourseId + "')";
         var rowAffected = _sDB.ExecuteNonQuery(query, _connectionString);
         return(rowAffected > 0);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Ejemplo n.º 15
0
 public ActionResult Create(StudentInfoModel model)
 {
     try
     {
         // TODO: Add insert logic here
         model.InsertStudent(model);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 16
0
        void OnSubgroupPickerSelectedIndexChanged(object sender, EventArgs e)
        {
            var picker        = (Picker)sender;
            int selectedIndex = picker.SelectedIndex;

            if (selectedIndex != -1)
            {
                String selectedSubgroup = (string)picker.ItemsSource[selectedIndex];
                StudentInfoModel.Subgroup = selectedSubgroup;
                StudentInfoModel.SaveLoginInfo();
                Login.IsVisible = true;
            }
        }
Ejemplo n.º 17
0
 public ActionResult Delete(StudentInfoModel model)
 {
     try
     {
         // TODO: Add delete logic here
         model.DeleteStudent(model.id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 18
0
 public ActionResult Edit(StudentInfoModel model)
 {
     try
     {
         // TODO: Add update logic here
         model.UpdateStudent(model);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public void GetStudentById_ShouldReturnABadRequestResult_WhenNoStudentIdIsGiven()
        {
            var studentInfoModel = new StudentInfoModel
            {
                Id = 1
            };

            _studentDataMock.Setup(x => x.GetStudentById(It.IsAny <int>()))
            .Returns((User)null);

            var result = _studentController.GetStudentById(studentInfoModel);

            Assert.AreEqual(result.GetType(), typeof(BadRequestResult));
        }
Ejemplo n.º 20
0
    public int SaveMst(StudentInfoModel student)
    {
        var connection = new SqlConnection(DataManager.OraConnString());

        connection.Open();
        // string variables =
        //    "Sl_Id,NID,StdName,StdPhoneNo,FthName,FthPhoneNo,MthName,MthPhoneNo,DBO,Email,Nationality,Religion,MaritalStatus,LastEducation,Bord,Result,PresentAddress,ParVill,ParPO,ParPS,ParDistrict,AddDate";
        string variables = "Sl_Id,NID,StdName,StdPhoneNo,FthName,FthPhoneNo,MthName,MthPhoneNo,DBO,Email,Nationality,Religion,MaritalStatus,LastEducation,Bord,Result,PresentAddress,ParVill,ParPO,ParPS,ParDistrict,AddDate";



        string valus = "  '" + student.SlNo + "','" + student.NID + "','" + student.Name + "','" +
                       student.StdPhone + "','" + student.FthName + "','" + student.FthPhone + "','" +
                       student.MthName + "','" + student.MthPhone + "',convert(datetime,nullif('" + student.DBO + "',''),103),'" + student.Email +
                       "','" + student.Nationality + "','" + student.Religion + "','" + student.MaritalStatus +
                       "','" + student.LastEducation + "','" + student.Bord + "','" + student.Result + "','" + student.PresentAddress + "','" + student.ParVill +
                       "','" + student.ParPO + "','" + student.ParPS + "','" + student.ParDis + "',  GETDate() ";
        string query = "";

        if (student.StdPhoto != null)
        {
            if (student.StdPhoto.Length > 0)
            {
                variables = variables + ",StdPhoto";
                valus     = valus + ",@img";
            }
        }

        query = "Insert Into StudetnInfoMst (" + variables + ") Values (" + valus + ")";
        var          command = new SqlCommand(query, connection);
        SqlParameter img     = new SqlParameter();

        img.SqlDbType     = SqlDbType.VarBinary;
        img.ParameterName = "img";
        img.Value         = student.StdPhoto;
        command.Parameters.Add(img);
        if (student.StdPhoto == null)
        {
            command.Parameters.Remove(img);
        }
        else
        {
            if (student.StdPhoto.Length == 0)
            {
                command.Parameters.Remove(img);
            }
        }

        return(command.ExecuteNonQuery());
    }
Ejemplo n.º 21
0
 /// <summary>
 /// 获取登录的学生用户
 /// </summary>
 /// <param name="stu"></param>
 public void getLoginStudent(StudentInfoModel stu)
 {
     lblShowID.Text   = "编号:" + stu.StuID;
     lblShowName.Text = "用户名:" + stu.StuName;
     try
     {
         if (!string.IsNullOrEmpty(stu.HeadPath))
         {
             picHead.Image = Image.FromFile(stu.HeadPath);
         }
     }
     catch { }
     id  = stu.StuID;
     pro = "student";
 }
Ejemplo n.º 22
0
        /// <summary>
        /// update Student information by model
        /// </summary>
        /// <param name="stu"></param>
        /// <returns></returns>
        public int updateStudentInfo(StudentInfoModel stu)
        {
            string comd = "update StudentInfo set stuName=@stuName,stuPwd=@stuPwd,headPath=@headPath where stuID=@stuID ";

            SqlParameter[] ps =
            {
                new SqlParameter("@stuName",  stu.StuName),
                new SqlParameter("@stuPwd",   stu.StuPwd),
                new SqlParameter("@headPath", stu.HeadPath),
                new SqlParameter("@stuID",    stu.StuID)
            };
            SQLHelper h = new SQLHelper();

            return(h.ExecuteNonQuery(comd, ps));
        }
Ejemplo n.º 23
0
    public int Save(StudentInfoModel student)
    {
        var            connection = new SqlConnection(DataManager.OraConnString());
        SqlTransaction transaction;

        try
        {
            connection.Open();
            transaction = connection.BeginTransaction();
            var command = new SqlCommand();
            command.Connection  = connection;
            command.Transaction = transaction;
            var command1 = new SqlCommand();
            command1.Connection  = connection;
            command1.Transaction = transaction;
            var Command2 = new SqlCommand();
            Command2.Connection  = connection;
            Command2.Transaction = transaction;

            command.CommandText = @"SELECT TOP(1)[ID] FROM StudetnInfoMst ORDER BY ID DESC";
            int ID = Convert.ToInt32(command.ExecuteScalar());
            command.CommandText = " INSERT INTO dbo.StudentInfoDtl (MstId,CourseName,TrainerName,BatchNo,ClassTime,APM,AdmissionDate,CourseFee,Waiver,DisCount,TotalAmount,PayAmount,AddmissionYear,CertificationDate) VALUES('" + ID + "','" + student.CourseName + "','" + student.TrainerName + "','" + student.BatchNo + "','" + student.ClassTime + "','" + student.APM + "', convert(datetime,nullif('" + student.AdmissionDate + "',''),103),'" + student.CourseFee + "','" + student.Waiver + "','" + student.DisCount + "','" + student.TotalAmount + "','" + student.PayAmount + "','" + student.AddmissionYear + "',convert(datetime,nullif('" + student.CertificationDate + "',''),103) ) ";
            command.ExecuteNonQuery();
            command1.CommandText =
                "insert into Day_Information(StudentID,StarDay,Sunday,MonDay,TusesDay,WednessDay,ThusDay,Friday) values('" +
                ID + "','" + student.SatDay + "','" + student.SunDay + "','" + student.MonDay + "','" + student.TuesDay +
                "','" + student.WednessDay + "','" + student.ThusDay + "','" + student.FriDay + "')";

            command1.ExecuteNonQuery();
            Command2.CommandText =
                "Insert Into StdPaymentDtls (StudentId,CourseFee,Waiver,Discount,TotalAmount,PaidAmount) values('" + ID + "','" + student.CourseFee + "','" + student.Waiver + "','" + student.DisCount + "','" + student.TotalAmount + "','" + student.PayAmount + "')";
            int success = Command2.ExecuteNonQuery();
            transaction.Commit();
            return(success);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
        finally
        {
            if (connection.State == ConnectionState.Open)
            {
                connection.Close();
            }
        }
    }
Ejemplo n.º 24
0
        public static StudentInfoModel GetStudentInfo(int id)
        {
            using (var context = new MakeMyJobsEntities())
            {
                if (context.Students.Any(x => x.UserId == id))
                {
                    StudentInfoModel studentInfoModel = context.Students.Join(context.States, s => s.State, st => st.StateId, (s, st) => new
                    {
                        StateName = st.StateName,
                        student   = s
                    }).Join(context.Countries, s => s.student.Country, c => c.CountryId, (s, c) => new
                    {
                        student     = s,
                        stateName   = s.StateName,
                        countryName = c.CountryName
                    }).Join(context.Users, s => s.student.student.UserId, u => u.UserId, (s, u) => new StudentInfoModel()
                    {
                        studentId     = s.student.student.StudentId,
                        userId        = s.student.student.UserId,
                        firstName     = s.student.student.FirstName,
                        lastName      = s.student.student.LastName,
                        collegeName   = s.student.student.CollegeName,
                        contactNumber = s.student.student.ContactNumber,
                        dateOfBirth   = s.student.student.DateOfBirth,
                        resume        = s.student.student.Resume,
                        dateJoined    = s.student.student.DateJoined,
                        address       = s.student.student.Address + ", " + s.student.StateName + ", " + s.countryName,
                        state         = s.student.student.State,
                        country       = s.student.student.Country,
                        email         = u.Email,
                        zipCode       = s.student.student.ZipCode
                    }).FirstOrDefault(x => x.userId == id);

                    if (context.StudentDocuments.Any(x => x.StudentId == studentInfoModel.studentId && x.DocumentType == StudentDocumentTypes.Resume))
                    {
                        studentInfoModel.resume = "1";
                    }

                    return(studentInfoModel);
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 25
0
        public IActionResult AddStudentInfo(int studentInfoId, string operationType)
        {
            var model = new StudentInfoModel(studentInfoId, operationType, _studentInfoService, _courseService, _programService);

            ViewBag.ProgramList     = new SelectList(_programService.Where(x => x.IsDeleted == false), "Id", "Name");
            ViewBag.ProjectTyepList = new SelectList(_projectTypeService.Where(x => x.IsDeleted == false), "Id", "Name");
            if (operationType == Constants.OperationType.Update)
            {
                ViewBag.CourseList = new SelectList(_courseService.Where(x => x.ProgramsId == model.ProgramsId && x.IsDeleted == false), "Id", "Name");
            }
            else
            {
                ViewBag.CourseList = new SelectList(string.Empty, "Value", "Text");
            }
            _session.SetString("OperationType", operationType);
            return(PartialView("_AddStudentInfo", model));
        }
        public ActionResult EditInfo(StudentInfoModel model)
        {
            if (ModelState.IsValid)
            {
                // Get the currently logged in student.
                var student = Student;

                // Map the new values from the view model to the current student.
                Mapper.Map(model, student);

                // Update the student in the database.
                StudentRepository.Update(student);

                return(RedirectToAction("Dashboard"));
            }

            return(View(model));
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 填充对象
        /// </summary>
        /// <param name="list"></param>
        /// <param name="read"></param>
        private static void FillModel(List <StudentInfoModel> list, SqlDataReader read)
        {
            StudentInfoModel stu = new StudentInfoModel();

            stu.StuID        = read["stuID"].ToString();
            stu.StuName      = read["stuName"].ToString();
            stu.StuPwd       = read["stuPwd"].ToString();
            stu.SchoolID     = read["schoolName"].ToString();
            stu.CollegeID    = read["collegeName"].ToString();
            stu.ProfessionID = read["professionName"].ToString();
            stu.StuClass     = read["stuClass"].ToString();
            stu.NowBorrows   = Convert.ToInt32(read["nowBorrows"]);
            stu.NowsCredit   = Convert.ToInt32(read["nowsCredit"]);
            stu.HeadPath     = read["headPath"].ToString();
            stu.Entrance     = Convert.ToDateTime(read["entrance"]);

            list.Add(stu);
        }
Ejemplo n.º 28
0
    public int UpdateMst(StudentInfoModel student, string MstId)
    {
        var connection = new SqlConnection(DataManager.OraConnString());

        connection.Open();
        string variables =
            "Update StudetnInfoMst set NID ='" + student.NID + "',StdName ='" + student.Name + "',StdPhoneNo ='" + student.StdPhone + "',FthName ='" + student.FthName + "',FthPhoneNo ='" + student.FthPhone + "',MthName ='" + student.MthName + "',MthPhoneNo ='" + student.MthPhone + "',DBO = convert(datetime,nullif('" + student.DBO + "',''),103),Email ='" + student.Email + "',Nationality ='" + student.Nationality + "',Religion ='" + student.Religion + "',MaritalStatus ='" + student.MaritalStatus + "',LastEducation ='" + student.LastEducation + "',Bord='" + student.Bord + "',Result='" + student.Result + "',PresentAddress ='" + student.PresentAddress + "',ParVill ='" + student.ParVill + "',ParPO ='" + student.ParPO + "',ParPS ='" + student.ParPS + "',ParDistrict ='" + student.ParDis + "',UpdateDate=GETDATE()";

        string query = "";

        if (student.StdPhoto != null)
        {
            if (student.StdPhoto.Length > 0)
            {
                variables = variables + ",StdPhoto = @img";
            }
        }

        string WHERE = "Where Id='" + MstId + "'";

        query = "" + variables + " " + WHERE + "";
        var          command = new SqlCommand(query, connection);
        SqlParameter img     = new SqlParameter();

        img.SqlDbType     = SqlDbType.VarBinary;
        img.ParameterName = "img";
        img.Value         = student.StdPhoto;
        command.Parameters.Add(img);
        if (student.StdPhoto == null)
        {
            command.Parameters.Remove(img);
        }
        else
        {
            if (student.StdPhoto.Length == 0)
            {
                command.Parameters.Remove(img);
            }
        }

        return(command.ExecuteNonQuery());
    }
Ejemplo n.º 29
0
        public void ParseStudentNameCSV(string filepath)
        {
            //Reads the contents of the CSV files as individual lines
            string[] lines = System.IO.File.ReadAllLines(filepath);
            //Split each row into column data
            bool isFirst = true;

            foreach (var line in lines)
            {
                //creates a new Student
                if (isFirst)//handles a header for the file so it is not added to the data
                {
                    isFirst = false;
                    continue;
                }
                StudentInfoModel st = new StudentInfoModel(line);
                //adds our newly created student to our Students List
                Students.Add(st);
            }
        }
 // To Insert Student Info in Student Table
 public int InsertStudentInfo(StudentInfoModel model, string UserName)
 {
     using (var context = new JustHallAtumationEntities())
     {
         var     user    = context.Users.Where(x => x.UserName == UserName).FirstOrDefault();
         Student student = new Student()
         {
             StudentName  = model.StudentName,
             FatherName   = model.FatherName,
             MobileNumber = model.MobileNumber,
             MotherName   = model.MotherName,
             RoomId       = model.RoomId,
             PaymentId    = model.PaymentId,
             UserId       = user.UserId
         };
         context.Students.Add(student);
         context.SaveChanges();
         return(student.StudentId);
     }
 }