Exemple #1
0
        public static StudentModel SerilizeStudentModel(Student student)
        {
            StudentModel studentModel = new StudentModel();
            studentModel.FirstName = student.FirstName;
            studentModel.LastName = student.LastName;
            studentModel.Age = student.Age;
            studentModel.Grade = student.Grade;

            return studentModel;
        }
Exemple #2
0
        public static Student SerilizeStudent(StudentModel model)
        {
            Student student = new Student();
            student.FirstName = model.FirstName;
            student.LastName = model.LastName;
            student.Age = model.Age;
            student.Grade = model.Grade;

            return student;
        }
        public HttpResponseMessage Post(StudentModel studentModel)
        {
            Student student = ModelsBridge.SerilizeStudent(studentModel);
            using (this.unitOfWork = new UnitOfWorkScope(true))
            {

                UnitOfWorkScope.StudentRepository.Add(student);
            }

            return this.Request.CreateResponse(HttpStatusCode.OK, student);
        }
        public StudentModel GetStudetById(int studentId)
        {
            var student = this.studentRepository.Get(studentId);

            var model = new StudentModel
            {
                Id = student.Id,
                FirstName = student.FirstName,
                LastName = student.LastName,
                StudentNumber = student.StudentNumber
            };

            return model;
        }
        public static StudentModel Convert(Student student)
        {
            StudentModel model = new StudentModel
            {
                StudentId = student.StudentId,
                FirstName = student.FirstName,
                LastName = student.LastName,
                Age = student.Age,
                Grade = student.Grade,
                MarksCount = student.Marks.Count,
                TownSchoolId = student.TownSchoolId
            };

            return model;
        }
        public HttpResponseMessage AddNewStudent(Student model)
        {
            var result = this.studentRepository.Add(model);

            var newStudent = new StudentModel
            {
                Id = result.Id,
                FirstName = result.FirstName,
                LastName = result.LastName,
                StudentNumber = result.StudentNumber
            };

            var response = this.Request.CreateResponse(HttpStatusCode.Created, newStudent);
            response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = newStudent.Id }));

            return response;
        }