Ejemplo n.º 1
0
 public dtoAgencyPermission(Int32 loaderType, dtoAgency agency, Int32 userCount)
 {
     Edit   = (agency.Deleted == BaseStatusDeleted.None && (loaderType == (int)UserTypeStandard.SysAdmin || loaderType == (int)UserTypeStandard.Administrator || loaderType == (int)UserTypeStandard.Administrative));
     Info   = (loaderType == (int)UserTypeStandard.SysAdmin || loaderType == (int)UserTypeStandard.Administrator || loaderType == (int)UserTypeStandard.Administrative);
     Delete = (!agency.IsDefault && !agency.IsEmpty) && (loaderType == (int)UserTypeStandard.SysAdmin || loaderType == (int)UserTypeStandard.Administrator || loaderType == (int)UserTypeStandard.Administrative);
     if (Delete)
     {
         //if (usedBy > 0 && deleted != BaseStatusDeleted.None) {
         if (userCount > 0)
         {
             VirtualUndelete = (agency.Deleted != BaseStatusDeleted.None);
             Delete          = false;
         }
         else if (userCount == 0)
         {
             if (agency.Deleted == BaseStatusDeleted.None)
             {
                 VirtualDelete = true;
                 Delete        = false;
             }
             else
             {
                 VirtualUndelete = true;
             }
         }
     }
 }
Ejemplo n.º 2
0
        public void InitView()
        {
            long idAgency = View.PreloadedIdAgency;

            if (UserContext.isAnonymous)
            {
                View.NoPermission();
            }
            else
            {
                ModuleProfileManagement module = ModuleProfileManagement.CreatePortalmodule(UserContext.UserTypeID);
                if (module.DeleteProfile || module.Administration)
                {
                    if (Service.ExistAgency(idAgency))
                    {
                        View.IdAgency = idAgency;
                        dtoAgency agency = Service.GetDtoAgency(idAgency);
                        View.DisplayAgencyInfo(agency);
                        View.AllowDelete = (agency.EmployeeNumber == 0);
                    }
                    else
                    {
                        View.DisplayAgencyUnknown();
                    }
                }
                else
                {
                    View.NoPermission();
                }
            }
        }
Ejemplo n.º 3
0
 public void InitView(long idAgency)
 {
     if (UserContext.isAnonymous)
     {
         View.DisplaySessionTimeout();
     }
     else
     {
         dtoAgency agency = Service.GetDtoAgency(idAgency);
         if (agency == null)
         {
             View.DisplayAgencyUnknown();
         }
         else
         {
             ModuleProfileManagement module = ModuleProfileManagement.CreatePortalmodule(UserContext.UserTypeID);
             if (module.ViewProfileDetails || module.Administration)
             {
                 View.LoadAgencyInfo(agency);
             }
             else
             {
                 View.DisplayNoPermission();
             }
         }
     }
 }
Ejemplo n.º 4
0
        public Boolean ValidateInput(dtoAgency agency)
        {
            List <AgencyError> errors = Service.VerifyExistingAgency(agency);

            if (errors.Count > 0)
            {
                View.LoadErrors(errors);
            }
            return(errors.Count == 0);
        }
Ejemplo n.º 5
0
 public void Save(dtoAgency agency)
 {
     agency.Id = View.IdAgency;
     if (ValidateInput(agency))
     {
         Agency saved = Service.SaveAgency(agency);
         if (saved != null)
         {
             View.GotoManagement();
         }
         else
         {
             View.DisplayErrorSaving();
         }
     }
 }
Ejemplo n.º 6
0
        private Dictionary <long, String> CreateAgencies(Boolean assignToAll, Dictionary <Int32, String> organizations, ExternalResource selectedItems, List <String> notAddedItems)
        {
            Dictionary <long, String> agencies = new Dictionary <long, String>();

            if (assignToAll == true || organizations.Count > 1)
            {
                long  idAgency = 0;
                Int32 index    = 1;
                List <ExternalColumnComparer <String, Int32> > columns = View.Fields;
                foreach (ExternalRow row in selectedItems.Rows)
                {
                    dtoAgency dto = new  dtoAgency();
                    dto.AlwaysAvailable = assignToAll;
                    dto.Name            = row.GetCellValue(columns.Where(c => c.DestinationColumn.Id == (int)ImportedAgencyColumn.name).Select(c => c.Number).FirstOrDefault());
                    dto.NationalCode    = row.GetCellValue(columns.Where(c => c.DestinationColumn.Id == (int)ImportedAgencyColumn.nationalCode).Select(c => c.Number).FirstOrDefault());
                    dto.TaxCode         = row.GetCellValue(columns.Where(c => c.DestinationColumn.Id == (int)ImportedAgencyColumn.taxCode).Select(c => c.Number).FirstOrDefault());
                    dto.ExternalCode    = row.GetCellValue(columns.Where(c => c.DestinationColumn.Id == (int)ImportedAgencyColumn.externalCode).Select(c => c.Number).FirstOrDefault());
                    dto.IsDefault       = false;
                    dto.IsEditable      = true;
                    if (!assignToAll)
                    {
                        dto.Organizations = (from o in organizations select new dtoOrganizationAffiliation()
                        {
                            Id = o.Key
                        }).ToList();
                    }
                    Agency agency = Service.SaveAgency(dto);

                    if (agency == null)
                    {
                        notAddedItems.Add(dto.Name);
                    }
                    else
                    {
                        agencies.Add(agency.Id, agency.Name);
                    }
                    View.UpdateAgencyCreation(selectedItems.Rows.Count, index, (agency != null), " // ");
                    index++;
                }
            }
            return(agencies);
        }
Ejemplo n.º 7
0
 public void InitView(long idAgency)
 {
     if (UserContext.isAnonymous)
     {
         View.DisplaySessionTimeout();
     }
     else
     {
         ModuleProfileManagement module = ModuleProfileManagement.CreatePortalmodule(UserContext.UserTypeID);
         View.AllowManagement = module.Administration;
         if (module.Administration)
         {
             dtoAgency agency = Service.GetDtoAgency(idAgency);
             if (agency == null && idAgency > 0)
             {
                 View.DisplayAgencyUnknown();
             }
             else
             {
                 View.IdAgency  = idAgency;
                 View.AllowEdit = true;
                 if (idAgency > 0)
                 {
                     View.LoadAgencyName(agency.Name);
                     View.LoadAgency(agency, Service.GetAgencyAvailableOrganizations(idAgency));
                 }
                 else
                 {
                     View.InitializeForAdd(Service.GetAgencyAvailableOrganizations(idAgency));
                 }
             }
         }
         else
         {
             View.DisplayNoPermission();
         }
     }
 }