Example #1
0
 private void UpdateTDO(EventTDO tdo, Event ev)
 {
     tdo.EventId          = ev.EventId;
     tdo.Created          = ev.Created;
     tdo.CreatedBy        = ev.CreatedBy;
     tdo.EventVirtualPath = ev.EventVirtualPath;
     tdo.Thumbnail        = AppConfigs.VirtualRoot + EventPhotosService.GetThumbnailUrl(ev.EventId, ev.EventFolder, ev.EventVirtualPath, db);
 }
Example #2
0
        // GET api/Events
        public IEnumerable <EventTDO> GetEvents(string eventType = "")
        {
            EventStatus        evType = EventPhotosService.GetEventStatus(eventType);
            HashSet <EventTDO> tdos   = new HashSet <EventTDO>();

            try {
                IEnumerable <Event> events = (evType != EventStatus.Undefined) ?
                                             db.Events.Where(ev => ev.User.Id == CurrentUser.Id && ev.EventStatus == (byte)evType).Include(e => e.EventOption).OrderBy(ev => ev.EventName).ToList() :
                                             db.Events.Where(ev => ev.User.Id == CurrentUser.Id).Include(e => e.EventOption).OrderBy(ev => ev.EventName).ToList();
                if (events.Any())
                {
                    foreach (Event ev in events)
                    {
                        string error = DirectoryUtils.GenerateDirectories(ev.EventFolder);
                        if (!string.IsNullOrEmpty(error))
                        {
                            this.GenerateException(HttpStatusCode.InternalServerError, error, _logger);
                        }
                        FotoShoutApi.Services.IO.DirectoryService.GenerateVirtualPath(ev.EventFolder);

                        if (evType != EventStatus.Undefined || EventPhotosService.IsEventType(ev, eventType))
                        {
                            EventTDO tdo = new EventTDO {
                                EventId          = ev.EventId,
                                EventName        = ev.EventName,
                                EventDescription = ev.EventDescription,
                                EventDate        = ev.EventDate,
                                EventLocation    = ev.EventLocation,
                                EventFolder      = ev.EventFolder,
                                EventVirtualPath = ev.EventVirtualPath,
                                Created          = ev.Created,
                                CreatedBy        = ev.CreatedBy,
                                EventOptionId    = ev.EventOption.EventOptionId,
                                EventStatus      = ev.EventStatus,
                                PublishAlbum     = ev.PublishAlbum
                            };

                            try {
                                string relativeThumbnail = EventPhotosService.GetThumbnailUrl(tdo.EventId, tdo.EventFolder, tdo.EventVirtualPath, db);
                                tdo.Thumbnail = string.IsNullOrEmpty(relativeThumbnail) ? "" : AppConfigs.VirtualRoot + relativeThumbnail;
                            }
                            catch (ObjectNotFoundException) {
                                tdo.Thumbnail = "";
                            }
                            tdos.Add(tdo);
                        }
                    }
                }
            }
            catch (Exception ex) {
                FotoShoutUtils.Log.LogManager.Error(_logger, ex.ToString());
                this.GenerateException(HttpStatusCode.InternalServerError, ex.Message);
            }

            return(tdos);
        }
        public string GetThumbnailUrl(int id)
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            try {
                return(AppConfigs.VirtualRoot + EventPhotosService.GetThumbnailUrl(ev.EventId, ev.EventFolder, ev.EventVirtualPath, db));
            }
            catch (Exception ex) {
                LogManager.Error(EventPhotosController._logger, ex.ToString());
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.ToString()));
            }
        }