Esempio n. 1
0
        public List <DepartmentProfile> ListDepartments(string latitude = null, string longitude = null)
        {
            var departments = new List <DepartmentProfile>();
            var profiles    = _departmentProfileService.GetAllActive();

            if (profiles != null && profiles.Any())
            {
                GeoCoordinate source;
                if (!String.IsNullOrWhiteSpace(latitude) && !String.IsNullOrWhiteSpace(longitude))
                {
                    source = new GeoCoordinate(double.Parse(latitude), double.Parse(longitude));
                }
                else
                {
                    source = new GeoCoordinate(0, 0);
                }

                foreach (var profile in profiles.OrderBy(x => x.Coordinate.GetDistanceTo(source)))
                {
                    var department = new DepartmentProfile();
                    department.ProfileId         = profile.DepartmentProfileId;
                    department.Did               = profile.DepartmentId;
                    department.Name              = profile.Name;
                    department.ShortName         = profile.ShortName;
                    department.Description       = profile.Description;
                    department.InCaseOfEmergency = profile.InCaseOfEmergency;
                    department.ServiceArea       = profile.ServiceArea;
                    department.ServicesProvided  = profile.ServicesProvided;
                    department.Founded           = profile.Founded;
                    //department.Logo = profile.Logo;
                    department.Keywords      = profile.Keywords;
                    department.InviteOnly    = profile.InviteOnly;
                    department.AllowMessages = profile.AllowMessages;
                    department.VolunteerPositionsAvailable = profile.VolunteerPositionsAvailable;
                    department.ShareStats           = profile.ShareStats;
                    department.VolunteerKeywords    = profile.VolunteerKeywords;
                    department.VolunteerDescription = profile.VolunteerDescription;
                    department.VolunteerContactName = profile.VolunteerContactName;
                    department.VolunteerContactInfo = profile.VolunteerContactInfo;
                    department.Geofence             = profile.Geofence;
                    department.Address     = profile.Address;
                    department.Latitude    = profile.Latitude;
                    department.Longitude   = profile.Longitude;
                    department.What3Words  = profile.What3Words;
                    department.Facebook    = profile.Facebook;
                    department.Twitter     = profile.Twitter;
                    department.GooglePlus  = profile.GooglePlus;
                    department.LinkedIn    = profile.LinkedIn;
                    department.Instagram   = profile.Instagram;
                    department.YouTube     = profile.YouTube;
                    department.Website     = profile.Website;
                    department.PhoneNumber = profile.PhoneNumber;

                    departments.Add(department);
                }
            }

            return(departments);
        }
Esempio n. 2
0
        public DepartmentProfile GetDepartment(string profileId, string userId)
        {
            int  id;
            Guid uid;

            if (!int.TryParse(profileId, out id))
            {
                return(null);
            }

            var department = new DepartmentProfile();
            var profile    = _departmentProfileService.GetProfileById(id);

            if (profile != null)
            {
                department.ProfileId         = profile.DepartmentProfileId;
                department.Did               = profile.DepartmentId;
                department.Name              = profile.Name;
                department.ShortName         = profile.ShortName;
                department.Description       = profile.Description;
                department.InCaseOfEmergency = profile.InCaseOfEmergency;
                department.ServiceArea       = profile.ServiceArea;
                department.ServicesProvided  = profile.ServicesProvided;
                department.Founded           = profile.Founded;
                //department.Logo = profile.Logo;
                department.Keywords      = profile.Keywords;
                department.InviteOnly    = profile.InviteOnly;
                department.AllowMessages = profile.AllowMessages;
                department.VolunteerPositionsAvailable = profile.VolunteerPositionsAvailable;
                department.ShareStats           = profile.ShareStats;
                department.VolunteerKeywords    = profile.VolunteerKeywords;
                department.VolunteerDescription = profile.VolunteerDescription;
                department.VolunteerContactName = profile.VolunteerContactName;
                department.VolunteerContactInfo = profile.VolunteerContactInfo;
                department.Geofence             = profile.Geofence;
                department.Address     = profile.Address;
                department.Latitude    = profile.Latitude;
                department.Longitude   = profile.Longitude;
                department.What3Words  = profile.What3Words;
                department.Facebook    = profile.Facebook;
                department.Twitter     = profile.Twitter;
                department.GooglePlus  = profile.GooglePlus;
                department.LinkedIn    = profile.LinkedIn;
                department.Instagram   = profile.Instagram;
                department.YouTube     = profile.YouTube;
                department.Website     = profile.Website;
                department.PhoneNumber = profile.PhoneNumber;

                var userFollows = _departmentProfileService.GetFollowsForUser(userId);

                if (userFollows != null && userFollows.Any(x => x.DepartmentProfileId == id))
                {
                    department.Following = true;
                }
            }

            return(department);
        }