Exemple #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;
        }
        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());
        }
Exemple #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)
            });
        }
Exemple #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);
        }
        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());
            }
        }