Пример #1
0
        public ActionResult GetInvited(int eventPageId)
        {
            var invited = _eventPageAttendanceService.GetAllInvited(eventPageId);


            if (invited.Count == 0)
            {
                return(Json(null));
            }

            var invitedCustomers = _customerService.GetCustomersByIds(invited.Select(x => x.CustomerId).ToArray());

            var models = new List <object>();

            foreach (var customer in invitedCustomers)
            {
                models.Add(new
                {
                    CustomerId = customer.Id,
                    FullName   = customer.GetFullName(),
                    PictureUrl = _pictureService.GetPictureUrl(
                        customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId),
                        _mobSocialSettings.EventPageAttendanceThumbnailSize, _customerSettings.DefaultAvatarEnabled, defaultPictureType: PictureType.Avatar),
                    ProfileUrl = Url.RouteUrl("CustomerProfileUrl", new { SeName = SeoExtensions.GetSeName(customer, 0) }),
                });
            }

            return(Json(models));
        }
        public IHttpActionResult Get(int eventPageId, AttendanceStatus status)
        {
            List <EventPageAttendance> attendees = null;

            switch (status)
            {
            case AttendanceStatus.Going:
                attendees = _eventPageAttendanceService.GetAllGoing(eventPageId);
                break;

            case AttendanceStatus.NotGoing:
                attendees = _eventPageAttendanceService.GetAllNotGoing(eventPageId);
                break;

            case AttendanceStatus.Maybe:
                attendees = _eventPageAttendanceService.GetAllMaybies(eventPageId);
                break;

            case AttendanceStatus.Invited:
                attendees = _eventPageAttendanceService.GetAllInvited(eventPageId);
                break;
            }
            var userIds = attendees.Select(x => x.CustomerId);

            var users = _userService.Get(x => userIds.Contains(x.Id)).ToArray();

            var models = new List <object>();

            foreach (var user in users)
            {
                models.Add(user.ToModel(_mediaService, _mediaSettings));
            }

            return(RespondSuccess(new { Users = models }));
        }