示例#1
0
        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));
        }
示例#2
0
        public ActionResult Create([Bind(Include = "CategoryID,CategoryName")] BookCategoriesModel bookCategoriesModel)
        {
            if (ModelState.IsValid)
            {
                db.BookCategories.Add(bookCategoriesModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bookCategoriesModel));
        }
示例#3
0
 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());
 }
示例#4
0
 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"));
 }
示例#5
0
        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"));
            }
        }