public async Task <ActionResult> Create(RSStock rSStock) { if (ModelState.IsValid) { db.Stocks.Add(rSStock); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(rSStock)); }
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); }
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)); }
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"); } }
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"); } }
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"); } }