Example #1
0
        public IHttpActionResult Post(StudentCreate course)
        {
            var service = new StudentServicecs();

            service.CreateStudent(course);
            return(Ok());
        }
        public ActionResult Create(StudentCreate model)
        {
            if (ModelState.IsValid)
            {
                Student entity = new Student
                {
                    FirstName    = model.FirstName,
                    LastName     = model.LastName,
                    Email        = model.Email,
                    PhoneNumber  = model.PhoneNumber,
                    Birthday     = model.Birthday,
                    Faculty      = model.Faculty,
                    FacultyStart = model.FacultyStart,
                    Gender       = model.Gender
                };
                StudentOrganiserDbContext ctxx = new StudentOrganiserDbContext();


                ctxx.Students.Add(entity);
                ctxx.SaveChanges();

                save(model.academy, entity.StudentId);

                return(RedirectToAction("Index"));
            }
            return(View());
        }
Example #3
0
        public async Task <StudentUpdate> Create(StudentCreate model)
        {
            var student = new Student
            {
                Firstname = model.Firstname,
                Lastname  = model.Lastname,
                Jmbag     = model.Jmbag,
                IndexNmb  = model.IndexNmb
            };

            var errors = student.Validate();

            if (errors.Any())
            {
                throw new ValidationPropertyException(errors);
            }

            await context.Student.AddAsync(student);

            await context.SaveChangesAsync();

            return(new StudentUpdate
            {
                Id = student.Id,
                Firstname = student.Firstname,
                Lastname = student.Lastname,
                Jmbag = student.Jmbag,
                IndexNmb = student.IndexNmb
            });
        }
Example #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            StudentCreate studentCreate = new StudentCreate(_studentViewModel);

            studentCreate.ShowDialog();
            if (studentCreate.Success)
            {
                LoadData();
            }
        }
        public static Student Create(StudentCreate.CommandModel commandModel)
        {
            var student = new Student
            {
                EnrollmentDate = commandModel.EnrollmentDate,
                FirstMidName = commandModel.FirstMidName,
                LastName = commandModel.LastName,
            };

            return student;
        }
        // Create student
        public static StudentCreate.Response Handle(IRepository repository, StudentCreate.Request request)
        {
            var container = new EntityStateWrapperContainer();
            container.AddEntity(StudentFactory.Create(request.CommandModel));
            var validationDetails = repository.Save(container);

            var studentId = default(int?);
            if (!validationDetails.HasValidationIssues)
                studentId = container.FindEntity<Student>().ID;

            return new StudentCreate.Response(validationDetails, studentId);
        }
        //Adds a student into database
        public int Add(StudentCreate student)
        {
            SqlCommand cmd = new SqlCommand
                                 ("INSERT INTO Student (Name, Course, Photo, Description, Achievement, ExternalLink, EmailAddr, Password, MentorID)" +
                                 " OUTPUT INSERTED.StudentID" +
                                 " VALUES(@name, @course, @photo, @description, @achievement, @externallink, @email, @password, @mentorid)", conn);

            cmd.Parameters.AddWithValue("@name", student.Name);
            cmd.Parameters.AddWithValue("@course", student.Course);
            if (student.Photo != null)
            {
                cmd.Parameters.AddWithValue("@photo", student.Photo);
            }
            else
            {
                cmd.Parameters.AddWithValue("@photo", DBNull.Value);
            }
            if (student.Description != null)
            {
                cmd.Parameters.AddWithValue("@description", student.Description);
            }
            else
            {
                cmd.Parameters.AddWithValue("@description", DBNull.Value);
            }
            if (student.Achievement != null)
            {
                cmd.Parameters.AddWithValue("@achievement", student.Achievement);
            }
            else
            {
                cmd.Parameters.AddWithValue("@achievement", DBNull.Value);
            }
            if (student.ExternalLink != null)
            {
                cmd.Parameters.AddWithValue("@externallink", student.ExternalLink);
            }
            else
            {
                cmd.Parameters.AddWithValue("@externallink", DBNull.Value);
            }
            cmd.Parameters.AddWithValue("@email", student.EmailAddr);
            cmd.Parameters.AddWithValue("@password", student.Password);
            cmd.Parameters.AddWithValue("@mentorid", student.MentorID);

            //open connection to run command
            conn.Open();
            student.StudentID = (int)cmd.ExecuteScalar();
            //close connection
            conn.Close();
            return(student.StudentID);
        }
Example #8
0
        public void CreateStudent(StudentCreate course)
        {
            var entity = new Student()
            {
                Name = course.Name
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Students.Add(entity);
                ctx.SaveChanges();
            }
        }
        public IHttpActionResult PostProfile(StudentCreate student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateStudentService();

            if (!service.CreateStudent(student))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
Example #10
0
        public ActionResult Create(StudentCreate student)
        {
            if (!ModelState.IsValid)
            {
                return(View(student));
            }
            var svc = CreateStudentService();

            if (svc.CreateStudent(student))
            {
                return(RedirectToAction("Index"));
            }
            return(View(student));
        }
Example #11
0
        public void AddStudent()
        {
            //var student = new StudentCreate { };

            //int id = 1;
            //if (NewStudents.Any())
            //    id = NewStudents.Max(_ => _.Id) + 1;
            //else
            //    id = Students.Items.Max(_ => _.Id) + 1;
            //var student = new StudentUpdate { Id = id };
            //NewStudents.Add(student);

            NewStudent = new StudentCreate {
            };
        }
        public IActionResult Create(StudentCreate studentCreate)
        {
            var createResult = studentService.Create(studentCreate);

            if (createResult > 0)
            {
                TempData["Success"] = "Student has been created success";
            }
            else
            {
                TempData["Error"] = "Something went wrong, please try again later";
            }
            ViewBag.languages = studentService.GetLanguages();
            ViewBag.levels    = studentService.GetLevels();
            return(View());
        }
Example #13
0
        public bool CreateStudent(StudentCreate studentCreate)
        {
            var entity = new Student
            {
                OwnerId   = _userId,
                FirstName = studentCreate.FirstName,
                LastName  = studentCreate.LastName,
                FullName  = $"{studentCreate.FirstName} {studentCreate.LastName}",
                Email     = studentCreate.Email,
                Grade     = studentCreate.Grade,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Students.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Example #14
0
        public ActionResult Create(StudentCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateStudentService();

            if (service.CreateStudent(model))
            {
                TempData["SaveResult"] = "The student was created";
                return(RedirectToAction("Index"));
            }
            ;
            {
                ModelState.AddModelError("", "Student could not be created.");
                return(View(model));
            }
        }
Example #15
0
        public IEnumerable <StudentCreate> GetStudentsInCourse(int courseID)
        {
            var listOfStudents = new List <StudentCreate>();

            using (var ctx = new ApplicationDbContext())
            {
                var oneCourse = ctx.Courses.Single(e => e.ClassID == courseID);
                foreach (var student in oneCourse.Students)
                {
                    var newStudent = new StudentCreate
                    {
                        StudentID = student.StudentID,
                        Name      = student.Name
                    };
                    listOfStudents.Add(newStudent);
                }
            }
            return(listOfStudents);
        }
Example #16
0
 public IActionResult CreateStudent(StudentCreate student)
 {
     if (ModelState.IsValid)
     {
         var newStudent = new Student
         {
             stuFirstName = student.stuFirstName,
             stuLastName  = student.stuLastName,
             stuBirthDate = student.stuBirthDate,
             stuGender    = student.stuGender
         };
         var newModel = _repository.Add(newStudent);
         return(RedirectToAction(nameof(Detail), new { id = newModel.stuId }));
     }
     else
     {
         return(View("Create"));
     }
 }
Example #17
0
        public bool CreateStudent(StudentCreate model)
        {
            var entity =
                new Student()
            {
                OwnerId   = _userId,
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Age       = model.Age,
                Height    = model.Height,
                Weight    = model.Weight,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Students.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Example #18
0
        public bool CreateStudent(StudentCreate model)
        {
            var entity =
                new Student()
            {
                StudentId     = _userId,
                FirstName     = model.FirstName,
                LastName      = model.LastName,
                CohortId      = model.CohortId,
                ResumeLink    = model.ResumeLink,
                LinkedInLink  = model.LinkedInLink,
                PortfolioLink = model.PortfolioLink,
                GitHub        = model.GitHub
            };

            using (var context = new ApplicationDbContext())
            {
                context.Student.Add(entity);
                return(context.SaveChanges() == 1);
            }
        }
Example #19
0
        public ActionResult CreateStudent(StudentCreate student)
        {
            var    sha1           = new SHA1CryptoServiceProvider();
            var    hash           = sha1.ComputeHash(Encoding.UTF8.GetBytes("p@55Student"));
            string hashedPassword = BitConverter.ToString(hash).Replace("-", string.Empty).ToLower();

            student.Password = hashedPassword;
            System.Diagnostics.Debug.WriteLine(ModelState.IsValid);
            ViewData["CourseSelect"]   = GetCourse();
            ViewData["LecturerSelect"] = GetLecturer();
            if (ModelState.IsValid)
            {
                ViewData["Message"] = "Student profile Created Successfully!";
                student.StudentID   = studentContext.Add(student);
                return(View());
            }
            else
            {
                return(View(student));
            }
        }
        public int Create(StudentCreate studentCreate)
        {
            int rowAffected = 0;

            using (IDbConnection con = new SqlConnection(strConnectionString))
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                    DynamicParameters parameters = new DynamicParameters();
                    parameters.Add("@Name", studentCreate.Name);
                    parameters.Add("@DOB", studentCreate.DOB);
                    parameters.Add("@Gender", studentCreate.Gender);
                    parameters.Add("@Email", studentCreate.Email);
                    parameters.Add("@LevelID", studentCreate.LevelID);
                    parameters.Add("@LanguageID", studentCreate.LanguageID);
                    rowAffected = con.Execute("Student_Create", parameters, commandType: CommandType.StoredProcedure);
                }
                return(rowAffected);
            }
        }
Example #21
0
 public Result Create(StudentCreate studentCreate)
 {
     repository.Insert(studentCreate.Adapt <StudentCreate, Student>());
     return(repository.Save());
 }