コード例 #1
0
        internal static OrganizationVm FromModel(Organization organization)
        {
            if (organization.Admin == null)
            {
                organization.Admin = new Admin();
            }

            List <NeededSubCategoryVm> subCategoriesForModel = new List <NeededSubCategoryVm>();

            if (organization.NeededSubCategories != null)
            {
                foreach (var type in organization.NeededSubCategories)
                {
                    subCategoriesForModel.Add(NeededSubCategoryVm.FromModel(type));
                }
            }

            List <LocationVm> locationsForModel = new List <LocationVm>();

            if (organization.Locations != null)
            {
                foreach (var type in organization.Locations)
                {
                    locationsForModel.Add(LocationVm.FromModel(type));
                }
            }

            return(new OrganizationVm
            {
                Id = organization.Id,
                Admin = AdminVm.FromModel(organization.Admin),
                ContactInformation = ContactInformationVm.FromModel(organization.HeadquartersContactInformation),
                EIN = organization.EIN,
                Name = organization.Name,
                NeededSubCategories = subCategoriesForModel,
                Subscription = organization.Subscription,
                Locations = locationsForModel,
                Budget = organization.Budget,
                DonationDescription = organization.DonationDescription,
                MissionStatement = organization.MissionStatement,
                Pickup = organization.Pickup,
                PathToLogo = organization.PathToLogo
            });
        }
コード例 #2
0
        private List<LocationVm> SaveLocationOnFirstSave(OrganizationVm organization)
        {
            ICollection<Location> locationsModel = new List<Location>();
            LocationVm vm = new LocationVm { Address = organization.ContactInformation };
            {
                locationsModel.Add(vm.ToModel());
            }
            try
            {
                this.organizationService.SaveLocations(organization.Id, locationsModel);

                List<LocationVm> responseModel = new List<LocationVm>();

                foreach (Location m in locationsModel)
                {
                    responseModel.Add(LocationVm.FromModel(m));
                }
                return responseModel;
            }
            catch (Exception e)
            {
                emailHelper.SendErrorEmail(e);
            }
            return null;
        }