Ejemplo n.º 1
0
        public async Task <string> AdvancedSearch([Bind("StockOrderID,MovieID,Quantity")] MovieStockOrder searchMovieStockOrder)
        {
            var result = _context.MovieStockOrder.AsQueryable();

            if (searchMovieStockOrder != null)
            {
                if (searchMovieStockOrder.StockOrderID != null)
                {
                    result = result.Where(movieStockOrder => movieStockOrder.StockOrderID == searchMovieStockOrder.StockOrderID);
                }
                if (searchMovieStockOrder.MovieID != null)
                {
                    result = result.Where(movieStockOrder => movieStockOrder.MovieID == searchMovieStockOrder.MovieID);
                }
                if (searchMovieStockOrder.Quantity != 0)
                {
                    result = result.Where(movieStockOrder => movieStockOrder.Quantity == searchMovieStockOrder.Quantity);
                }
            }
            var list = await result.ToListAsync();

            var listJason = Newtonsoft.Json.JsonConvert.SerializeObject(list);

            return(listJason);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(string StockOrderID, string MovieID, [Bind("StockOrderID,MovieID,Quantity")] MovieStockOrder movieStockOrder)
        {
            if (StockOrderID != movieStockOrder.StockOrderID || MovieID != movieStockOrder.MovieID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movieStockOrder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieStockOrderExists(movieStockOrder.StockOrderID, movieStockOrder.MovieID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MovieID"]      = new SelectList(_context.Movie, "MovieID", "MovieID", movieStockOrder.MovieID);
            ViewData["StockOrderID"] = new SelectList(_context.StockOrder, "StockOrderID", "StockOrderID", movieStockOrder.StockOrderID);
            return(View(movieStockOrder));
        }