/// <summary> /// We receive the slug value as a kind of cross-cutting value that /// all methods need and use, so we catch and load the conference here, /// so it's available for all. Each method doesn't need the slug parameter. /// </summary> protected override void OnActionExecuting(ActionExecutingContext filterContext) { var slug = (string)this.ControllerContext.RequestContext.RouteData.Values["slug"]; if (!string.IsNullOrEmpty(slug)) { this.ViewBag.Slug = slug; this._conference = _conferenceQueryService.FindConference(slug).ToViewModel(); if (this._conference != null) { // check access var accessCode = (string)this.ControllerContext.RequestContext.RouteData.Values["accessCode"]; if (accessCode == null || !string.Equals(accessCode, this._conference.AccessCode, StringComparison.Ordinal)) { filterContext.Result = new HttpUnauthorizedResult("Invalid access code."); } else { this.ViewBag.OwnerName = this._conference.OwnerName; this.ViewBag.WasEverPublished = this._conference.WasEverPublished; } } } base.OnActionExecuting(filterContext); }
public static AddSeatType ToAddSeatTypeCommand(this SeatType model, ConferenceInfo conference) { var command = new AddSeatType(conference.Id); command.Name = model.Name; command.Description = model.Description; command.Price = model.Price; command.Quantity = model.Quantity; return command; }
public static UpdateConference ToUpdateConferenceCommand(this EditableConferenceInfo model, ConferenceInfo original) { var command = new UpdateConference(); command.AggregateRootId = original.Id; command.Name = model.Name; command.Description = model.Description; command.Location = model.Location; command.Tagline = model.Tagline; command.TwitterSearch = model.TwitterSearch; command.StartDate = model.StartDate; command.EndDate = model.EndDate; return command; }
public static ConferenceInfo ToViewModel(this ConferenceDTO dto) { if (dto == null) return null; var model = new ConferenceInfo(); model.Id = dto.Id; model.Name = dto.Name; model.Description = dto.Description; model.Location = dto.Location; model.Tagline = dto.Tagline; model.TwitterSearch = dto.TwitterSearch; model.StartDate = dto.StartDate; model.EndDate = dto.EndDate; model.AccessCode = dto.AccessCode; model.OwnerName = dto.OwnerName; model.OwnerEmail = dto.OwnerEmail; model.Slug = dto.Slug; model.IsPublished = dto.IsPublished; model.WasEverPublished = dto.WasEverPublished; return model; }