Exemple #1
0
        public async Task <ResponseMessage <bool> > UpdateWaitHandle(long repairId)
        {
            ReportForRepair repair = await _reportForRepairService.QueryById(repairId);

            if (repair != null && repair.WaitHandle == 1)
            {
                repair.WaitHandle = 0;
                repair.RoleId     = 0;
                repair.WorkerId   = 0;
                var update = await _reportForRepairService.Update(repair);

                return(new ResponseMessage <bool>()
                {
                    Status = 200,
                    Msg = "弃单成功",
                    Success = true,
                    ResponseInfo = update
                });
            }
            else
            {
                return(new ResponseMessage <bool>()
                {
                    Msg = "弃单失败,没有该单或者没有接此单",
                    Success = false,
                });
            }
        }
Exemple #2
0
        [Authorize(Policy = "ElectricianAndCarpentry")]//Carpentry Electrician
        public async Task <ResponseMessage <RoleReportForRepairViewModel> > UpdateRoleReportForRepair(long roleReportForRepairId)
        {
            ClaimsPrincipal principal = HttpContext.User;
            string          roleName  = principal.FindFirst(x => x.Type == ClaimTypes.Role).Value;
            string          name      = principal.FindFirst(x => x.Type == ClaimTypes.Name).Value;
            string          jti       = principal.FindFirst(x => x.Type == JwtRegisteredClaimNames.Jti).Value;
            Roles           roles     = await _rolesService.Query(x => x.RoleName.Equals(roleName));

            ReportForRepair reportForRepair = await _reportForRepairService.QueryById(roleReportForRepairId);

            if (reportForRepair.WaitHandle == 0)
            {
                reportForRepair.WorkerId   = Convert.ToInt64(jti);
                reportForRepair.RoleId     = roles.Id;
                reportForRepair.WaitHandle = 1;//1标志表示接受处理
                bool update = await _reportForRepairService.Update(reportForRepair);

                return(update
                    ? new ResponseMessage <RoleReportForRepairViewModel>()
                {
                    Msg = "接单成功",
                    Success = true,
                    Status = 200,
                    ResponseInfo = new RoleReportForRepairViewModel()
                    {
                        UserName = name,
                        Dorm = reportForRepair.Dorm,
                        Tung = reportForRepair.Tung,
                        Desc = reportForRepair.Desc,
                        Layer = reportForRepair.Layer
                    }
                }
                    : new ResponseMessage <RoleReportForRepairViewModel>()
                {
                    Msg = "接单失败",
                    Success = false
                });
            }
            else
            {
                return(new ResponseMessage <RoleReportForRepairViewModel>()
                {
                    Msg = "接单失败,该报修已被接受或已完成维修",
                });
            }
        }
Exemple #3
0
        public async Task <ResponseMessage <string> > GetCompletionTask(long repairId)
        {
            ReportForRepair reportForRepair = await _reportForRepairService.QueryById(repairId);

            if (reportForRepair != null)
            {
                if (reportForRepair.WaitHandle == 0)
                {
                    return(new ResponseMessage <string>()
                    {
                        Msg = "该任务还未被人接受处理",
                        Success = false
                    });
                }

                if (reportForRepair.WaitHandle == 2)
                {
                    return(new ResponseMessage <string>()
                    {
                        Msg = "该任务已被完成",
                        Success = false
                    });
                }

                reportForRepair.WaitHandle = 2;
                bool update = await _reportForRepairService.Update(reportForRepair);

                return(update
                    ? new ResponseMessage <string>()
                {
                    Msg = "成功提交,已完成",
                    Success = true,
                    Status = 200
                }
                    : new ResponseMessage <string>()
                {
                    Msg = "提交失败",
                    Success = false
                });
            }
            return(new ResponseMessage <string>()
            {
                Msg = "没有该任务",
                Success = false
            });
        }
        //[Authorize(Policy = "Admin")]
        public async Task <ResponseMessage <bool> > PostComment([FromBody] CommentViewModel model)
        {
            //string jti = HttpContext.User.FindFirst(x => x.Type == JwtRegisteredClaimNames.Jti).Value;
            //long id = Convert.ToInt64(jti);
            ReportForRepair reportForRepair = await _reportForRepairService.QueryById(model.ReportForRepairId);

            if (reportForRepair != null)
            {
                if (reportForRepair.WaitHandle == 2 && reportForRepair.Evaluate == 0)
                {
                    reportForRepair.Evaluate = model.Evaluate;
                    bool update = await _reportForRepairService.Update(reportForRepair);

                    if (update)
                    {
                        return(new ResponseMessage <bool>()
                        {
                            Msg = "提交评论成功",
                            Status = 200,
                            Success = true,
                            ResponseInfo = update
                        });
                    }
                }
                return(new ResponseMessage <bool>()
                {
                    Msg = "提交评论失败。可能的原因:维修未完成、已提交过评论",
                    Success = false
                });
            }
            return(new ResponseMessage <bool>()
            {
                Msg = "没有该任务",
                Success = false
            });
        }