public ActionResult Order() { var orderList = OrderREST.GetAllOrders(); var productList = ProductREST.GetAllProducts(); var userList = UserREST.GetAllUsers(); var OrderResultList = ( from order in orderList join product in productList on order.ProductID equals product.ProductID join user in userList on order.UserID equals user.Email where order.ProductID == product.ProductID where order.UserID == user.Email select new OrderResult { orderId = order.OrderID, quantity = order.OrderQuantity, image = order.OrderImage, productName = product.ProductName, customerName = user.FirstName + user.LastName, phoneNumber = user.PhoneNumber }).ToList(); ViewBag.orders = OrderResultList; return(View()); }
public ActionResult Pricing() { var products = ProductREST.GetAllProducts(); if (products.Count() == 0) { ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } return(View(products.ToList())); }
public async Task <ActionResult <ProductREST> > PostProduct(ProductREST productREST) { var productModel = Mapper.Map <Product>(productREST); var success = await ProductService.CreateAsync(productModel); if (!success) { return(StatusCode(500)); } return(Ok(success)); }
public async Task <ActionResult <bool> > PutProduct(Guid id, ProductREST productREST) { if (id != productREST.Id) { return(BadRequest()); } var productModel = Mapper.Map <Product>(productREST); bool success = await ProductService.UpdateAsync(id, productModel); if (!success) { return(NoContent()); } return(Ok(success)); }
public ActionResult CreateProduct(ProductViewModel productViewModel) { var product = new Product { ProductName = productViewModel.ProductName, Price = productViewModel.Price }; var result = ProductREST.Post(product); if (result.IsSuccessStatusCode) { return(RedirectToAction("Products", "Product")); } Debug.Print(result.ReasonPhrase); ModelState.AddModelError(string.Empty, "Sorry, something went wrong."); return(View()); }
public ActionResult createOrder() { if (!OnlinePrintingService.Helper.Cookiez.isUserLoggedIn(Request)) { return(RedirectToAction("Login", "AppUser")); } var model = new OrdersViewModel(); var productList = ProductREST.GetAllProducts(); SelectList list = new SelectList(productList, "ProductID", "ProductName"); ViewBag.drplist = list; var productNameListItems = productList.Select(p => new SelectListItem { Text = p.ProductID.ToString(), Value = p.ProductName, }); model.ProductName = productNameListItems; return(View()); }
public ActionResult DeleteProduct(long ProductID) { ProductREST.Delete(ProductID); return(RedirectToAction("Products", "Product")); }