Ejemplo n.º 1
0
        public async Task <ActionResult> Create(RSStock rSStock)
        {
            if (ModelState.IsValid)
            {
                db.Stocks.Add(rSStock);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(rSStock));
        }
Ejemplo n.º 2
0
        public async Task <bool> SetOrderItemState(int id, [FromBody] int state)
        {
            RSOrderItem oi = await db.OrderItems.FindAsync(id);

            if (oi != null)
            {
                if (oi.State < 2)
                {
                    oi.State = state;
                    await db.SaveChangesAsync();

                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Edit(RSUser user, string newpassword, string confirmpassword)
        {
            if (ModelState.IsValid)
            {
                db.Entry(user).State = EntityState.Modified;
                if (!string.IsNullOrWhiteSpace(newpassword) & newpassword == confirmpassword)
                {
                    user.DependencyInjection();
                    user.CreatePassword(newpassword);
                }

                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(user));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> AddProduct(int id, int productId)
        {
            RSProduct product = await db.Products.FindAsync(productId);

            RSOrder order = await db.Orders.FindAsync(id);

            if (product != null && order != null)
            {
                RSOrderItem orderItem = new RSOrderItem(product, order);

                db.OrderItems.Add(orderItem);
                await db.SaveChangesAsync();

                return(Json(true));
            }
            else
            {
                throw new HttpException(400, "Error inserting OrderItem");
            }
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> AddStock(int id, int stockId, double amount)
        {
            RSStock stock = await db.Stocks.FindAsync(stockId);

            RSProduct product = await db.Products.FindAsync(id);

            if (stock != null && product != null)
            {
                RSStockItem stockItem = new RSStockItem();
                stockItem.Amount  = amount;
                stockItem.Stock   = stock;
                stockItem.Product = product;

                db.StockItems.Add(stockItem);
                await db.SaveChangesAsync();

                return(Json(true));
            }
            else
            {
                throw new HttpException(400, "Error inserting item");
            }
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> AddChild(int id, int childId)
        {
            RSNavigationItem child = await db.Navigation.FindAsync(childId);

            RSNavigationItem navigationItem = await db.Navigation.FindAsync(id);

            if (child != null && navigationItem != null)
            {
                navigationItem.Children.Add(child);
                await db.SaveChangesAsync();

                return(Json(true));
            }
            else
            {
                throw new HttpException(400, "Error inserting item");
            }
        }