// GET: TempCustomerOrder public ActionResult Index(int Id) { var currentOrder = _repo.ReadInOrder(Id).ToList(); List <TempCustomerOrder> CurOrd = new List <TempCustomerOrder>(); foreach (var Cx in CurOrd) { TempCustomerOrder CxOrd = new TempCustomerOrder(); CxOrd.PizzaId = Cx.PizzaId; CxOrd.Price = Cx.Price; CxOrd.Toppings = Cx.Toppings; CxOrd.CustId = Cx.CustId; CxOrd.Crust = Cx.Crust; CxOrd.Size = Cx.Size; CurOrd.Add(Cx); } //[Key] ////[Column(Order=1)] //public int CustId { get; set; } //public int Toppings { get; set; } //public string Crust { get; set; } //public decimal Price { get; set; } //public int Size { get; set; } //public int StoreId { get; set; } return(View(CurOrd)); }
// Creates Order public IActionResult Create() { List <TempCustomerOrder> TCO = new List <TempCustomerOrder>(); var fulOrder = _tco.ReadInOrder(FullOrder.UserID).ToList(); decimal Tot = 0; foreach (var ord in fulOrder) { TempCustomerOrder tco = new TempCustomerOrder(); tco.Crust = ord.Crust; tco.Price = ord.Price; tco.PizzaId = ord.PizzaId; Tot += ord.Price; tco.Size = ord.Size; TCO.Add(tco); } ViewBag.total = Tot; return(View(TCO)); }
public ResponseModel UploadCustomerOrder(System.Web.HttpRequest httpRequest, string rootPath) { ResponseModel res = new ResponseModel(); try { if (httpRequest.Files.Count > 0) { foreach (string file in httpRequest.Files) { HttpPostedFile fileUploaded = httpRequest.Files[file]; string fileName = UtilityHelper.SaveUploadedFile(fileUploaded, rootPath); string filePath = Path.Combine(rootPath, fileName); if (fileName != "") { using (var reader = new StreamReader(filePath)) using (var csv = new CsvReader(reader)) { int rowCnt = 0; var record = new CustomerOrderModel(); var records = csv.EnumerateRecords(record); using (CustomerDBEntities db = new CustomerDBEntities()) { FileStorageInfo fileInfo = new FileStorageInfo(); fileInfo.FileUploadId = Guid.NewGuid(); fileInfo.OriginalFileName = fileUploaded.FileName; fileInfo.StoredFileName = fileName; fileInfo.CreatedDate = DateTime.Now; db.FileStorageInfoes.Add(fileInfo); db.SaveChanges(); foreach (var r in records) { TempCustomerOrder tmpOrder = new TempCustomerOrder(); tmpOrder.ID = Guid.NewGuid(); tmpOrder.order_number = r.order_number; tmpOrder.qty = r.qty; tmpOrder.user_id = r.user_id; tmpOrder.FileUploadedId = fileInfo.FileUploadId; tmpOrder.CreatedDate = DateTime.Now; tmpOrder.IsAddedToMainTbl = false; db.TempCustomerOrders.Add(tmpOrder); db.SaveChanges(); rowCnt++; } } if (rowCnt > 0) { //Upsert Customer Order Data from Staginig table to Main Table res = UpsertOrderData(); if (res.status) { res.status = true; res.message = "File Upload Completed Successfully...!!!"; res.data = GetAllCustomerOrders(); } return(res); } else { res.message = "No/Invalid Data in File...!!!"; return(res); } } } } } return(res); } catch (Exception ex) { if (ex.Source == "CsvHelper") { res.message = "Invalid File Data...!!!"; } else { res.message = ex.Message; } res.data = ex.InnerException; return(res); } }
public IActionResult CreateNewPizza(TempCustomerOrder tmp, bool Sauce, bool Sausage, bool Pepperoni, bool Cheese, bool Pineapple, int Size, int Crust, int number) { if (Size > 100) { return(View()); } //int size = tmp.Size; //string crust = tmp.Crust; //bool sauce = tmp.sauce; //bool cheese = tmp.cheese; //bool pepperoni = tmp.pepperoni; //bool sausage = tmp.sausage; for (int i = 0; i < number; i++) { char[] tops = new char[5]; if (Sauce) { tops[0] = '1'; } else { tops[0] = '0'; } if (Cheese) { tops[1] = '1'; } else { tops[1] = '0'; } if (Pepperoni) { tops[2] = '1'; } else { tops[2] = '0'; } if (Sausage) { tops[3] = '1'; } else { tops[3] = '0'; } if (Pineapple) { tops[4] = '1'; } else { tops[4] = '0'; } // add pizza cypher to format code into database model PizzaOrderCypher POC = new PizzaOrderCypher(); POC.setCrust(Crust); POC.setSize(Size); POC.setToppings(tops); POC.getPriceOfPizza(); // Add Full Order to POC current Customer order. ViewBag.id = tmp.PizzaId + 1; FullOrder.storeID = CustomerInfo.StoreId; FullOrder.UserID = CustomerInfo.Id; FullOrder.currOrder.Add(POC); TempCustomerOrder1 TCO = new TempCustomerOrder1(); TCO.Toppings = BitFlagConversion.convertFlagArrayToInt(tops); TCO.Size = POC.size; TCO.Crust = POC.crust; TCO.CustId = CustomerInfo.Id; TCO.StoreId = CustomerInfo.StoreId; TCO.PizzaId = new Random().Next(10000000, 100000000); TCO.Price = POC.price; _repo_tmp.CreateOrder(TCO); } return(View()); }