public ActionResult CreateQuotePartial()
        {
            _activeQuoteSrv.UserVM = UserVM;
            CreateQuoteViewModel createQVM = _activeQuoteSrv.GetQuoteTypes();

            this.AssignUserVM(createQVM.UserVM);
            return(PartialView("../TCPViews/Partial/Quote/CreateQuotePartial", createQVM));
        }
예제 #2
0
        private Quote OnPostCreateQuote(CreateQuoteViewModel viewModel)
        {
            var quote = this.mapper.Map <Quote>(viewModel);

            quote.AuthorId = viewModel.AuthorId;
            quote.BookId   = viewModel.BookId;
            this.context.Quotes.Add(quote);
            this.context.SaveChanges();
            return(quote);
        }
예제 #3
0
        public IActionResult Create(CreateQuoteViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var createdQuote = this.OnPostCreateQuote(viewModel);
                return(this.RedirectToAction("Details", createdQuote.Id));
            }

            return(this.View(viewModel));
        }
예제 #4
0
        public ActionResult Create(CreateQuoteViewModel model)
        {
            try
            {
                _quoteService.CreateQuote(model.PersonName, model.QuoteContent);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
예제 #5
0
        public ActionResult CreateQuote(int?minPN, int?minTemp)
        {
            QuotingSystemDbEntities db = new QuotingSystemDbEntities();
            var filteredProducts       = db.Products.ToList();

            if (minPN != null)
            {
                filteredProducts = filteredProducts.Where(p => p.PN >= minPN).ToList();
            }
            if (minTemp != null)
            {
                filteredProducts = filteredProducts.Where(p => p.Temp >= minTemp).ToList();
            }

            Product PrefferedProduct = filteredProducts.OrderBy(p => p.Price).FirstOrDefault();

            CreateQuoteViewModel vm = new CreateQuoteViewModel(minPN, minTemp, filteredProducts, PrefferedProduct, db.Customers.ToList());

            return(View(vm));
        }
예제 #6
0
        public ActionResult CreateQuote(CreateQuoteViewModel quote)
        {
            if (!ModelState.IsValid)
            {
                //TODO: Check what should be returned in case of wrong input
                return(View("CreateQuote", quote));
            }
            QuotingSystemDbEntities db = new QuotingSystemDbEntities();

            var newQuote = new Quote()
            {
                SelectedCustomer = db.Customers.Find(quote.SelectedCustomerId),
                SelectedProduct  = db.Products.Find(quote.SelectedProductId)
            };

            db.Quotes.Add(newQuote);
            db.SaveChanges();
            TempData["QuoteAdded"] = $"New quote (Id: {newQuote.QuoteId}) successfully added!";

            return(RedirectToAction("Index"));
        }
예제 #7
0
        public async Task<ActionResult<Quote>> PostQuote(CreateQuoteViewModel model)
        {
            User user = await _context.Users.FindAsync(User.Claims.ToList()[0].Value);

            if (user == null)
                return Unauthorized();

            Movie movie = _movieRepository.GetMovie(User, model.MovieID);
            if (movie == null)
                return NotFound("Movie " + model.MovieID + " not found.");

            Quote quote = new Quote
            {
                Title = model.Title,
                Text = model.Text,
                MovieID = movie.Id
            };
            _context.Quotes.Add(quote);
            await _context.SaveChangesAsync();

            return CreatedAtAction("GetQuote", new { id = quote.Id }, quote);
        }