// 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))); } }
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)); } }
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)); } }
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())); } }
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)); } }
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())); } }
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)); } }
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())); } }
// 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)); } }
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())); } }
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)); } }
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)); } }
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())); } }
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())); } }
// 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)); }
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))); }
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)); }
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); }
public ActionResult EditEvent(int id) { return(PartialView("EditEvent", apiEvents.GetEvent(id))); }