Ejemplo n.º 1
0
        public ActionResult Login(string Mail, string Pass)
        {
            string page     = "";
            var    customer = CustomerAction.Find_Customer(Mail, Pass);

            if (customer != null)
            {
                ViewBag.ID = customer.id_customer;
                if (customer.password == Pass && (customer.role.Equals("admin") || customer.role.Equals("staff")) || customer.id_customer == 1)
                {
                    page            = "~/Customer/Index";
                    Session["id"]   = customer.id_customer;
                    Session["role"] = customer.role;
                    Session.Timeout = 24;
                }
                else if (customer.password == Pass && customer.role.Equals("guest"))
                {
                    page            = "~/Book/ShowBook";
                    Session["id"]   = customer.id_customer;
                    Session["role"] = customer.role;
                    Session.Timeout = 24;
                }
            }
            else if (customer == null)
            {
                page = "~/Book/ShowBook";
            }

            return(Redirect(page));
        }
 /* Set Role For User*/
 public JsonResult CreateStaff(int Id, string Role)
 {
     CustomerAction.Create_Staff(Id, Role);
     //return Redirect("~/Customer/Index/" + Session["id"]);
     RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " update role " + Role + "  for account " + CustomerAction.Find_Customer(Id).email, DateTime.Now.Date);
     return(Json(JsonRequestBehavior.AllowGet));
 }
 public ActionResult EditCustomer(int Id, string Email, string Password, string First_name, string Last_name, string Address,
                                  string Phone, string Date_Birth, string Gender)
 {
     ViewBag.ID = Id;
     CustomerAction.Edit_Customer(Id, Email, First_name, Last_name, Password, Phone, Date_Birth, Gender, Address);
     RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " update infomation.", DateTime.Now.Date);
     return(Redirect("~/Customer/Index/" + Session["id"]));
 }
 /* RESTORE CUSTOMERS WERE DELETED */
 public ActionResult UnLockCustomer(int Id)
 {
     if (Id != 0)
     {
         CustomerAction.UnLock(Id);
         RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " unlock account " + CustomerAction.Find_Customer(Id).email, DateTime.Now.Date);
         return(Redirect("~/Home/RestoreData"));
     }
     return(Redirect("~/Customer/Index/"));
 }
 /* DELETE CUSTOMER */
 public ActionResult DeleteCustomer(int Id)
 {
     if (Id != 0)
     {
         CustomerAction.Delete_Customer(Id);
         RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " lock account " + CustomerAction.Find_Customer(Id).email, DateTime.Now.Date);
         return(Redirect("~/Customer/Index/"));
     }
     return(Redirect("~/Customer/Index/"));
 }
Ejemplo n.º 6
0
 public ActionResult MyOrder()
 {
     if (Session["id"] != null)
     {
         ViewBag.KH = CustomerAction.Find_Customer((int)Session["id"]);
         return(View());
     }
     else
     {
         return(Redirect("~/Book/ShowBook"));
     }
 }
Ejemplo n.º 7
0
        /* ------------------------------------------------------------- */



        /* UPDATE IMAGE BOOK */
        public ActionResult UpdateImg(int Id, HttpPostedFileBase File)
        {
            string path = "";

            if (File.ContentLength > 0)
            {
                string File_Name = Path.GetFileName(File.FileName);
                path = Path.Combine(Server.MapPath("~/UploadFiles"), File_Name);
                File.SaveAs(path);
                BookAction.Update_Img(Id, File_Name);
            }
            RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " change image from " + BookAction.Find_Book(Id).ten_sach, DateTime.Now.Date);
            return(Redirect("~/Book/BookDetail/" + Id));
        }
 public ActionResult Editcustomer(int Id)
 {
     //ViewBag.ID = Id;
     if (Id != 0)
     {
         Customer customer = CustomerAction.Find_Customer(Id);
         ViewBag.Customer = customer;
         return(View());
     }
     else
     {
         return(Redirect("~/Book/ShowBook"));
     }
 }
Ejemplo n.º 9
0
        public ActionResult CreateBook(string Ten_Sach, string Tac_Gia, string The_Loai, string Nha_Xuat_Ban, string Mo_Ta, double Gia_Ban, HttpPostedFileBase File)
        {
            Book   book = new Book();
            string path = "";

            if (File.ContentLength > 0)
            {
                string File_Name = Path.GetFileName(File.FileName);
                path = Path.Combine(Server.MapPath("~/UploadFiles"), File_Name);
                File.SaveAs(path);
                BookAction.Create_Book(Ten_Sach, Tac_Gia, The_Loai, Nha_Xuat_Ban, Mo_Ta, Gia_Ban, File_Name);
            }
            RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " create new book.", DateTime.Now.Date);
            return(Redirect("~/Book/CreateBook"));
        }
Ejemplo n.º 10
0
        /* GET CUSTOMER BY ID */
        public ActionResult Customer_Info(int ID)
        {
            if (Session["id"] != null)
            {
                using (var db = new DBShop())
                {
                    int page = db.DbBill.Count();
                    ViewBag.Customer = CustomerAction.Find_Customer(ID);
                    ViewBag.Page     = page / page_size + (page % page_size == 0 ? 0 : 1);
                    db.Dispose();
                }


                return(View());
            }
            else
            {
                return(Redirect("~/Book/ShowBook"));
            }
        }
Ejemplo n.º 11
0
 public ActionResult EditBook(int Id, string Ten_Sach, string Tac_Gia, string The_Loai, string Nha_Xuat_Ban, string Mo_Ta, double Gia_Ban)
 {
     BookAction.Edit_Book(Id, Ten_Sach, Tac_Gia, The_Loai, Nha_Xuat_Ban, Mo_Ta, Gia_Ban);
     RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " update book " + Ten_Sach, DateTime.Now.Date);
     return(Redirect("~/Book/BookManager/" + Session["id"]));
 }
Ejemplo n.º 12
0
 /* RESTORE GENRES WERE DELETED */
 public ActionResult UnlockGenre(int ID)
 {
     GenreAction.Unlock_Genre(ID);
     RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " restorer genre" + GenreAction.Find_By_ID(ID).genre, DateTime.Now.Date);
     return(Redirect("~/Home/RestoreData"));
 }
Ejemplo n.º 13
0
 /* DELETE GENRE */
 public ActionResult DeleteGenre(int ID)
 {
     GenreAction.Lock_Genre(ID);
     RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " delete genre" + GenreAction.Find_By_ID(ID).genre, DateTime.Now.Date);
     return(Redirect("~/Book/BookManager/" + Session["id"]));
 }
Ejemplo n.º 14
0
 public ActionResult UpdateGenre(int ID, string Name)
 {
     GenreAction.Update_Genre(ID, Name);
     RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " update genre " + Name, DateTime.Now.Date);
     return(Redirect("~/Book/BookManager"));
 }
Ejemplo n.º 15
0
 /* RESTORE BOOKS WERE DELETED */
 public ActionResult Unlock_Book(int Id)
 {
     BookAction.Restore_Book(Id);
     RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " restore book " + BookAction.Find_Book(Id).ten_sach, DateTime.Now.Date);
     return(Redirect("~/Home/RestoreData"));
 }
Ejemplo n.º 16
0
 /* Find Customer By ID */
 public JsonResult GetCustomer(int Id)
 {
     return(Json(CustomerAction.Find_Customer(Id), JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 17
0
 /* SEARCH CUSTOMER BY EMAIL */
 public JsonResult Search(string Email)
 {
     return(Json(CustomerAction.Find_Customer(Email), JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 18
0
 /* DELETE BOOK */
 public ActionResult DeleteBook(int Id)
 {
     BookAction.Delete_Book(Id);
     RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " delete book " + BookAction.Find_Book(Id).ten_sach, DateTime.Now.Date);
     return(Redirect("~/Book/BookManager/" + Session["id"]));
 }
Ejemplo n.º 19
0
        /* ---------------------------------------------------------- */



        /* SHOW CUSTOMER INFORMATION BY ID */
        public ActionResult ViewCustomer(int Id)
        {
            ViewBag.Customer = CustomerAction.Find_Customer(Id);
            return(View());
        }