Ejemplo n.º 1
0
        public void test_GetLastStudentId()
        {
            databaseContextMock.Setup(t => t.Student.GetAll()).Returns(GetStudentData);
            var formInsertStudent = new InsertStudent(databaseContextMock.Object);
            var nextStudentId     = formInsertStudent.getLastStudentId();

            Assert.IsTrue(nextStudentId == 3);
        }
Ejemplo n.º 2
0
        public IActionResult InsertStudent(InsertStudent insertStudent)
        {
            var st = new Student
            {
                IndexNumber  = insertStudent.IndexNumber,
                FirstName    = insertStudent.FirstName,
                LastName     = insertStudent.LastName,
                BirthDate    = insertStudent.BirthDate,
                IdEnrollment = insertStudent.IdEnrollment
            };

            _studentContext.Student.Add(st);
            _studentContext.SaveChanges();

            return(Ok("New student added to database!"));
        }
Ejemplo n.º 3
0
        public void test_InsertStudent()
        {
            databaseContextMock.Setup(t => t.Student.GetAll()).Returns(GetStudentData);
            var formInsertStudent = new InsertStudent(databaseContextMock.Object);
            var nextStudentId     = formInsertStudent.getLastStudentId();

            var newStudent = new StudentDo()
            {
                Id           = nextStudentId,
                FirstName    = "Mihai",
                LastName     = "Popa",
                Age          = "25",
                EmailAddress = "*****@*****.**",
                Gender       = "M"
            };

            Assert.IsTrue(formInsertStudent.insertStudent(newStudent));
        }
Ejemplo n.º 4
0
        public ContentResult AddStudent(StudentsGroupsModel model)
        {
            if (ModelState.IsValid)
            {
                InsertStudent.Insert(model);

                return(new ContentResult
                {
                    StatusCode = (int)HttpStatusCode.OK
                });
            }
            else
            {
                return(new ContentResult
                {
                    StatusCode = (int)HttpStatusCode.InternalServerError
                });
            }
        }
Ejemplo n.º 5
0
        public async Task <int> InsertStudentAdmission(InsertStudent student)
        {
            using (IDbConnection conn = Connection)
            {
                var list = new List <Student>();
                list.Add(student.student);
                try
                {
                    var sqlparam = new DynamicParameters();
                    sqlparam.Add("@Student", this.service.ToDataTable(list).AsTableValuedParameter("[ams].[Student]"));
                    sqlparam.Add("@coursemap", this.service.ToDataTable(student.courses).AsTableValuedParameter("[ams].[StudentCourse]"));
                    sqlparam.Add("@Returnstatus", dbType: DbType.Int32, direction: ParameterDirection.Output);
                    var result = await conn.QueryMultipleAsync(sql : "ams.InsertStudentAdmission", param : sqlparam, commandType : CommandType.StoredProcedure);

                    int status = sqlparam.Get <int>("@Returnstatus");
                    return(status);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error", e);
                    throw;
                }
            }
        }
Ejemplo n.º 6
0
 public async Task <int> InsertStudentAdmission(InsertStudent student)
 {
     return(await repository.InsertStudentAdmission(student));
 }
        public async Task <IActionResult> InsertStudentAdmission(InsertStudent student)
        {
            int stat = await studentmanger.InsertStudentAdmission(student);

            return(Ok(stat));
        }
Ejemplo n.º 8
0
        public JsonResult InsertStudent(IndexStudentsListVM obj)
        {
            var    result  = (dynamic)null;
            string message = (dynamic)null;

            try
            {
                if (obj.Students != null)
                {
                    var Students = new InsertStudent_Students()
                    {
                        ClassId          = obj.Students.ClassId,
                        GenderId         = obj.Students.GenderId,
                        RegistrationNo   = obj.Students.RegistrationNo,
                        FirstName        = obj.Students.FirstName,
                        LastName         = obj.Students.LastName,
                        FatherName       = obj.Students.FatherName,
                        MotherName       = obj.Students.MotherName,
                        IP300X200        = obj.Students.IP300X200,
                        Year             = obj.Students.Year,
                        PresentAddress   = obj.Students.PresentAddress,
                        PermanentAddress = obj.Students.PermanentAddress,
                        DOB          = obj.Students.DOB,
                        fleImage     = obj.Students.fleImage,
                        IsActive     = obj.Students.IsActive,
                        AddedBy      = 0,
                        AddedDate    = DateTime.Now,
                        ModifiedBy   = 0,
                        ModifiedDate = DateTime.Now,
                        DataType     = null
                    };

                    var StudentPromotions = new InsertStudent_StudentPromotions()
                    {
                        ClassId      = obj.Students.ClassId,
                        StudentId    = obj.Students.Id,
                        Year         = obj.Students.Year,
                        RollNo       = obj.StudentPromotions.RollNo,
                        IsActive     = obj.Students.IsActive,
                        AddedBy      = 0,
                        AddedDate    = DateTime.Now,
                        ModifiedBy   = 0,
                        ModifiedDate = DateTime.Now,
                        DataType     = null
                    };

                    var model = new InsertStudent()
                    {
                        WebRootPath       = _he.WebRootPath,
                        Students          = Students,
                        StudentPromotions = StudentPromotions
                    };

                    message = _studentsServ.InsertStudent(model);
                    result  = Json(new { success = true, Message = message });
                }
            }
            // catch (Exception)
            catch (Exception ex)
            {
                result = Json(new { success = false, Message = "ERROR101:Students/InsertStudent - " + ex.Message });
            }

            return(result);
        }
        public string InsertStudent(InsertStudent obj)
        {
            string returnResult = (dynamic)null;

            try
            {
                var studentsList    = _studentsRepo.GetAll().ToList();
                var getregistration = (from stu in studentsList
                                       where stu.RegistrationNo == obj.Students.RegistrationNo
                                       select stu).SingleOrDefault();
                //var Studentlist = _studentsRepo.Get(obj.Students.Id);
                //var query=(from stu)

                if (getregistration == null)
                {
                    if (obj != null)
                    {
                        var AdmittedYear = DateTime.ParseExact(obj.Students.Year, "yyyy", null);
                        //[Note: insert 'states' table]
                        if (obj.Students != null)
                        {
                            var Students = new InsertStudent_Students()
                            {
                                ClassId          = obj.Students.ClassId,
                                GenderId         = obj.Students.GenderId,
                                RegistrationNo   = obj.Students.RegistrationNo,
                                FirstName        = obj.Students.FirstName,
                                LastName         = obj.Students.LastName,
                                IP300X200        = obj.Students.IP300X200,
                                AdmittedYear     = AdmittedYear,
                                PresentAddress   = obj.Students.PresentAddress,
                                PermanentAddress = obj.Students.PermanentAddress,
                                DOB          = obj.Students.DOB,
                                IsActive     = obj.Students.IsActive,
                                AddedBy      = obj.Students.AddedBy = 0,
                                AddedDate    = DateTime.Now,
                                ModifiedBy   = 0,
                                ModifiedDate = DateTime.Now,
                                FatherName   = obj.Students.FatherName,
                                MotherName   = obj.Students.MotherName,
                                DataType     = null
                            };
                            //[NOTE: Student table]
                            _studentsRepo.Insert(Students);
                            if (obj.Students.fleImage != null)
                            {
                                string imagePathIP300X200 = "ClientDictionary/Students/IP300X200/";
                                string extension          = Path.GetExtension(obj.Students.fleImage.FileName);
                                var    lastAddingRecord   = _studentsRepo.GetAll().Last();
                                if (_commonServ.CommImage_ImageFormat(lastAddingRecord.Id.ToString(), obj.Students.fleImage, obj.WebRootPath, imagePathIP300X200, 200, 300, extension).Equals(true))
                                {
                                    //[NOTE:Update image file]
                                    var imgStudent = _studentsRepo.Get(lastAddingRecord.Id);
                                    imgStudent.IP300X200 = imagePathIP300X200 + lastAddingRecord.Id + extension;
                                    _studentsRepo.Update(imgStudent);
                                }
                            }
                        }
                        Int64 getLastId = _studentsRepo.GetLastId();

                        //[NOTE: Student promotion table table]
                        if (obj.StudentPromotions != null)
                        {
                            var StudentPromotions = new InsertStudent_StudentPromotions()
                            {
                                StudentId    = getLastId,
                                ClassId      = obj.Students.ClassId,
                                RollNo       = obj.StudentPromotions.RollNo,
                                ClassYear    = AdmittedYear,
                                IsActive     = obj.Students.IsActive,
                                AddedBy      = 0,
                                AddedDate    = DateTime.Now,
                                ModifiedBy   = 0,
                                ModifiedDate = DateTime.Now,
                                DataType     = null
                            };

                            _StudentPromotionsRepo.Insert(StudentPromotions);
                        }
                    }
                    returnResult = "Saved";
                }
                else
                {
                    returnResult = "this registration number already exist";
                }
            }
            catch (Exception ex)
            {
                returnResult = "ERROR102:Insert all required Info - " + ex.Message;
            }
            return(returnResult);
        }