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 Post([FromBody] CurrentAiringIdViewModel viewModel) { CurrentAiringId blModel = viewModel.ToBusinessModel <CurrentAiringIdViewModel, CurrentAiringId>(); if (string.IsNullOrEmpty(blModel.Id)) { blModel.CreatedDateTime = DateTime.UtcNow; blModel.CreatedBy = HttpContext.User.Identity.Name; } else { blModel.ModifiedDateTime = DateTime.UtcNow; blModel.ModifiedBy = HttpContext.User.Identity.Name; } blModel = airingSvc.Save(blModel); return(blModel.ToViewModel <CurrentAiringId, CurrentAiringIdViewModel>()); }