Esempio n. 1
0
        public QuotesModule(IQuotesRepository quotesRepository)
            : base("/Quotes/")
        {
            db = Database.Open();

            Get["{Id}"] = parameters => { return View["quote.cshtml", GetQuoteVm(parameters.Id)]; };

            Get[""] = parameters => { return View["quoteList.cshtml", GetIndexVm(string.Empty)]; };

            Get["/Kid/{KidName}"] = parameters => { return View["quoteList.cshtml", GetIndexVm(parameters.KidName)]; };

            Post["AddLike"] = parameters =>
                {
                    var quoteId = IDFromLikedURL;
                    quotesRepository.AddLikeForQuote(quoteId);

                    return Response.AsJson(string.Format(LIKE_INCREMENTED_FORMAT, quoteId));
                };

            Post["RemoveLike"] = parameters =>
                {
                    var quoteId = IDFromLikedURL;
                    quotesRepository.RemoveLikeForQuote(quoteId);

                    return Response.AsJson(string.Format(LIKE_DECREMENTED_FORMAT, quoteId));
                };
        }