Esempio n. 1
0
 public ProposalView(IEnumerable <Proposal> proposals) :
     base(TITLE,
          H2(Text("Proposals List"))
          , Ul(proposals.Select(proposal => Li(A(ResolveUri.For(proposal), string.Format("{0} ({1})", proposal.Show.Name, proposal.Status.ToString())))).ToArray())
          , A(ResolveUri.ForNewProposal(), "Create New")
          )
 {
 }
Esempio n. 2
0
 public PlaylistListView(IEnumerable <ViewPlaylist> p)
     : base("Playlists",
            H1(Text("Playlist list")),
            Ul(
                p.Select(pl => Li(A(ResolveUri.For(pl), pl.Name))).ToArray()
                ),
            A(ResolveUri.ForPlaylistNew(), "New")
            )
 {
 }
Esempio n. 3
0
        public HttpResponse EditProposalSubmit(IEnumerable <KeyValuePair <string, string> > content)
        {
            int proposalId = Convert.ToInt32(content.GetValue("proposal_id"));

            Proposal proposal = ProposalService.GetProposalById(proposalId);

            proposal.Show.Name        = content.GetValue("show_name");
            proposal.Show.Description = content.GetValue("show_description");

            return(new HttpResponse(HttpStatusCode.Found).WithHeader("Location", ResolveUri.For(proposal)));
        }
Esempio n. 4
0
        public HttpResponse NewProposal(IEnumerable <KeyValuePair <string, string> > content)
        {
            Show show = new Show
            {
                Name          = content.GetValue("show_name")
                , Description = content.GetValue("show_description")
            };
            Proposal proposal = ProposalService.AddProposal(show, GetUser());

            return(new HttpResponse(HttpStatusCode.Found).WithHeader("Location", ResolveUri.For(proposal)));
        }
Esempio n. 5
0
 public UsersView(IEnumerable <User> users) :
     base("Users",
          H1(Text("User List"))
          , Ul(users.Select(user => Li(A(ResolveUri.For(user), user.Identity.Name))).ToArray())
          , H2(Text("Create a New User"))
          , Form("post", "/users", Label("username", "Username"), InputText("username")
                 , Label("password", "Password"), InputText("password", true)
                 , Label("submit", "Submit"), InputSubmit("Submit")
                 )
          )
 {
 }
Esempio n. 6
0
 public SearchView(List <ViewArtist> artists, SearchInfo info)
     : base("Search Results",
            H1(Text("Results")),
            H2(Text("Artists")),
            artists.Count > 0
         ? Ul(artists.Select(art => Li(Text(art.Name), A(ResolveUri.For(art), "View"))).ToArray())
         : Text("No results found"),
            //SearchFrame(info),
            Ul(
                Li(A(ResolveUri.ForHome(), "Home")),
                Li(A(ResolveUri.ForPlaylist(), "Playlists"))
                )
            )
 {
 }
Esempio n. 7
0
        public HttpResponse Post(IEnumerable <KeyValuePair <string, string> > content)
        {
            var desc = content.Where(p => p.Key == "desc").Select(p => p.Value).FirstOrDefault();

            if (desc == null)
            {
                return(new HttpResponse(HttpStatusCode.BadRequest));
            }
            var td = new ToDo {
                Description = desc
            };

            _repo.Add(td);
            return(new HttpResponse(HttpStatusCode.SeeOther).WithHeader("Location", ResolveUri.For(td)));
        }
Esempio n. 8
0
 public SearchView(List <ViewTrack> tracks, SearchInfo info)
     : base("Search Results",
            H1(Text("Results")),
            H2(Text("Tracks")),
            tracks.Count > 0
         ? Ul(
                tracks.Select(trc => Li(Text(trc.Name), A(ResolveUri.For(trc), trc.Name))).ToArray()
                )
         : Text("No results found"),
            //SearchFrame(info),
            Ul(
                Li(A(ResolveUri.ForHome(), "Home")),
                Li(A(ResolveUri.ForPlaylist(), "Playlists"))
                )
            )
 {
 }
Esempio n. 9
0
        public HttpResponseMessage Post(NameValueCollection content)
        {
            var desc = content["desc"];

            if (desc == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }
            var td = new ToDo {
                Description = desc
            };

            _repo.Add(td);
            var resp = new HttpResponseMessage(HttpStatusCode.SeeOther);

            resp.Headers.Location = new Uri(ResolveUri.For(td));
            return(resp);
        }
Esempio n. 10
0
        public HttpResponseMessage Edit(int id, NameValueCollection content)
        {
            //verificar
            var pl = new EditPlaylist(id, content["name"], content["desc"]);
            var p  = Rules.Edit.PlaylistTo(pl);

            //retornar resposta
            var response = new HttpResponseMessage(HttpStatusCode.SeeOther);

            response.Headers.Location = new Uri(string.Format("http://localhost:8080{0}", ResolveUri.For(p)));
            return(response);
        }
Esempio n. 11
0
        public HttpResponseMessage Post(NameValueCollection content)
        {
            CreatePlaylist cp       = new CreatePlaylist(content["name"], content["desc"]);
            var            playlist = Rules.Create.Playlist(cp);
            //retornar resposta
            var response = new HttpResponseMessage(HttpStatusCode.SeeOther);

            response.Headers.Location = new Uri(string.Format("http://localhost:8080{0}", ResolveUri.For(playlist)));
            return(response);
        }
Esempio n. 12
0
        [HttpMethod("POST", "/playlist/{href}/add")]//TODO: would look better if playlist was a parameter too
        public HttpResponseMessage AddTrack(string href, NameValueCollection content)
        {
            string playlistId = content["playlist"];
            int    id         = int.Parse(playlistId);
            var    playlist   = Rules.Find.Playlist(id);
            var    track      = Rules.Find.Track(href);

            if (playlist == null || !Rules.Edit.AddTrack(playlist, track))
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            var response = new HttpResponseMessage(HttpStatusCode.SeeOther);

            response.Headers.Location = new Uri(string.Format("http://localhost:8080{0}", ResolveUri.For(playlist)));
            return(response);
        }
Esempio n. 13
0
        public HttpResponseMessage Remove(string href, int id)
        {
            //verificar
            var playlist = Rules.Find.Playlist(id);
            var track    = Rules.Find.Track(href);

            if (playlist == null || !Rules.Edit.RemoveTrack(playlist, track))
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            //retornar resposta
            var response = new HttpResponseMessage(HttpStatusCode.SeeOther);

            response.Headers.Location = new Uri(string.Format("http://localhost:8080{0}", ResolveUri.For(playlist)));
            return(response);
        }