Example #1
0
        public async Task <int> Getresign([FromBody] FindworkRequest request)
        {
            //判断request里是否满足前置条件
            if (!ModelState.IsValid)
            {
                return(-1);
            }
            var user_id = Int32.Parse(User.Identity.Name);

            if (await UserAccessor.CheckRole(user_id) != Role.Student)
            {
                return(-2);
            }
            TakesEntity entity = new TakesEntity();

            entity.work_id    = request.work_id;
            entity.student_id = user_id;
            MessageEntity temp_entity = new MessageEntity();
            var           work_name   = await WorkAccessor.GetWorkName(request.work_id);

            var student_name = await UserAccessor.GetUserName(user_id);

            temp_entity.message_type = 0;
            temp_entity.content      = student_name + "同学辞去" + work_name + "工作。";
            temp_entity.sender_id    = user_id;
            temp_entity.receiver_id  = await WorkAccessor.GetTeacher(request.work_id);

            var num = await TakesAccessor.GetRegion(entity);

            await MessageAccessor.Create(temp_entity, 1);

            return(num);
        }
Example #2
0
        public async Task <ActionResult <int> > CreateApply(ApplyRequest request)
        {
            var stu_id = Int32.Parse(User.Identity.Name);

            if (await UserAccessor.CheckRole(stu_id) != Role.Student)
            {
                return(BadRequest(new { message = "CreateApply is for students." }));
            }
            int check_apply = await ApplyAccessor.CheckApply(stu_id, request.work_id);

            if (check_apply == 1)
            {
                // 已通过改工作的申请
                return(Ok(-21));
            }
            else if (check_apply == 2)
            {
                // 正在申请该工作
                return(Ok(-22));
            }
            var temp = _mapper.Map <ApplyEntity>(request);

            temp.student_id = stu_id;
            temp.teacher_id = await WorkAccessor.GetTeacher(temp.work_id);

            temp.resume_id = await ResumeAccessor.GetResume(temp.student_id);

            if (temp.resume_id == -1)
            {
                return(Ok(-10));
            }
            var ans = await ApplyAccessor.Create(temp);

            if (ans > 0)
            {
                return(Ok(ans));
            }
            return(Ok(-1));
        }