Example #1
0
        public AiringIdRoutes(IAiringIdService service)
            : base("v1")
        {
            this.RequiresAuthentication();

            Get("/airingId/generate/{prefix}", _ =>
            {
                this.RequiresClaims(c => c.Type == HttpMethod.Get.Verb());

                return(service.Distribute((string)_.prefix)
                       .ToViewModel <CurrentAiringId, CurrentAiringIdViewModel>());
            });

            Post("/airingId/{prefix}", _ =>
            {
                this.RequiresClaims(c => c.Type == HttpMethod.Post.Verb());
                CurrentAiringId airingId = service.Create((string)_.prefix);
                return(airingId.ToViewModel <CurrentAiringId, CurrentAiringIdViewModel>());
            });

            Delete("/airingId/{prefix}", _ =>
            {
                this.RequiresClaims(c => c.Type == HttpMethod.Delete.Verb());
                service.Delete((string)_.prefix);
                return(new { Message = "deleted successfully" });
            });
        }
        public CurrentAiringIdViewModel GenerateAiringId(string prefix)
        {
            CurrentAiringIdViewModel currentAiringIdModel = airingSvc.Distribute(prefix).ToViewModel <CurrentAiringId, CurrentAiringIdViewModel>();

            return(currentAiringIdModel);
        }