Exemple #1
0
        public async Task<ApiResult<GetComplaintTypeOutput>> Get([FromUri]string id, CancellationToken cancelToken)
        {
            if (Authorization == null)
            {
                return new ApiResult<GetComplaintTypeOutput>(APIResultCode.Unknown, new GetComplaintTypeOutput { }, APIResultMessage.TokenNull);
            }
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new NotImplementedException("楼宇Id信息为空!");
            }

            var user = _tokenRepository.GetUser(Authorization);
            if (user == null)
            {
                return new ApiResult<GetComplaintTypeOutput>(APIResultCode.Unknown, new GetComplaintTypeOutput { }, APIResultMessage.TokenError);
            }
            var data = await _complaintTypeRepository.GetAsync(id, cancelToken);

            return new ApiResult<GetComplaintTypeOutput>(APIResultCode.Success, new GetComplaintTypeOutput
            {
                Id = data.Id.ToString(),
                ComplaintPeriod = data.ComplaintPeriod,
                Description = data.Description,
                InitiatingDepartmentName = data.InitiatingDepartmentName,
                InitiatingDepartmentValue = data.InitiatingDepartmentValue,
                Level = data.Level,
                Name = data.Name,
                ProcessingPeriod = data.ProcessingPeriod
            });

        }
Exemple #2
0
        public async Task <ApiResult <GetComplaintFollowUpOutput> > Get([FromUri] GetComplaintFollowUpInput input, CancellationToken cancelToken)
        {
            if (string.IsNullOrWhiteSpace(input.Id))
            {
                throw new NotImplementedException("投诉ID为空!");
            }
            if (Authorization == null)
            {
                return(new ApiResult <GetComplaintFollowUpOutput>(APIResultCode.Unknown, new GetComplaintFollowUpOutput {
                }, APIResultMessage.TokenNull));
            }

            var user = _tokenRepository.GetUser(Authorization);

            if (user == null)
            {
                return(new ApiResult <GetComplaintFollowUpOutput>(APIResultCode.Unknown, new GetComplaintFollowUpOutput {
                }, APIResultMessage.TokenError));
            }

            var data = await _complaintFollowUpRepository.GetListForComplaintIdAsync(input.Id, cancelToken);

            var complaintAnnexList = await _complaintAnnexRepository.GetByFollowUpIdsAsync(data.Select(x => x.Id.ToString()).ToList());

            List <GetComplaintFollowUpListOutput> list = new List <GetComplaintFollowUpListOutput>();

            foreach (var item in data)
            {
                string OperationName = "";
                bool   IsCreateUser  = false;
                if (item.OperationDepartmentValue == Department.YeZhu.Value)
                {
                    OperationName = (await _ownerCertificationRecordRepository.GetIncludeAsync(item.OwnerCertificationRecordId.ToString(), cancelToken))?.Owner.Name;
                    IsCreateUser  = item.OwnerCertificationRecordId.ToString() == input.OwnerCertificationId ? true : false;
                }
                else if (item.OperationDepartmentValue == Department.YeZhuWeiYuanHui.Value)
                {
                    OperationName = (await _ownerCertificationRecordRepository.GetIncludeAsync(item.OwnerCertificationRecordId.ToString(), cancelToken))?.Owner.Name;
                    IsCreateUser  = item.OwnerCertificationRecordId.ToString() == input.OwnerCertificationId ? true : false;
                }
                else
                {
                    OperationName = (await _userRepository.GetForIdAsync(item.CreateOperationUserId, cancelToken)).Name;
                    IsCreateUser  = user.Name == OperationName ? true : false;
                }
                var entity = new GetComplaintFollowUpListOutput
                {
                    Aappeal                 = string.IsNullOrWhiteSpace(item.Aappeal) ? "" : item.Aappeal,
                    IsCreateUser            = IsCreateUser,
                    Description             = item.Description,
                    OperationDepartmentName = item.OperationDepartmentName,
                    OperationName           = OperationName,
                    Url        = (complaintAnnexList?.Where(x => x.ComplaintFollowUpId == item.Id)).FirstOrDefault()?.AnnexContent,
                    CreateTime = item.CreateOperationTime.Value
                };
                list.Add(entity);
            }

            var complaintEntity = await _complaintRepository.GetIncludeAsync(input.Id, cancelToken);

            var complaintTypeEntyity = await _complaintTypeRepository.GetAsync(complaintEntity.ComplaintTypeId.ToString(), cancelToken);

            var remainingPeriod = (complaintEntity.ExpiredTime - DateTimeOffset.Now).Value.Days + 1;

            return(new ApiResult <GetComplaintFollowUpOutput>(APIResultCode.Success, new GetComplaintFollowUpOutput
            {
                ExpiredTime = complaintEntity.ExpiredTime.Value,
                ProcessUpTime = complaintEntity.ProcessUpTime.Value,
                ComplaintPeriod = complaintTypeEntyity.ComplaintPeriod,
                ProcessingPeriod = complaintTypeEntyity.ProcessingPeriod,
                StatusName = complaintEntity.StatusName,
                StatusValue = complaintEntity.StatusValue,
                DepartmentName = complaintEntity.DepartmentName,
                DepartmentValue = complaintEntity.DepartmentValue,
                Description = complaintEntity.Description,
                ComplaintTypeName = complaintEntity.ComplaintType.Name,
                List = list,
                RemainingPeriod = remainingPeriod > 0 ? remainingPeriod : 0
            }));
        }