Exemplo n.º 1
0
        public override RequestModel <RequestDelegatePermissionsUserModel> GetRequestModelBy(Request request)
        {
            DateTime?completeDate = null;

            if (request.IdCurrentRequestStateType == 4)
            {
                completeDate = request.CurrentRequestStateDate;
            }
            return(new RequestModel <RequestDelegatePermissionsUserModel>
            {
                IdRequest = request.IdRequest,
                Description = request.Description,
                OwnerSnp = request.User.Snp,
                OwnerDepartment = request.User.Department.Name,
                RequestStateName = request.CurrentRequestStateType.Name,
                RequestDate = request.RequestStates.First(r => !r.Deleted).Date,
                CompleteDate = completeDate,
                IdRequestType = request.IdRequestType,
                Users = request.RequestUserAssoc.Where(ru => !ru.Deleted).Select(ru =>
                {
                    var delegationExtInfo =
                        RequestsRepository.GetDelegationRequestUserExtInfoBy(ru.IdRequestUserAssoc);
                    if (delegationExtInfo == null)
                    {
                        throw new ApplicationException("Отсутствует дополнительная информация о делегировании");
                    }
                    var userModel = FillRequestUserModel(ru);
                    userModel.DelegationRequestUsersExtInfoModel = new DelegationRequestUsersExtInfoModel
                    {
                        LoginDelegateTo = delegationExtInfo.DelegateToUser.Login,
                        PostDelegateTo = delegationExtInfo.DelegateToUser.Post,
                        SnpDelegateTo = delegationExtInfo.DelegateToUser.Snp,
                        PhoneDelegateTo = delegationExtInfo.DelegateToUser.Phone,
                        DepartmentDelegateTo = delegationExtInfo.DelegateToUser.Department,
                        UnitDelegateTo = delegationExtInfo.DelegateToUser.Unit,
                        OfficeDelegateTo = delegationExtInfo.DelegateToUser.Office,
                        DelegateFromDate = delegationExtInfo.DelegateFromDate,
                        DelegateToDate = delegationExtInfo.DelegateToDate
                    };
                    return userModel;
                }).ToList()
            });
        }