internal int ThemHopDong(HopDongNcc hopDong) { //hopDong.Id = TaoMa(); hopDong.TinhTrang = true; hopDong.TTThanhToan = true; db.HopDongNccs.Add(hopDong); db.SaveChanges(); var sendmail = new EmailTool(); sendmail.SendMail(GetParent(hopDong.Id)); return(hopDong.Id); }
public ActionResult PaypalPaymanet() { var s = PdtHolder.Success(Request.QueryString.Get("tx")); //khởi tạo biến order var order = new Order(); var username = Session["UsernameMember"]; if (username != null) { var model = new UserDAO().findByUsername(username.ToString()); order.UserID = model.ID; } order.ShipCreateDate = DateTime.Now; order.ShipName = s.AddressName; order.ShipAddress = s.AddressState + "-" + s.AddressCountry + "-" + s.AddressStreet; order.ShipEmail = s.PayerEmail; order.Status = 0; order.PaymentID = 1; //insert order var id = new OrderDAO().Create(order);//trả về id của order try { var cart = (List <CartItem>)Session[CartSession]; var db = new OrderDetailDAO(); foreach (var item in cart) { var orderDetail = new OrderDetail(); orderDetail.ProductID = item.ProductModel.ID; orderDetail.OrderID = id; if (item.ProductModel.Sale != null) { orderDetail.Price = item.ProductModel.Sale; } else { orderDetail.Price = item.ProductModel.Price; } orderDetail.Quantity = item.Quantity; db.Create(orderDetail); Session[CartSession] = null; } EmailTool emailTool = new EmailTool(); emailTool.SendMail(GetParent(id)); } catch (Exception) { throw; } return(RedirectToAction("Success", "Cart"));//chuyển hướng đến hành động được chỉ định thay vì hiển thị HTML }
public ActionResult PaymentUserLogin() { var username = Session["Member"];//lấy session gáng giá trị vào order var model = new UserDAO().FindUserName(username.ToString()); var order = new Order(); order.ShipCreateDate = DateTime.Now; order.ShipName = model.Name; order.ShipAddress = model.Address; order.ShipEmail = model.Email; order.ShipPhone = model.Phone; order.Status = 0; order.UserID = model.ID; //insert order var id = new OrderDAO().Create(order);//trả về id của order try { var cart = (List <CartItem>)Session[CartSession]; var db = new OrderDetailDAO(); decimal total = 0; foreach (var item in cart) { decimal price = (decimal)item.ProductModel.Price; var orderDetail = new OrderDetail(); orderDetail.ProductID = item.ProductModel.ID; orderDetail.OrderID = id; if (item.ProductModel.Sale.HasValue) { price = price - (decimal)(item.ProductModel.Sale * price / 100); } orderDetail.Price = price; orderDetail.Quantity = item.Quantity; orderDetail.SubPrice = item.Quantity * price; total += (decimal)orderDetail.SubPrice; db.Create(orderDetail); Session[CartSession] = null; } new OrderDAO().EditTotal(total, id); EmailTool emailTool = new EmailTool(); emailTool.SendMail(GetParent(id)); } catch (Exception) { throw; } return(RedirectToAction("Success", "Cart")); }
public ActionResult PaymentUserLogin() { var username = Session["UsernameMember"];//lấy session gáng giá trị vào order var model = new UserDAO().findByUsername(username.ToString()); var order = new Order(); order.ShipCreateDate = DateTime.Now; order.ShipName = model.Name; order.ShipAddress = model.Address; order.ShipEmail = model.Email; order.ShipPhone = model.Phone; order.Status = 0; order.PaymentID = 2; order.UserID = model.ID; //insert order var id = new OrderDAO().Create(order);//trả về id của order try { var cart = (List <CartItem>)Session[CartSession]; var db = new OrderDetailDAO(); foreach (var item in cart) { var orderDetail = new OrderDetail(); orderDetail.ProductID = item.ProductModel.ID; orderDetail.OrderID = id; if (item.ProductModel.Sale != null) { orderDetail.Price = item.ProductModel.Sale; } else { orderDetail.Price = item.ProductModel.Price; } orderDetail.Quantity = item.Quantity; db.Create(orderDetail); Session[CartSession] = null; } EmailTool emailTool = new EmailTool(); emailTool.SendMail(GetParent(id)); } catch (Exception) { throw; } return(RedirectToAction("Success", "Cart")); }
public ActionResult Payment(string shipName, string shipPhone, string shipAddress, string shipEmail) { var order = new Order(); order.ShipCreateDate = DateTime.Now; order.ShipName = shipName; order.ShipAddress = shipAddress; order.ShipEmail = shipEmail; order.ShipPhone = shipPhone; order.Status = 0; order.PaymentID = 2; //insert order var id = new OrderDAO().Create(order);//trả về id của order try { var cart = (List <CartItem>)Session[CartSession]; var db = new OrderDetailDAO(); foreach (var item in cart) { var orderDetail = new OrderDetail(); orderDetail.ProductID = item.ProductModel.ID; orderDetail.OrderID = id; if (item.ProductModel.Sale != null) { orderDetail.Price = item.ProductModel.Sale; } else { orderDetail.Price = item.ProductModel.Price; } orderDetail.Quantity = item.Quantity; db.Create(orderDetail); Session[CartSession] = null; } EmailTool emailTool = new EmailTool(); emailTool.SendMail(GetParent(id)); } catch (Exception) { throw; } return(RedirectToAction("Success", "Cart")); }
public ActionResult ForgotPassword(string email) { if (ModelState.IsValid) { var check = new UserDAO().find(email); if (check != null) { var newpass = new UserDAO().CreatePassword(8); var creat = new UserDAO().UpdatePass(email, Encryptor.Encrypt(newpass)); if (creat) { EmailTool emailTool = new EmailTool(); emailTool.SendMail(GetParent(email, newpass)); ModelState.AddModelError("", "Đã gửi một email chứa mật khẩu tới tài khoản của bạn!"); return(View()); } } } return(View()); }
public ActionResult ForgotPassword(string email) { if (ModelState.IsValid) { var check = new UserDAO().find(email); if (check != null) { var newpass = new UserDAO().CreatePassword(10); var creat = new UserDAO().UpdatePass(email, Encryptor.Encrypt(newpass)); if (creat) { EmailTool emailTool = new EmailTool(); emailTool.SendMail(GetParent(email, newpass)); TempData["Success"] = "Đã lấy lại mật khẩu thành công ,chung tôi đã gửi một email chứa mật khẩu tới tài khoản của bạn!"; return(View()); } } } TempData["Error"] = "Lấy lại mật khẩu không thành công!"; return(View()); }