예제 #1
0
        // GET: Quote
        public ActionResult Index(int?page)
        {
            var quotes     = _quoteRepository.GetAll();
            int pageSize   = 5;
            int pageNumber = (page ?? 1);

            return(View(quotes.ToPagedList(pageNumber, pageSize)));
        }
예제 #2
0
        // GET: Quote
        public ActionResult Index(int?page)
        {
            var quotes     = _quoteRepository.GetAll();
            int pageSize   = 5;
            int pageNumber = (page ?? 1);



            ViewBag.AuthorsHome = _authorRepository.GetAll().OrderByDescending(a => a.AuthorID).Take(8);

            return(View(quotes.ToPagedList(pageNumber, pageSize)));
        }
예제 #3
0
        public async Task <IActionResult> Get()
        {
            var allQuotes = new List <Quote.DataAccess.Models.Quote>();

            try
            {
                allQuotes = await quoteRepository.GetAll();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(this.Ok(allQuotes));
        }
예제 #4
0
        public QuoteResponse GetQuoteResponse(int?id)
        {
            QuoteResponse response = new QuoteResponse();

            if (id != null)
            {
                response.Quote = quoteRepository.GetQuoteAndQuoteDetail((int)id);
            }
            else
            {
                response.QuoteCount = quoteRepository.GetAll().Count() + 1;
            }

            //BaseData
            response.Contacts      = contactRepository.GetAll().ToList();
            response.Products      = productRepository.GetAll().ToList();
            response.ProductModels = productModelRepository.GetAll().ToList();
            response.Exclusions    = exclusionRepository.GetAll().ToList();


            return(response);
        }
예제 #5
0
 public ActionResult <List <Quote> > GetAll()
 {
     return(quoteRepository.GetAll());
 }
예제 #6
0
 public Task <List <Quote> > GetAll()
 {
     return(_quoteRepository.GetAll());
 }
예제 #7
0
        public ActionResult Index(string channelName)
        {
            var quotes = db.GetAll(channelName);

            return(View(quotes));
        }
예제 #8
0
        public QuoteModule(IQuoteRepository repo)
        {
            _repo = repo;

            #region Before Request Hook

            Before += ctx =>
            {
                Console.WriteLine("I'm about to execute {0}", ctx.Request.Url.ToString());
                return(null);
            };

            #endregion

            Get["/quote"] = _ =>
            {
                var quotes = _repo.GetAll();
                SetUserName(quotes);
                return(View["Index.cshtml", quotes]);
            };

            Get["/api/quote"] = _ =>
            {
                //need to materialize the list...
                //  content negotiation won't render to XML
                //  but JSON works fine if just an IEnumerable<>
                return(_repo.GetAll().Quotes.ToList());
            };

            Get["/quote/{id}"] = args =>
            {
                var quote = _repo.GetWithDetail(args.id);
                SetUserName(quote);
                return(View["details.cshtml", quote]);
            };

            Get["/quote/create"] = _ =>
            {
                this.RequiresAuthentication();
                var model = new Quote();
                SetUserName(model);

                return(View["create.cshtml", model]);
            };

            Post["/quote/create"] = args =>
            {
                this.RequiresAuthentication();

                var newQuote = this.Bind <Quote>();
                if (_repo.Insert(newQuote))
                {
                    return(this.Response.AsRedirect("/quote"));
                }
                else
                {
                    return(View["index.cshtml"]);
                }
            };

            Get["/quote/delete/{id}"] = args =>
            {
                this.RequiresAuthentication();

                _repo.DeleteById(args.id);
                return(this.Response.AsRedirect("/quote"));
            };

            Get["/quote/edit/{id}"] = args =>
            {
                this.RequiresAuthentication();

                var quote = _repo.GetById(args.id);
                SetUserName(quote);
                return(View["edit.cshtml", quote]);
            };

            Post["/quote/edit/{id}"] = model =>
            {
                this.RequiresAuthentication();

                var theQuote = this.Bind <Quote>();
                if (_repo.Update(theQuote))
                {
                    return(this.Response.AsRedirect("/quote"));
                }
                else
                {
                    return("ooops!");
                }
            };

            Get["/quote/search"] = args =>
            {
                var model = new QuoteHighlights();
                SetUserName(model);
                Int32 numFound;
                var   searchResults = _repo.Search((String)this.Request.Query.id, out numFound);
                ViewBag.TotalResults = numFound;
                ViewBag.NumberShown  = searchResults.Count();
                ViewBag.Term         = (String)this.Request.Query.id;
                model.Quotes         = searchResults.ToList();
                return(View["search.cshtml", model]);
            };
        }
예제 #9
0
 public ActionResult Create()
 {
     ViewBag.Quotes = _quoteRepository.GetAll();
     ViewBag.Users  = _userRepository.GetAll();
     return(View());
 }
 public IActionResult Get()
 {
     return(Ok(_quoteRepository.GetAll()));
 }