コード例 #1
0
ファイル: WorkController.cs プロジェクト: chuckleLZY/FeedPet
        public async Task <int> DeleteWork([FromBody] FindworkRequest request)
        {
            //取得存在cookie的当前账户id
            var pro_id = Int32.Parse(User.Identity.Name);
            var temp   = await WorkAccessor.FindWorkInfo(request.work_id);

            if (temp != null)
            {
                var num = await WorkAccessor.DeleteWork(request.work_id);

                return(num);
            }
            return(-1);
        }
コード例 #2
0
ファイル: WorkController.cs プロジェクト: chuckleLZY/FeedPet
        public async Task <ActionResult <WorkResponse> > ViewWorkInfo([FromBody] FindworkRequest temp)
        {
            //判断request里是否满足前置条件
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var work_info = await WorkAccessor.FindWorkInfo(temp.work_id);

            if (work_info != null)
            {
                return(Ok(_mapper.Map <WorkResponse>(work_info)));
            }
            return(Ok(-1));
        }
コード例 #3
0
ファイル: WorkController.cs プロジェクト: chuckleLZY/FeedPet
        public async Task <ActionResult <WorkItemResponse> > ViewOwnWork([FromBody] ViewWorkRequest request)
        {
            WorkItemResponse workItem = new WorkItemResponse();

            workItem.totalpage = 0;
            workItem.pagenum   = request.pagenum;
            workItem.worklist  = new List <WorkResponse>();

            var start = (request.pagenum - 1) * request.pagesize;
            var end   = request.pagenum * request.pagesize - 1;

            //取得存在cookie的当前账户id
            var stu_id = Int32.Parse(User.Identity.Name);

            var temp = await WorkAccessor.FindOwnWork(stu_id);

            if (temp != null)
            {
                for (int i = 0; i < temp.total; i++)
                {
                    var work_info = await WorkAccessor.FindWorkInfo(temp.TakesItem[i].work_id);

                    var status = await TakesAccessor.FindInfo(stu_id, temp.TakesItem[i].work_id);

                    workItem.totalpage++;
                    if (i >= start && i <= end && work_info != null)
                    {
                        WorkResponse a = _mapper.Map <WorkResponse>(work_info);
                        a.status = status.status;
                        workItem.worklist.Add(a);
                    }
                }

                return(Ok(workItem));
            }
            return(Ok(-1));
        }