コード例 #1
0
        public async Task <IActionResult> PutOrders(int id, Orders orders)
        {
            if (id != orders.OrderId)
            {
                return(BadRequest());
            }

            _context.Entry(orders).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrdersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("CustomerId,FirstName,LastName,Phone,Email,Street,City,State,ZipCode")] Customers customers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customers));
        }
コード例 #3
0
ファイル: StoresController.cs プロジェクト: Allandres/Quiz1
        public async Task <IActionResult> Create([Bind("StoreId,StoreName,Phone,Email,Street,City,State,ZipCode")] Stores stores)
        {
            if (ModelState.IsValid)
            {
                _context.Add(stores);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(stores));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("StaffId,FirstName,LastName,Email,Phone,Active,StoreId,ManagerId")] Staffs staffs)
        {
            if (ModelState.IsValid)
            {
                _context.Add(staffs);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ManagerId"] = new SelectList(_context.Staffs, "StaffId", "Email", staffs.ManagerId);
            ViewData["StoreId"]   = new SelectList(_context.Stores, "StoreId", "StoreName", staffs.StoreId);
            return(View(staffs));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("StoreId,ProductId,Quantity")] Stocks stocks)
        {
            if (ModelState.IsValid)
            {
                _context.Add(stocks);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductName", stocks.ProductId);
            ViewData["StoreId"]   = new SelectList(_context.Stores, "StoreId", "StoreName", stocks.StoreId);
            return(View(stocks));
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("ProductId,ProductName,BrandId,CategoryId,ModelYear,ListPrice")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandId"]    = new SelectList(_context.Brands, "BrandId", "BrandName", product.BrandId);
            ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryName", product.CategoryId);
            return(View(product));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("OrderId,CustomerId,OrderStatus,OrderDate,RequiredDate,ShippedDate,StoreId,StaffId")] Orders orders)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orders);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "Email", orders.CustomerId);
            ViewData["StaffId"]    = new SelectList(_context.Staffs, "StaffId", "Email", orders.StaffId);
            ViewData["StoreId"]    = new SelectList(_context.Stores, "StoreId", "StoreName", orders.StoreId);
            return(View(orders));
        }
コード例 #8
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var customer = await bikeStoresContext.Customers.FindAsync(request.Id);

                if (customer == null)
                {
                    throw new Exception("no customer found to delete");
                }

                bikeStoresContext.Remove(customer);
                var sucess = await bikeStoresContext.SaveChangesAsync() > 0;

                if (sucess)
                {
                    return(Unit.Value);
                }

                throw new Exception("unable to save changes");
            }
コード例 #9
0
        public async Task <ActionResult> Post(IFormFile image, string email)
        {
            // Validar si el usuario existe en la BD modificar su imagen
            // si no existe, crear usuario

            UsuariosTruchos usuario = new UsuariosTruchos
            {
                email = email
            };

            using (var memoryStream = new MemoryStream())
            {
                await image.CopyToAsync(memoryStream);

                usuario.imagen = memoryStream.ToArray();
            }
            await context.UsuariosTruchos.AddAsync(usuario);

            await context.SaveChangesAsync();

            return(Ok(usuario));
        }
コード例 #10
0
 public virtual async Task SaveChangesAsync()
 {
     await _dataContext.SaveChangesAsync();
 }