예제 #1
0
        // DELETE api/Events/1
        public HttpResponseMessage DeleteEvent(int id)
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            if (EventPhotosService.IsEventType(ev, EventPhotosService.EVENTTYPE_NEW))
            {
                if (EventsController.ClearEventRelationships(ev, db))
                {
                    db.Events.Remove(ev);

                    try {
                        db.SaveChanges();
                    }
                    catch (DbUpdateConcurrencyException ex) {
                        FotoShoutUtils.Log.LogManager.Error(_logger, ex.ToString());
                        this.GenerateException(HttpStatusCode.NotFound, ex.Message);
                    }

                    return(Request.CreateResponse(HttpStatusCode.OK, ev));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, string.Format(Errors.ERROR_EVENT_CLEARREL, ev.EventName)));
                }
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, string.Format(Errors.ERROR_EVENT_DELETE_ANNOTATED, ev.EventName)));
            }
        }
예제 #2
0
        public int GetNumUnclaimedPhotos(int id)
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            try {
                return(EventPhotosService.GetNumUnclaimedPhotos(ev));
            }
            catch (Exception ex) {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message));
            }
        }
예제 #3
0
        public IEnumerable <PhotoTDO> GetUnclaimedPhotos(int id, int page = 0, int pageSize = 12)
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            try {
                return(EventPhotosService.GetUnclaimedPhotos(ev, page, pageSize));
            }
            catch (Exception ex) {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message));
            }
        }
예제 #4
0
        public IEnumerable <PhotoTDO> GetPublishedPhotosByGuest(int id, string name)
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db, true, true);

            try {
                return(EventPhotosService.GetPublishedPhotosByGuest(ev, name, db));
            }
            catch (Exception ex) {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.ToString()));
            }
        }
예제 #5
0
        public IEnumerable <PhotoTDO> GetPhotos(int id, int page = 0, int pageSize = 12)
        {
            LogManager.Info(EventPhotosController._logger, string.Format("Getting photos of the event {0}...", id));
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db, false, false);

            try {
                return(EventPhotosService.GetPhotos(ev));
            }
            catch (Exception ex) {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message));
            }
        }
예제 #6
0
        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()));
            }
        }
예제 #7
0
        public int GetNumProcessedPhotos(int id, string name, string created = null)
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db, true, true);

            try {
                return(EventPhotosService.GetNumProcessedPhotosByGuest(ev, name, created));
            }
            catch (Exception ex) {
                LogManager.Error(EventPhotosController._logger, ex.ToString());
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message));
            }
        }
예제 #8
0
        public IEnumerable <PhotoGroupTDO> GetProcessedPhotoGroupsByDate(int id)
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            try {
                return(EventPhotosService.GetProcessedPhotoGroupsByDate(ev, db));
            }
            catch (Exception ex) {
                LogManager.Error(EventPhotosController._logger, ex.ToString());
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.ToString()));
            }
        }
예제 #9
0
        // GET api/EventBroadcasts/5
        public IEnumerable <EventBroadcast> GetEventBroadcasts(int id)
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            try {
                return(EventBroadcastsService.GetBroadcasts(ev, db));
            }
            catch (Exception ex) {
                FotoShoutUtils.Log.LogManager.Error(_logger, ex.ToString());
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message));
            }
        }
예제 #10
0
        public IEnumerable <PhotoTDO> GetSubmittedPhotosByGuest(int id, string name)
        {
            LogManager.Info(EventPhotosController._logger, string.Format("Getting submitted photos of the event {0} by {1} ...", id, name));
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db, true, true);

            try {
                return(EventPhotosService.GetSubmittedPhotosByGuest(ev, name, db));
            }
            catch (Exception ex) {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.ToString()));
            }
        }
예제 #11
0
        public EventDetailsTDO GetProcessedPhotosReporting(int id)
        {
            LogManager.Info(EventPhotosController._logger, string.Format("Getting reporting processed photos of the event {0}...", id));
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            try {
                return(EventPhotosService.GetProcessedPhotosReporting(ev, db));
            }
            catch (Exception ex) {
                LogManager.Error(EventPhotosController._logger, ex.ToString());
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message));
            }
        }
예제 #12
0
        public IEnumerable <PhotoDetailsTDO> GetProcessedPhotosDetailing(int id, string created = null, int page = 0, int pageSize = 12)
        {
            LogManager.Info(EventPhotosController._logger, string.Format("Getting details of the processed photos of the event {0}...", id));
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            try {
                return(EventPhotosService.GetProcessedPhotosDetailing(ev, created, page, pageSize, db));
            }
            catch (Exception ex) {
                LogManager.Error(EventPhotosController._logger, ex.ToString());
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message));
            }
        }
예제 #13
0
        public IEnumerable <PhotoTDO> GetUnauthorizedPhotos(int id)
        {
            LogManager.Info(EventPhotosController._logger, string.Format("Getting unauthorized photos of the event {0}...", id));
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            try {
                return(EventPhotosService.GetUnauthorizedPhotos(ev, db));
            }
            catch (Exception ex) {
                LogManager.Error(EventPhotosController._logger, ex.ToString());
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.ToString()));
            }
        }
예제 #14
0
        private HttpResponseMessage UpdateClaimingPhotoStatus(int id, string filename, PhotoStatus status)
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            try {
                if (status == PhotoStatus.Unclaimed)
                {
                    PhotoAnnotationService.MovePhoto(ev.EventFolder, Constants.STR_UNCLAIMED, filename);
                }
                else if (status == PhotoStatus.Unselected)
                {
                    PhotoAnnotationService.RestorePhoto(ev.EventFolder, Constants.STR_UNCLAIMED, filename);
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex) {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, ex.ToString()));
            }
        }
예제 #15
0
        // GET api/Events/1
        public EventTDO GetEvent(int id)
        {
            if (id == 0)
            {
                return(GenerateTDO());
            }

            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            if (ev == null)
            {
                string msg = string.Format("The {0} event not found.", id.ToString());
                FotoShoutUtils.Log.LogManager.Error(_logger, msg);
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    ReasonPhrase = msg, Content = new StringContent(msg)
                });
            }

            return(GenerateTDO(ev));
        }
예제 #16
0
        public HttpResponseMessage SelectPhoto(int id, string filename)
        {
            Event ev    = EventsController.GetEvent(id, CurrentUser.Id, Request, db);
            Photo photo = GetPhotoFromId(id)
                          .Where(p => p.Filename.Equals(filename, StringComparison.InvariantCultureIgnoreCase)).SingleOrDefault();

            if (photo == null)
            {
                string folder    = ev.EventFolder.EndsWith(Path.DirectorySeparatorChar.ToString()) ? ev.EventFolder : (ev.EventFolder + Path.DirectorySeparatorChar);
                string thumbnail = File.Exists(folder + Constants.STR_THUMB + "/" + filename) ? (ev.EventVirtualPath + "/" + Constants.STR_THUMB + "/" + filename) : "";
                photo = new Photo {
                    PhotoId   = Guid.NewGuid(),
                    Folder    = ev.EventFolder,
                    Filename  = filename,
                    Image     = ev.EventVirtualPath + '/' + filename,
                    Thumbnail = thumbnail,
                    Created   = File.GetCreationTime(folder + filename),
                    Event     = ev
                };
                ev.Photos.Add(photo);
            }
            else if (photo.Status == (byte)PhotoStatus.Selected)
            {
                return(Request.CreateResponse(HttpStatusCode.Conflict, string.Format("The {0} photo is editing by someone else.", filename)));
            }

            photo.Status = (byte)PhotoStatus.Selected;

            try {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex) {
                LogManager.Error(EventPhotosController._logger, ex.ToString());
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, ex.ToString()));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, EventPhotosService.GenerateTDO(ev, photo)));
        }
예제 #17
0
        private HttpResponseMessage UpdateEventStatus(int id, EventStatus status)
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);

            try {
                ev.EventStatus = (byte)status;
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex) {
                string validationErrors = GetValidationErrors(ex.EntityValidationErrors);
                this.GenerateException(HttpStatusCode.NotFound, validationErrors, _logger);
            }
            catch (DbUpdateConcurrencyException ex) {
                FotoShoutUtils.Log.LogManager.Error(_logger, ex.ToString());
                this.GenerateException(HttpStatusCode.NotFound, ex.Message);
            }
            catch (Exception ex) {
                FotoShoutUtils.Log.LogManager.Error(_logger, ex.ToString());
                this.GenerateException(HttpStatusCode.InternalServerError, ex.Message);
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
예제 #18
0
        private HttpResponseMessage UpdatePhotoStatus(int id, string filename, PhotoStatus condStatus, PhotoStatus status, string error = "")
        {
            Event ev = EventsController.GetEvent(id, CurrentUser.Id, Request, db);
            HttpResponseMessage response = null;

            try {
                response = DoUpdatePhotoStatus(id, filename, condStatus, status, error);
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    db.SaveChanges();
                }
            }
            catch (DbUpdateConcurrencyException ex) {
                FotoShoutUtils.Log.LogManager.Error(_logger, ex.ToString());
                this.GenerateException(HttpStatusCode.NotFound, ex.Message);
            }
            catch (Exception ex) {
                FotoShoutUtils.Log.LogManager.Error(_logger, ex.ToString());
                this.GenerateException(HttpStatusCode.InternalServerError, ex.Message);
            }

            return(response);
        }
예제 #19
0
 public ActionResult EditEvent(int id)
 {
     return(PartialView("EditEvent", apiEvents.GetEvent(id)));
 }