Пример #1
0
 protected IList<DocumentDto> GetDocumentsListForManager(EmployeeDocumentListModel model)
 {
     int managerId = AuthenticationService.CurrentUser.Id;
     UserRole managerRole = AuthenticationService.CurrentUser.UserRole;
     bool showNew = model.ShowNew;
     return DocumentDao.GetDocumentsListForManager(managerId, managerRole, showNew, model.UserId, model.DocumentSubTypeId);
 }
Пример #2
0
 protected void SetModel(EmployeeDocumentListModel model)
 {
     if ((AuthenticationService.CurrentUser.UserRole & UserRole.Employee) == UserRole.Employee)
     {
         if (!model.UserId.HasValue)
             model.UserId = AuthenticationService.CurrentUser.Id;
         model.ViewHeader = true;
         model.AddVisible = true;
         model.DocumentTypesAndSubtypes = new List<IdNameDto>();
         model.DocumentSubTypeId = 0;
         //model.DocumentSubTypes = new List<IdNameDto>();
         SetUserModel(model, model.UserId.Value);
         model.Documents = GetDocumentsListForOwner(model.UserId.Value).ToList().
             ConvertAll(x => new DocumentDtoModel
                                 {
                                     Date = x.Date.ToShortDateString(),
                                     Id = x.Id,
                                     IsApproved = x.IsApproved,
                                     Type = x.Type + (x.SubType == null
                                                          ? string.Empty
                                                          : " " + x.SubType),
                                     OwnerId = x.OwnerId,
                                 });
     }
     else
     {
         if (model.UserId.HasValue)
             SetUserModel(model, model.UserId.Value);
         model.TypeFilterVisible = true;
         SetDocumentTypesAndSubtypesToModel(model);
         model.Documents = GetDocumentsListForManager(model).ToList().
             ConvertAll(x => new DocumentDtoModel
             {
                 Date = x.Date.ToShortDateString(),
                 Id = x.Id,
                 IsApproved = x.IsApproved,
                 Type = x.Type + (x.SubType == null
                                      ? string.Empty
                                      : " " + x.SubType),
                 OwnerId = x.OwnerId,
             });
     }
 }
Пример #3
0
 public EmployeeDocumentListModel GetModel(int? ownerId, bool? viewHeader,
     bool? showNew, int? subtypeId)
 {
     //if(!userId.HasValue)
     //    userId = AuthenticationService.CurrentUser.Id;
     EmployeeDocumentListModel model = new EmployeeDocumentListModel
                                           {
                                               UserId = ownerId,
                                               ViewHeader = viewHeader.HasValue && viewHeader.Value,
                                               ShowNew = showNew.HasValue && showNew.Value,
                                               DocumentSubTypeId = subtypeId.HasValue ? subtypeId.Value : 0,
                                           };
     SetModel(model);
     return model;
 }
Пример #4
0
        protected void SetDocumentTypesAndSubtypesToModel(EmployeeDocumentListModel model)
        {
            List<IdNameDto> modelList = new List<IdNameDto>();
            List<EmployeeDocumentType> types = GetEmployeeDocumentTypes();
            IList<EmployeeDocumentSubType> subtypes = EmployeeDocumentTypeDao.LoadAllSubtype();
            foreach (var documentType in types)
            {
                IOrderedEnumerable<EmployeeDocumentSubType> typeSubtypes = subtypes.
                    Where(x => x.Type.Id == documentType.Id).
                    OrderBy(x => x.Name);
                modelList.AddRange(typeSubtypes.
                    Select(subtype =>
                        new IdNameDto(subtype.Id, documentType.Name + " " + subtype.Name)));
            }
            modelList.Insert(0,new IdNameDto(0,"Все"));
            model.DocumentTypesAndSubtypes = modelList;
            //if (model.DocumentSubTypeId == 0)
            //    model.DocumentSubTypeId = modelList[0].Id;

            //List<EmployeeDocumentType> types = GetEmployeeDocumentTypes();
            //model.DocumentTypes = types.ConvertAll(x => new IdNameDto(x.Id, x.Name));
            //model.DocumentTypes.Add(new IdNameDto(0, "Все"));
            //model.DocumentTypeId = model.DocumentTypeId;
            //if (model.DocumentTypeId == 0)
            //{
            //    model.DocumentSubTypes = new List<IdNameDto> { new IdNameDto(0, "Все") };
            //    model.DocumentSubTypeId = 0;
            //}
            //else
            //{
            //    model.DocumentSubTypes = GetDocumentSubTypes(types, model.DocumentTypeId);
            //    model.DocumentSubTypeId = model.DocumentTypeId;
            //}
        }