예제 #1
0
        //This goes in Initialization/constructor
        void Add()
        {
            var addedStudent = studentsRepository.AddStudentAsync(SelectedPerson).Result;

            studentList.Add(addedStudent);
            SelectedPerson      = addedStudent;
            RecordCount         = studentList.Count;
            StudentListEditMode = EditMode.Update;
        }
예제 #2
0
        public async Task <ActionResult> Post([FromBody] Student student)
        {
            var newStudent = await _repository.AddStudentAsync(UserId, student);

            if (newStudent == null)
            {
                return(BadRequest(new { message = $"Студент с идентификатором {student.StudentID} уже существует" }));
            }
            return(Ok());
        }
예제 #3
0
        // POST: api/Student
        public async Task <HttpResponseMessage> PostAsync([FromBody] Student.Data.Models.Student newStudent)
        {
            var data = await studentsRepo.AddStudentAsync(newStudent);

            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ObjectContent <object>(new
                {
                    Message = "new student created"
                }, Configuration.Formatters.JsonFormatter)
            });
        }
예제 #4
0
        /// <summary>
        /// Добавить студента.
        /// </summary>
        /// <param name="student">Студент.</param>
        /// <returns></returns>
        public async Task <ISTrainingPartResponse <bool> > AddStudentAsync(Student student)
        {
            Logger.Log.Info($"Add student: {student.FullName}");

            var res = await repository.AddStudentAsync(student);

            if (res)
            {
                Clients.Group(Consts.AuthorizedGroup).OnChanged(DbChangeStatus.Add, student);
            }

            return(res);
        }
예제 #5
0
        public async Task <IActionResult> AddStudentAsync(Student student)
        {
            try
            {
                var studentList = await _studentsRepository.AddStudentAsync(student);

                if (student != null)
                {
                    return(new OkObjectResult(new StudentViewModel
                    {
                        // Id = studentList.StudentId,
                        Gender = studentList.Gender.Trim(),
                        Name = studentList.Name.Trim(),
                        SchoolId = studentList.School
                    }));
                }
                return(new NotFoundResult());
            }
            catch
            {
                return(new ConflictResult());
            }
        }