public async Task <int> CreateAnnounce([FromBody] AnnounceRequest request)
        {
            //判断request里是否满足前置条件
            if (!ModelState.IsValid)
            {
                return(-5);
            }
            //取得存在cookie的当前账户id
            var user_id = Int32.Parse(User.Identity.Name);
            var role    = await UserAccessor.CheckRole(user_id);

            if (role == Role.Student || role == Role.Provider)
            {
                return(-10);
            }
            //生成annouce实例
            var announcement = _mapper.Map <AnnounceEntity>(request);

            announcement.user_id = user_id;
            //新建annouce
            var num = await AnnounceAccessor.Create(announcement);

            var s = await AnnounceAccessor.Createsend(num);

            return(num);
        }
Beispiel #2
0
        public async Task <int> CreateAnnounce([FromBody] AnnounceRequest request)
        {
            //判断request里是否满足前置条件
            if (!ModelState.IsValid)
            {
                return(-5);
            }
            //取得存在cookie的当前账户id
            var user_id = 6;//Int32.Parse(User.Identity.Name);
            //生成annouce实例
            var announcement = _mapper.Map <AnnounceEntity>(request);

            announcement.user_id = user_id;
            //新建annouce
            var num = await AnnounceAccessor.Create(announcement);

            return(user_id);
        }