Ejemplo n.º 1
0
        protected Request ConvertToRequest(RequestModel <TUserModel> requestModel, Action <RequestUserAssoc, TUserModel> requestUserAssocAddedCallback = null)
        {
            requestModel.Users.ForEach(r => r.Snp = r.Snp.Trim());
            requestModel.Users = ClearUsersDuplicates(requestModel.Users);

            var request = new Request
            {
                IdRequest        = requestModel.IdRequest,
                IdRequestType    = requestModel.IdRequestType,
                Description      = requestModel.Description,
                RequestUserAssoc = new List <RequestUserAssoc>()
            };

            foreach (var user in requestModel.Users)
            {
                var requestUser = new RequestUser
                {
                    Snp        = user.Snp,
                    Login      = user.Login,
                    Post       = user.Post,
                    Department = user.Department,
                    Unit       = user.Unit,
                    Office     = user.Office,
                    Phone      = user.Phone
                };
                var requestUserAssoc = new RequestUserAssoc
                {
                    RequestUser = requestUser,
                    Request     = request,
                    Description = user.Description
                };
                request.RequestUserAssoc.Add(requestUserAssoc);
                if (requestUserAssocAddedCallback != null)
                {
                    requestUserAssocAddedCallback(requestUserAssoc, user);
                }
                if (user.Rights != null)
                {
                    requestUserAssoc.RequestUserRightAssocs = new List <RequestUserRightAssoc>();
                    foreach (var right in user.Rights)
                    {
                        var requestUserRightAssoc = new RequestUserRightAssoc
                        {
                            RequestUserAssoc        = requestUserAssoc,
                            Descirption             = right.Description,
                            IdRequestRightGrantType = right.IdRequestRightGrantType,
                            IdResourceRight         = right.IdResourceRight
                        };
                        requestUserAssoc.RequestUserRightAssocs.Add(requestUserRightAssoc);
                    }
                }
            }
            return(request);
        }
Ejemplo n.º 2
0
 protected TUserModel FillRequestUserModel(RequestUserAssoc userAssoc)
 {
     return(new TUserModel
     {
         Description = userAssoc.Description,
         Login = userAssoc.RequestUser.Login,
         Post = userAssoc.RequestUser.Post,
         Snp = userAssoc.RequestUser.Snp,
         Phone = userAssoc.RequestUser.Phone,
         Department = userAssoc.RequestUser.Department,
         Unit = userAssoc.RequestUser.Unit,
         Office = userAssoc.RequestUser.Office,
         Rights = userAssoc.RequestUserRightAssocs.Where(rur => !rur.Deleted).
                  Select(RequestUserRightModelBy).ToList()
     });
 }
Ejemplo n.º 3
0
        private DelegationRequestUsersExtInfo GetDelegationRequestUsersExtInfo(RequestUserAssoc requestUserAssoc,
                                                                               RequestDelegatePermissionsUserModel user)
        {
            var delegationToUser = new RequestUser
            {
                Snp        = user.DelegationRequestUsersExtInfoModel.SnpDelegateTo,
                Login      = user.DelegationRequestUsersExtInfoModel.LoginDelegateTo,
                Post       = user.DelegationRequestUsersExtInfoModel.PostDelegateTo,
                Department = user.DelegationRequestUsersExtInfoModel.DepartmentDelegateTo,
                Unit       = user.DelegationRequestUsersExtInfoModel.UnitDelegateTo,
                Office     = user.DelegationRequestUsersExtInfoModel.OfficeDelegateTo,
                Phone      = user.DelegationRequestUsersExtInfoModel.PhoneDelegateTo
            };

            return(new DelegationRequestUsersExtInfo
            {
                RequestUserAssoc = requestUserAssoc,
                DelegateFromDate = user.DelegationRequestUsersExtInfoModel.DelegateFromDate.Date,
                DelegateToDate = user.DelegationRequestUsersExtInfoModel.DelegateToDate.Date.AddDays(1).AddSeconds(-1),
                DelegateToUser = delegationToUser
            });
        }