public IHttpActionResult GetPhotosPost(int?page = null, int?pageSize = null, int?id = null) { ISiteMember member; if (!id.HasValue && Members.IsLoggedIn()) { var m = Members.GetCurrentMember(); member = ContextService.MembershipHelper.MapMember(m); } else if (id.HasValue) { var m = Members.GetById(id.Value); member = ContextService.MembershipHelper.MapMember(m); } else { var payload = new PayloadResult(); payload.SetMessageType(GenericMessages.Danger); payload.SetMessage("No member is logged in and no id was passed!"); return(Error(payload, HttpStatusCode.InternalServerError)); } var photos = member.GetPhotos().Select( media => { var typedMedia = Umbraco.TypedMedia(media.Id); var mediaModel = (MemberImageType)CodeFirstHelper.TypedMedia(typedMedia); return(mediaModel); }).OrderByDescending(x => x.CreateDate); var pageNumber = page ?? 1; var pagedResult = photos.ToPagedList(pageNumber, pageSize ?? 25); return(Json(new { items = pagedResult, totalPages = pagedResult.PageCount })); }
public IHttpActionResult UnregisterPost(int eventId, int memberId) { var status = EventRepository.RemoveParticipant(eventId, memberId); if (status == EventStatus.Unregistered) { var currentMember = Members.GetById(memberId); var currentMappedMember = ContextService.MembershipHelper.MapMember(currentMember); currentMappedMember.MemberField = string.Empty; var eventPage = CodeFirstHelper.TypedContent <EventPageModel>(eventId); // Remove any scheduled mails for this event and member. Mailer.RemoveScheduleNotifyEventStart(currentMappedMember, eventPage); } return(Json(status)); }
public IHttpActionResult BuildStatePost(int eventId, int?memberId = null) { var eventPage = CodeFirstHelper.TypedContent <EventPageModel>(eventId); var payload = new EventStatePayload(); if (memberId.HasValue && memberId.Value != -1) { var participating = eventPage.Participants.FirstOrDefault(x => x.Id == memberId.Value); payload.IsParticipating = participating != null; } DateTime eventDate; if (eventPage.StartDate.HasValue) { eventDate = new DateTime(eventPage.StartDate.Value.Year, eventPage.StartDate.Value.Month, eventPage.StartDate.Value.Day, eventPage.StartDate.Value.Hour, eventPage.StartDate.Value.Minute, eventPage.StartDate.Value.Second); } else { // We have no start date mark this as closed. payload.Closed = true; payload.CanUnregister = false; return(Json(payload)); } // Closing un-registrations ? if (eventDate < DateTime.Now) { // Course closed payload.Closed = true; } var stopRegistrations = eventDate.AddHours(-48); if (stopRegistrations < DateTime.Now) { payload.CanUnregister = false; } else { payload.CanUnregister = true; } return(Json(payload)); }
public IHttpActionResult RegisterPost(int eventId, int memberId) { var status = EventRepository.AddParticipant(eventId, memberId); if (status == EventStatus.Registered) { var currentMember = Members.GetById(memberId); var eventPage = CodeFirstHelper.TypedContent <EventPageModel>(eventId); var currentMappedMember = ContextService.MembershipHelper.MapMember(currentMember); Mailer.SendNotifyEventApplied(currentMappedMember, eventPage); // Notify the member who applied. foreach (var activity in eventPage.EventActivities) { // Create a qued email close to this event's start date. Mailer.ScheduleSendNotifyEventStart(currentMappedMember, eventPage, activity); } } return(Json(status)); }