Exemplo n.º 1
0
        public static FirmListViewModel Create(IRepository <Firm> firmRepository, IFirmService firmService)
        {
            Check.Require(firmRepository != null, "Repository is required.");

            var viewModel = new FirmListViewModel()
            {
                Firms        = firmService.GetAllFirms(),
                PendingFirms = firmRepository.Queryable.Where(a => a.Review).OrderBy(a => a.Id).ToList()
            };

            return(viewModel);
        }
Exemplo n.º 2
0
        public static AddConfirmViewModel Create(IRepository repository, IFirmService firmService, Seminar seminar, Person person, SeminarPerson seminarPerson, Firm firm = null)
        {
            Check.Require(repository != null, "Repository is required.");

            var viewModel = new AddConfirmViewModel()
            {
                //Firms = firmService.GetAllFirms(),
                Seminar       = seminar, Person = person,
                SeminarPerson = seminarPerson ?? new SeminarPerson(),
                Firm          = firm
            };

            var firms = new List <Firm>(firmService.GetAllFirms());

            firms.Add(new Firm("Other", null, null));

            viewModel.Firms = firms;

            return(viewModel);
        }
Exemplo n.º 3
0
        public IActionResult GetAllFirms()
        {
            Guid transactionID            = Guid.NewGuid();
            FinancingPMSLogger logMessage = new FinancingPMSLogger("GetAllFirms execution started", transactionID.ToString());

            _logger.LogInformation(message: logMessage.ToString());
            List <Firm> firmsList = new List <Firm>();

            try
            {
                firmsList = _firmService.GetAllFirms(transactionID.ToString());
                if (firmsList.Count == 0)
                {
                    return(StatusCode(204));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
            logMessage.message = "GetAllFirms execution ended";
            _logger.LogInformation(message: logMessage.ToString());
            return(Ok(firmsList));
        }
Exemplo n.º 4
0
        public static PersonViewModel Create(IRepository repository, IFirmService firmService, string site, Seminar seminar = null, Person person = null, string email = null, Firm firm = null)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new PersonViewModel()
            {
                Person = person ?? new Person(),
                Addresses = repository.OfType<AddressType>().Queryable.Select(a => new Address() { AddressType = a}).ToList(),
                Contacts = repository.OfType<ContactType>().Queryable.Select( a => new Contact(){ContactType = a}).ToList(),
                Countries = repository.OfType<Country>().GetAll(),
                CommunicationOptions = repository.OfType<CommunicationOption>().GetAll(),
                SeminarPerson = person != null ? person.GetLatestRegistration(site) : null,
                Email = email,
                Seminar = seminar,
                Commodities = repository.OfType<Commodity>().Queryable.Where(a=>a.IsActive).ToList(),
                Firm = firm ?? new Firm()
            };

            if (firm == null && viewModel.SeminarPerson != null)
            {
                viewModel.Firm = viewModel.SeminarPerson.Firm;
            }

            // find any addresses and replace them into the list
            if (person != null)
            {
                foreach(var a in person.Addresses)
                {
                    var addr = viewModel.Addresses.Where(b => b.AddressType == a.AddressType).FirstOrDefault();

                    if (addr != null) viewModel.Addresses.Remove(addr);

                    viewModel.Addresses.Add(a);
                }

                foreach (var a in person.Contacts)
                {
                    var ct = viewModel.Contacts.Where(b => b.ContactType == a.ContactType).FirstOrDefault();

                    if (ct != null) viewModel.Contacts.Remove(ct);

                    viewModel.Contacts.Add(a);
                }
            }

            // reorder so always in the same order
            viewModel.Addresses = viewModel.Addresses.OrderBy(a => a.AddressType.Id).ToList();
            viewModel.Contacts = viewModel.Contacts.OrderBy(a => a.ContactType.Id).ToList();

            // get the firms and add the "Other" option
            var firms = new List<Firm>(firmService.GetAllFirms());
            firms.Add(new Firm() { Name = "Other (Not Listed)" });

            viewModel.Firms = firms;
            if (viewModel.Person.User != null) viewModel.UserName = viewModel.Person.User.UserName;

            return viewModel;
        }
Exemplo n.º 5
0
        public static ApplicationViewModel Create(IRepository repository, IFirmService firmService, string userId, string siteId, Application application = null, bool seminarTerms = false)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new ApplicationViewModel
            {
                Application = application ?? new Application(),
                // always get the latest
                Seminar = SiteService.GetLatestSeminar(siteId),
                //Commodities = repository.OfType<Commodity>().Queryable.Where(a=>a.IsActive).OrderBy(a=>a.Name).ToList(),
                Countries            = repository.OfType <Country>().GetAll(),
                CommunicationOptions = repository.OfType <CommunicationOption>().GetAll(),
                SeminarTerms         = seminarTerms
            };

            // load commodities
            var commodities = repository.OfType <Commodity>().Queryable.Where(a => a.IsActive).OrderBy(a => a.Name).ToList();

            viewModel.Commodities = commodities;

            // load the firm types
            var firmTypes = repository.OfType <FirmType>().Queryable.Where(a => a.IsActive).OrderBy(a => a.Name).ToList();

            viewModel.FirmTypes = firmTypes;

            var user = repository.OfType <User>().Queryable.FirstOrDefault(a => a.LoweredUserName == userId.ToLower());

            if (user == null)
            {
                throw new ArgumentException(string.Format("Unable to load user with userid {0}.", userId));
            }

            // populate the application with person info
            var person = user.Person;

            // if person is not null, there should be at least one registration (seminar person)
            if (person != null)
            {
                viewModel.PersonId = person.Id;

                viewModel.Application.FirstName = person.FirstName;
                viewModel.Application.MI        = person.MI;
                viewModel.Application.LastName  = person.LastName;
                viewModel.Application.BadgeName = person.BadgeName;

                viewModel.Application.CommunicationOption       = person.CommunicationOption;
                viewModel.Application.ContactInformationRelease = person.ContactInformationRelease;

                // get latest seminar information
                var reg = person.GetLatestRegistration(siteId);
                if (reg != null)
                {
                    viewModel.Application.JobTitle = reg.Title;
                }

                // copy assistant information
                var assistant = person.Contacts.FirstOrDefault(a => a.ContactType.Id == 'A');

                if (assistant != null)
                {
                    viewModel.Application.AssistantEmail     = assistant.Email;
                    viewModel.Application.AssistantFirstName = assistant.FirstName;
                    viewModel.Application.AssistantLastName  = assistant.LastName;
                    viewModel.Application.AssistantPhone     = assistant.Phone;
                }

                var seminarPeople = person.GetLatestRegistration(siteId);
                if (seminarPeople != null)
                {
                    viewModel.Application.Firm = seminarPeople.Firm;
                }

                viewModel.Application.FirmPhone    = person.Phone;
                viewModel.Application.FirmPhoneExt = person.PhoneExt;

                var address = person.Addresses.FirstOrDefault(a => a.AddressType.Id == 'B');
                if (address != null)
                {
                    viewModel.Application.FirmAddressLine1 = address.Line1;
                    viewModel.Application.FirmAddressLine2 = address.Line2;
                    viewModel.Application.FirmCity         = address.City;
                    viewModel.Application.FirmState        = address.State;
                    viewModel.Application.FirmZip          = address.Zip;
                    viewModel.Application.Country          = address.Country;
                }
            }

            viewModel.HasPhoto = user.Person != null && user.Person.MainProfilePicture != null;

            // get the firms and add the "Other" option
            //var firms = new List<Firm>(firmService.GetAllFirms());
            //firms = firms.Where(a=>!a.Review && a.Name != "Other (Not Listed)").OrderBy(a=>a.Name).ToList();

            var tmpFirms = firmService.GetAllFirms();
            var firms    = new List <Firm>();

            firms.Add(tmpFirms.First(a => a.Name == "Other (Not Listed)"));
            firms.AddRange(tmpFirms.Where(a => !a.Review && a.Name != "Other (Not Listed)").OrderBy(a => a.Name).ToList());

            viewModel.Firms = firms;

            return(viewModel);
        }
Exemplo n.º 6
0
        public static ApplicationViewModel Create(IRepository repository, IFirmService firmService, string userId, string siteId, Application application = null, bool seminarTerms = false)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new ApplicationViewModel
                                {
                                    Application = application ?? new Application(),
                                    // always get the latest
                                    Seminar = SiteService.GetLatestSeminar(siteId),
                                    //Commodities = repository.OfType<Commodity>().Queryable.Where(a=>a.IsActive).OrderBy(a=>a.Name).ToList(),
                                    Countries = repository.OfType<Country>().GetAll(),
                                    CommunicationOptions = repository.OfType<CommunicationOption>().GetAll(),
                                    SeminarTerms = seminarTerms
                                };

            // load commodities
            var commodities = repository.OfType<Commodity>().Queryable.Where(a => a.IsActive).OrderBy(a => a.Name).ToList();
            viewModel.Commodities = commodities;

            // load the firm types
            var firmTypes = repository.OfType<FirmType>().Queryable.Where(a => a.IsActive).OrderBy(a => a.Name).ToList();
            viewModel.FirmTypes = firmTypes;

            var user = repository.OfType<User>().Queryable.FirstOrDefault(a => a.LoweredUserName == userId.ToLower());
            if (user == null) throw new ArgumentException(string.Format("Unable to load user with userid {0}.", userId));

            // populate the application with person info
            var person = user.Person;
            // if person is not null, there should be at least one registration (seminar person)
            if (person != null)
            {
                viewModel.PersonId = person.Id;

                viewModel.Application.FirstName = person.FirstName;
                viewModel.Application.MI = person.MI;
                viewModel.Application.LastName = person.LastName;
                viewModel.Application.BadgeName = person.BadgeName;

                viewModel.Application.CommunicationOption = person.CommunicationOption;
                viewModel.Application.ContactInformationRelease = person.ContactInformationRelease;

                // get latest seminar information
                var reg = person.GetLatestRegistration(siteId);
                if (reg != null)
                {
                    viewModel.Application.JobTitle = reg.Title;
                }

                // copy assistant information
                var assistant = person.Contacts.FirstOrDefault(a => a.ContactType.Id == 'A');

                if (assistant != null)
                {
                    viewModel.Application.AssistantEmail = assistant.Email;
                    viewModel.Application.AssistantFirstName = assistant.FirstName;
                    viewModel.Application.AssistantLastName = assistant.LastName;
                    viewModel.Application.AssistantPhone = assistant.Phone;
                }

                var seminarPeople = person.GetLatestRegistration(siteId);
                if (seminarPeople != null)
                {
                    viewModel.Application.Firm = seminarPeople.Firm;
                }

                viewModel.Application.FirmPhone = person.Phone;
                viewModel.Application.FirmPhoneExt = person.PhoneExt;

                var address = person.Addresses.FirstOrDefault(a => a.AddressType.Id == 'B');
                if (address != null)
                {
                    viewModel.Application.FirmAddressLine1 = address.Line1;
                    viewModel.Application.FirmAddressLine2 = address.Line2;
                    viewModel.Application.FirmCity = address.City;
                    viewModel.Application.FirmState = address.State;
                    viewModel.Application.FirmZip = address.Zip;
                    viewModel.Application.Country = address.Country;
                }
            }

            viewModel.HasPhoto = user.Person != null && user.Person.MainProfilePicture != null;

            // get the firms and add the "Other" option
            //var firms = new List<Firm>(firmService.GetAllFirms());
            //firms = firms.Where(a=>!a.Review && a.Name != "Other (Not Listed)").OrderBy(a=>a.Name).ToList();

            var tmpFirms = firmService.GetAllFirms();
            var firms = new List<Firm>();
            firms.Add(tmpFirms.First(a => a.Name == "Other (Not Listed)"));
            firms.AddRange(tmpFirms.Where(a=>!a.Review && a.Name != "Other (Not Listed)").OrderBy(a=>a.Name).ToList());

            viewModel.Firms = firms;

            return viewModel;
        }
Exemplo n.º 7
0
        public static PersonViewModel Create(IRepository repository, IFirmService firmService, string site, Seminar seminar = null, Person person = null, string email = null, Firm firm = null)
        {
            Check.Require(repository != null, "Repository must be supplied");

            var viewModel = new PersonViewModel()
            {
                Person    = person ?? new Person(),
                Addresses = repository.OfType <AddressType>().Queryable.Select(a => new Address()
                {
                    AddressType = a
                }).ToList(),
                Contacts = repository.OfType <ContactType>().Queryable.Select(a => new Contact()
                {
                    ContactType = a
                }).ToList(),
                Countries                                         = repository.OfType <Country>().GetAll(),
                CommunicationOptions                              = repository.OfType <CommunicationOption>().GetAll(),
                SeminarPerson                                     = person != null?person.GetLatestRegistration(site) : null,
                                                      Email       = email,
                                                      Seminar     = seminar,
                                                      Commodities = repository.OfType <Commodity>().Queryable.Where(a => a.IsActive).ToList(),
                                                      Firm        = firm ?? new Firm()
            };

            if (firm == null && viewModel.SeminarPerson != null)
            {
                viewModel.Firm = viewModel.SeminarPerson.Firm;
            }

            // find any addresses and replace them into the list
            if (person != null)
            {
                foreach (var a in person.Addresses)
                {
                    var addr = viewModel.Addresses.Where(b => b.AddressType == a.AddressType).FirstOrDefault();

                    if (addr != null)
                    {
                        viewModel.Addresses.Remove(addr);
                    }

                    viewModel.Addresses.Add(a);
                }

                foreach (var a in person.Contacts)
                {
                    var ct = viewModel.Contacts.Where(b => b.ContactType == a.ContactType).FirstOrDefault();

                    if (ct != null)
                    {
                        viewModel.Contacts.Remove(ct);
                    }

                    viewModel.Contacts.Add(a);
                }
            }

            // reorder so always in the same order
            viewModel.Addresses = viewModel.Addresses.OrderBy(a => a.AddressType.Id).ToList();
            viewModel.Contacts  = viewModel.Contacts.OrderBy(a => a.ContactType.Id).ToList();

            // get the firms and add the "Other" option
            var firms = new List <Firm>(firmService.GetAllFirms());

            firms.Add(new Firm()
            {
                Name = "Other (Not Listed)"
            });

            viewModel.Firms = firms;
            if (viewModel.Person.User != null)
            {
                viewModel.UserName = viewModel.Person.User.UserName;
            }

            return(viewModel);
        }