public List<DBModel.OrderLine> VisSpesifikOrdre(int id, string email) { var handlevogn = new List<DBModel.OrderLine>(); if (id == 0 || email == null) { var ol = new DBModel.OrderLine() { Ordernumber = 0, }; handlevogn.Add(ol); handlevogn.Add(ol); handlevogn.Add(ol); return handlevogn; } var vare = new DBModel.OrderLine() { Priceperunit = 100, Quantity = 1, Productid = 1, Ordernumber = id, Product = new DBModel.Product() { Title = "TestVare" }, Order = new DBModel.Order() { status = "teststatus", statusDato = DateTime.Today, } }; handlevogn.Add(vare); handlevogn.Add(vare); handlevogn.Add(vare); return handlevogn; }
public List<DBModel.OrderLine> visHandlevogn(string email) { var handlevogn = new List<DBModel.OrderLine>(); if (email == null) { var ol = new DBModel.OrderLine() { Ordernumber = 0, }; handlevogn.Add(ol); handlevogn.Add(ol); handlevogn.Add(ol); return handlevogn; } var vare = new DBModel.OrderLine() { Priceperunit = 100, Quantity = 1, Productid = 1, Ordernumber = 1, Product = new DBModel.Product() { Title = "TestVare" } }; handlevogn.Add(vare); handlevogn.Add(vare); handlevogn.Add(vare); return handlevogn; }
public List<DBModel.OrderLine> VisSpesifikOrdre(int id, string email) { try { if (id == 0 || email == null || email == "") return null; var handlevogn = new List<DBModel.OrderLine>(); var user = db.Users.FirstOrDefault(u => u.Email == email); if (user == null) { return null; } var orders = user.Orders; if (orders == null) { return null; } foreach (var order in orders) { if (order.Ordernumber == id) { foreach (var item in order.Orderlines) { var vare = new DBModel.OrderLine(); vare.Priceperunit = item.Priceperunit; vare.Quantity = item.Quantity; vare.Ordernumber = item.Ordernumber; vare.Productid = item.Productid; vare.Product.Title = item.Product.Title; vare.Order.status = item.Order.status; vare.Order.statusDato = item.Order.statusDato; handlevogn.Add(vare); } return handlevogn; } } return null; } catch (System.Data.SqlClient.SqlException ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (InvalidOperationException ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (ArgumentException ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (NullReferenceException ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (SystemException ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (Exception ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } return null; }
public List<DBModel.Order> hentOrdre(string status) { try { if (status == null || status == "") { return null; } var liste = new List<DBModel.Order>(); var ordre = db.Orders.Where(u => u.status == status); if (ordre != null) { foreach (var item in ordre) { var o = new DBModel.Order(); o.dato = item.dato; o.Confirmed = item.Confirmed; o.Email = item.Email; o.Ordernumber = item.Ordernumber; o.status = item.status; o.statusDato = item.statusDato; o.Orderlines = new List<DBModel.OrderLine>(); liste.Add(o); } } var prodliste = new List<DBModel.OrderLine>(); foreach (var item in liste) { var orderline = db.Orderlines.Where(u => u.Ordernumber == item.Ordernumber); foreach (var prod in orderline) { var ol = new DBModel.OrderLine(); ol.Ordernumber = prod.Ordernumber; ol.Priceperunit = prod.Priceperunit; ol.Productid = prod.Productid; ol.Quantity = prod.Quantity; ol.Order = new DBModel.Order() { statusDato = prod.Order.statusDato, status = prod.Order.status, }; prodliste.Add(ol); } item.Orderlines = prodliste; } return liste; } catch (System.Data.SqlClient.SqlException ex) { SWKP.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKP.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (InvalidOperationException ex) { SWKP.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKP.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (ArgumentException ex) { SWKP.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKP.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (NullReferenceException ex) { SWKP.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKP.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (SystemException ex) { SWKP.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKP.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (Exception ex) { SWKP.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKP.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } return null; }
public List<DBModel.OrderLine> visHandlevogn(string email) { try { if (email == null || email == "") return null; var handlevogn = new List<DBModel.OrderLine>(); var user = db.Users.FirstOrDefault(u => u.Email == email); if (user == null) { return null; } var ordre = user.Orders; if (ordre == null) { return null; } foreach (var item in ordre) { if (item.Confirmed == false) { foreach (var t in item.Orderlines) { var vare = new DBModel.OrderLine(); vare.Priceperunit = t.Priceperunit; vare.Quantity = t.Quantity; vare.Productid = t.Productid; vare.Product.Title = t.Product.Title; handlevogn.Add(vare); } return handlevogn; } } //Trenger vi denne ???? var handlevognliste = from produkt in db.Orderlines where produkt.Order.Confirmed == false && produkt.Order.Email == user.Email select produkt; } catch (System.Data.SqlClient.SqlException ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (InvalidOperationException ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (ArgumentException ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (NullReferenceException ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (SystemException ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } catch (Exception ex) { SWKR.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); SWKR.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } return null; }