// GET: Invoices/Details/5 public ActionResult Details(int id) { List <DataPoint> dataPoints = new List <DataPoint>(); BillDetails res = CallApi.Get(Request.Cookies["jwt"], "bills/details", id.ToString()).Content.ReadAsAsync <BillDetails>().Result; Dictionary <string, double> keyValuePairs = new Dictionary <string, double>(); foreach (ProductDetails productDetails in res.ProductDetails) { foreach (WasteDiscount productWaste in productDetails.WasteDiscounts) { if (!keyValuePairs.ContainsKey(productWaste.Waste.Name)) { keyValuePairs.Add(productWaste.Waste.Name, productWaste.DiscountedAmount * productWaste.Waste.RecyclingPrice); } else { keyValuePairs[productWaste.Waste.Name] += productWaste.DiscountedAmount * productWaste.Waste.RecyclingPrice; } } } foreach (var x in keyValuePairs) { dataPoints.Add(new DataPoint(x.Key, x.Value)); } ViewBag.DataPoints = JsonConvert.SerializeObject(dataPoints); return(View(res)); }
// GET: Employee/Edit/5 public ActionResult EditCardWaste(int id) { var cookie = HttpContext.Request.Cookies["jwt"]; CardWaste cw = CallApi.Get(cookie, "CardWastes", id.ToString()).Content.ReadAsAsync <CardWaste>().Result; return(View(cw)); }
// GET: Employee public ActionResult Index() { var response = CallApi.Get(Request.Cookies["jwt"], "Cards"); IEnumerable <Card> result = response.Content.ReadAsAsync <IEnumerable <Card> >().Result; return(View(result)); }
// GET: Wastes/Delete/5 public ActionResult Delete(int id) { var cookie = HttpContext.Request.Cookies["jwt"]; Waste waste = CallApi.Get(cookie, "Wastes", id.ToString()).Content.ReadAsAsync <Waste>().Result; return(View(waste)); }
// GET: Products public ActionResult Index() { var response = CallApi.Get(Request.Cookies["jwt"], "Products"); var readTask = response.Content.ReadAsAsync <IList <Product> >(); readTask.Wait(); return(View(readTask.Result)); }
// GET: Employee/Edit/5 public ActionResult Edit(int id) { var cookie = HttpContext.Request.Cookies["jwt"]; CardCardWastes cardCardWastes = new CardCardWastes(); cardCardWastes.Card = CallApi.Get(cookie, "Cards", id.ToString()).Content.ReadAsAsync <Card>().Result; cardCardWastes.CardWastes = CallApi.Get(cookie, "CardWastes/CardId", id.ToString()).Content.ReadAsAsync <List <CardWaste> >().Result; return(View(cardCardWastes)); }
public ActionResult CreateBillProduct(int billId) { BillProductProducts billProductProducts = new BillProductProducts(); billProductProducts.products = CallApi.Get(Request.Cookies["jwt"], "products").Content.ReadAsAsync <List <Product> >().Result; billProductProducts.billProduct = new BillProduct() { BillId = billId, Product = new Product() }; return(View(billProductProducts)); }
// GET: Products/Edit/5 public ActionResult Edit(int id) { var token = Request.Cookies["jwt"]; ProductProductWastes productProductWastes = new ProductProductWastes(); productProductWastes.Product = CallApi.Get(token, "products", id.ToString()).Content.ReadAsAsync <Product>().Result; var response = CallApi.Get(token, "ProductWastes/product", id.ToString()).Content; if (response != null) { productProductWastes.productWastes = CallApi.Get(token, "ProductWastes/product", id.ToString()).Content.ReadAsAsync <List <ProductWaste> >().Result; } return(View(productProductWastes)); }
public IActionResult Index() { var cookie = HttpContext.Request.Cookies["jwt"]; if (cookie == null) { return(RedirectToAction("LogOut")); } var response = CallApi.Get(cookie, "Account/verify"); if (cookie != null && response.IsSuccessStatusCode) { var content = response.Content.ReadAsAsync <Card>(); CallApi.Role = content.Result.IsAdmin ? CallApi.Roles.admin : CallApi.Roles.user; CallApi.Email = content.Result.Email; CallApi.CardNumber = content.Result.CardId; CallApi.Balance = content.Result.Balance; CallApi.Name = content.Result.CardOwnerName; return(View()); } return(RedirectToAction("LogOut")); }
// GET: Invoices public ActionResult Index() { return(View(CallApi.Get(Request.Cookies["jwt"], "bills").Content.ReadAsAsync <IEnumerable <Bill> >().Result)); }
//// POST: Invoices/Create //[HttpPost] //[ValidateAntiForgeryToken] //public async Task<ActionResult> Create(InvoiceAndThirdparties collection) //{ // try // { // Invoice inv = collection.Invoice; // inv.Employee = new Employee(); // inv.Employee.Username = CallApi.Email; // await CallApi.PostAsync(Request.Cookies["jwt"], "Invoices", collection.Invoice); // // TODO: Add insert logic here // return RedirectToAction(nameof(Index)); // } // catch // { // return View(); // } //} // GET: Invoices/Delete/5 public ActionResult Delete(int id) { return(View(CallApi.Get(Request.Cookies["jwt"], "bills", id.ToString()).Content.ReadAsAsync <Bill>().Result)); }
// GET: Products/Delete/5 public ActionResult Delete(int id) { var token = Request.Cookies["jwt"]; return(View(CallApi.Get(token, "products", id.ToString()).Content.ReadAsAsync <Product>().Result)); }
// GET: Employee/Delete/5 public ActionResult Delete(int id) { Card card = CallApi.Get(Request.Cookies["jwt"], "cards", id.ToString()).Content.ReadAsAsync <Card>().Result; return(View(card)); }