public ActionResult Create([Bind(Include = "BookID,BookName,BookIntroduction,BookPrice,BookCoverImage,Bookauthor,BookPublisher,YearReleased,BookForm,BookLanguage,BookAddedDate,BookModifiedDate")] BookInformationModel bookInformationModel) { if (ModelState.IsValid) { db.BookInformation.Add(bookInformationModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bookInformationModel)); }
public ActionResult Create([Bind(Include = "CategoryID,CategoryName")] BookCategoriesModel bookCategoriesModel) { if (ModelState.IsValid) { db.BookCategories.Add(bookCategoriesModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bookCategoriesModel)); }
public ActionResult Register(cast_RegisterCustomerModel user) { if (CustomerDAO.IsNullCutomer(user.Email)) { using (var db = new BookeeDb()) { CustomerModel customer = new CustomerModel(); customer.Email = user.Email; customer.isActive = true; customer.CreatedDate = DateTime.Now; customer.LastDateModified = null; db.Customers.Add(entity: customer); db.SaveChanges(); } user.Password = CustomerDAO.encryptPassword(user.Password); Boolean result = CustomerDAO.InsertOnMock(user); if (result) { ViewBag.resultMessage = "Đăng ký thành công"; } else { ViewBag.resultMessage = "Đăng ký thất bại"; } } else { ViewBag.resultMessage = "Email đã đăng ký"; } ModelState.Clear(); return(View()); }
public ActionResult Order() { using (var db = new BookeeDb()) { int userID = Convert.ToInt32(Session["ID"].ToString()); OrdersModel order = new OrdersModel(); order.OrderID = Guid.NewGuid().ToString(); order.OrderDate = DateTime.Now; order.OrderStatus = "process"; order.CustomerID = db.Customers.FirstOrDefault(user => user.CustomerID == userID); order.BookID = db.BookInformation.FirstOrDefault(book => book.BookID == StaticVariable.Book_ID); order.TotalPrice = db.BookInformation.FirstOrDefault(book => book.BookID == StaticVariable.Book_ID).BookPrice; db.Orders.Add(entity: order); db.SaveChanges(); } return(RedirectToAction("Index", "Bookee")); }
public ActionResult Register([Bind(Include = "FirstName, LastName, Email, Password")] cast_RegisterCustomerModel user) { if (!ModelState.IsValid) { return(RedirectToAction("Login")); } if (CustomerDAO.IsNullCutomer(user.Email)) { using (var db = new BookeeDb()) { CustomerModel customer = new CustomerModel(); customer.Email = user.Email; customer.isActive = true; customer.CreatedDate = DateTime.Now; customer.LastDateModified = null; db.Customers.Add(entity: customer); db.SaveChanges(); } user.Password = CustomerDAO.encryptPassword(user.Password); Boolean result = CustomerDAO.InsertOnMock(user); if (result) { ViewBag.message = "Đăng ký thành công"; return(RedirectToAction("Index")); } else { ViewBag.message = "Đăng ký thất bại"; } return(RedirectToAction("Login")); } else { ViewBag.message = "Email đã đăng ký"; ModelState.Clear(); return(RedirectToAction("Register")); } }