public List <book_order> Mapping(List <BookOrderModel> list) { try { if (list != null && list.Count > 0) { List <book_order> boList = new List <book_order>(); foreach (BookOrderModel b in list) { book_order bookOrder = new book_order(); bookOrder.book_order_id = b.book_order_id; bookOrder.book_order_date = b.book_order_date; bookOrder.book_order_total = b.book_order_total; bookOrder.book_status_code = "WP"; bookOrder.cus_id = 3; boList.Add(bookOrder); } return(boList); } return(null); } catch (Exception ex) { throw ex; } }
public int AddBookOrder(BookOrderModel bs) { try { if (bs != null) { if (GetOrder().Where(obj => obj.book_order_id == bs.book_order_id).ToList().Count == 0) { book_order brDb = new book_order(); brDb.cus_id = bs.cus_id; brDb.book_status_code = bs.book_status_code; brDb.book_order_total = bs.book_order_total; brDb.book_order_date = DateTime.Today; db.book_order.Add(brDb); db.SaveChanges(); return(brDb.book_order_id); } return(0); } return(0); } catch (Exception ex) { throw ex; } }
protected void btn_confirm_order_Click(object sender, EventArgs e) { try { UserManager <ApplicationUser> usermanager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext())); ApplicationUser current_user = usermanager.FindById(User.Identity.GetUserId()); current_user.Email = txt_email.Text; usermanager.Update(current_user); UserInfo info = db.getUserInfo(Int32.Parse(Session["editInfoID"].ToString())); info.first_name = txt_first_name.Text; info.last_name = txt_last_name.Text; info.company = txt_company.Text; info.tel = txt_tel.Text; info.fax = txt_fax.Text; info.country = drop_country.SelectedValue; info.city = txt_city.Text; info.post = txt_post.Text; info.address_1 = txt_add1.Text; info.address_2 = txt_add2.Text; db.saveUserInfo(info); book_order order = new book_order(); order.user_id = User.Identity.GetUserId(); order.order_time = DateTime.Now; order.first_name = txt_first_name.Text; order.last_name = txt_last_name.Text; order.company = txt_company.Text; order.tel = txt_tel.Text; order.fax = txt_fax.Text; order.country = drop_country.SelectedValue; order.city = txt_city.Text; order.post = txt_post.Text; order.address_1 = txt_add1.Text; order.address_2 = txt_add2.Text; db.checkoutCart(current_user.Id, order); Response.Redirect("/message.aspx?msg=" + "Your order is now in process."); } catch (Exception ex) { Response.Redirect("/message.aspx?msg=" + ex.ToString()); } }
/* * public int AddBookOrder(BookOrderModel bookOrder) * { * try * { * book_order bc = Mapping(bookOrder); * db.book_order.Add(bc); * db.SaveChanges(); * return bc.book_order_id; * * } * catch (Exception ex) * { * throw ex; * } * } */ public bool AddBookOrder(BookOrderModel bookOrder, List <BookOrderDetailModel> bookDetail) { try { book_order bc = Mapping(bookOrder); db.book_order.Add(bc); db.SaveChanges(); int id = bc.book_order_id; AddOrderDetail(id, bookDetail); return(true); } catch (Exception ex) { throw ex; } }
public void checkoutCart(string user_id, book_order book_order) { db.book_order.Add(book_order); db.SaveChanges(); int order_id = book_order.auto_id; List <Cart> listCart = db.Carts.Where(c => c.user_id == user_id).ToList <Cart>(); for (int i = 0; i < listCart.Count; i++) { order_detail detail = new order_detail(); detail.order_id = order_id; detail.book_id = listCart[i].book_id; db.order_detail.Add(detail); db.SaveChanges(); listCart[i].status = false; updateCart(listCart[i]); } }
public book_order Mapping(BookOrderModel bs) { try { book_order bsm = new book_order(); if (bs != null) { bsm.book_order_id = bs.book_order_id; bsm.cus_id = bs.cus_id; bsm.book_status_code = bs.book_status_code; bsm.book_order_total = bs.book_order_total; bsm.book_order_date = bs.book_order_date; return(bsm); } return(null); } catch (Exception ex) { throw ex; } }
public book_order Mapping(BookOrderModel o) { try { if (o != null) { book_order bookOrder = new book_order(); bookOrder.book_order_id = o.book_order_id; bookOrder.book_order_date = o.book_order_date; bookOrder.book_order_total = o.book_order_total; bookOrder.book_status_code = "WP"; bookOrder.cus_id = 3; return(bookOrder); } return(null); } catch (Exception ex) { throw ex; } }
public BookOrderModel Mapping(book_order o) { try { if (o != null) { BookOrderModel bookOrder = new BookOrderModel(); bookOrder.book_order_id = o.book_order_id; bookOrder.cus_id = o.cus_id; bookOrder.book_status_code = o.book_status_code; bookOrder.book_order_total = o.book_order_total; bookOrder.book_order_date = o.book_order_date; return(bookOrder); } return(null); } catch (Exception ex) { throw ex; } }