示例#1
0
        public async Task <object> AddStudent([FromBody] StudentClassViewModel model)
        {
            StudentClass item = new SimpleAutoMapper <StudentClass>().Map(model);

            try
            {
                if (await this.CheckPermissionToAddStudent(item))
                {
                    Response response = await _classService.AddStudent(new Class()
                    {
                        ID = item.ClassID
                    }, new Student()
                    {
                        ID = item.StudentID
                    });

                    return(new
                    {
                        success = response.Success
                    });
                }

                return(Forbid());
            }
            catch (Exception e)
            {
                Response.StatusCode = StatusCode(500).StatusCode;
                return(null);
            }
        }