Пример #1
0
 public long Insert(User entity)
 {
     entity.CreatedDate = DateTime.Now;
     db.User.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Пример #2
0
        public JsonResult CreateProduct(Product pr)
        {
            FashionShopDbContext db = new FashionShopDbContext();
            Product temp            = db.Product.Find(pr.maSanPham);

            if (temp == null)
            {
                Product pro = new Product();
                pro.maSanPham     = pr.maSanPham;
                pro.moTa          = pr.moTa;
                pro.giaSanPham    = pr.giaSanPham;
                pro.chatLieu      = pr.chatLieu;
                pro.loaiSanPhamMa = pr.loaiSanPhamMa;
                pro.soLuongDatMua = 0;
                pro.mauSac        = pr.mauSac;
                pro.urlAnh        = pr.urlAnh;
                pro.tenSanPham    = pr.tenSanPham;
                db.Product.Add(pro);
                db.SaveChanges();
                return(Json(new
                {
                    status = true
                }));
            }
            return(Json(new
            {
                status = false
            }));
        }
Пример #3
0
        public long Insert(OrderViewModel Order)
        {
            HoaDon hd = new HoaDon();

            hd.CreatedDate = Order.CreatedDate;
            hd.ID_User     = Order.UserID;
            hd.Status      = false;
            db.HoaDon.Add(hd);
            db.SaveChanges();
            //Order.ID=hd.ID;
            return(hd.ID);
        }
Пример #4
0
        public IActionResult SignUp(Register register)
        {
            User user = new User();

            user.Email        = register.Email;
            user.Password     = Crypto.HashPassword(register.Password);
            user.CreationDate = DateTime.UtcNow;
            user.role         = 0;
            _context.User.Add(user);
            int success = _context.SaveChanges();

            if (success == 0)
            {
                ViewBag.Message = "Failed to Register";
            }
            else
            {
                ViewBag.Message = "Register Sucessful!";
            }
            return(View());
        }
Пример #5
0
 public bool Insert(OrderDetail detail)
 {
     try
     {
         db.OrderDetails.Add(detail);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #6
0
 public bool Delete(int id)
 {
     try
     {
         var feedback = db.Feedbacks.Find(id);
         db.Feedbacks.Remove(feedback);
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #7
0
        public ActionResult Register(User us)
        {
            FashionShopDbContext db = new FashionShopDbContext();

            if (ModelState.IsValid)
            {
                //Thêm dữ liệu vào bảng User
                db.User.Add(us);

                //Lưu vào CSDL
                db.SaveChanges();
                ViewBag.ThongBao = "Đăng kí thành công";
            }
            return(View());
        }
Пример #8
0
        public JsonResult DeleteGroupDetail(string id)
        {
            FashionShopDbContext db       = new FashionShopDbContext();
            GroupDetail          grDetail = db.GroupDetail.Find(id);

            if (grDetail != null)
            {
                db.GroupDetail.Remove(grDetail);
                db.SaveChanges();
            }
            return(Json(new
            {
                status = true
            }));
        }
Пример #9
0
        public JsonResult DeleteProduct(string maSanPham)
        {
            FashionShopDbContext db = new FashionShopDbContext();
            Product pr = db.Product.Find(maSanPham);

            if (pr != null)
            {
                db.Product.Remove(pr);
                db.SaveChanges();
            }
            return(Json(new
            {
                status = true
            }));
        }
Пример #10
0
        public JsonResult UpdateGroupPr(string maNhom, string tenNhom, string tittle)
        {
            FashionShopDbContext db = new FashionShopDbContext();
            GroupPr gr = db.GroupPr.Find(maNhom);

            if (gr != null)
            {
                gr.tenNhom     = tenNhom;
                gr.meta_tittle = tittle;
                db.SaveChanges();
            }
            return(Json(new
            {
                status = true
            }));
        }
Пример #11
0
        public JsonResult UpdateGroupDetail(string maLoai, string tenLoai, string tittle, string maNhom)
        {
            FashionShopDbContext db       = new FashionShopDbContext();
            GroupDetail          grDetail = db.GroupDetail.Find(maLoai);

            if (grDetail != null)
            {
                grDetail.tenLoaiSanPham = tenLoai;
                grDetail.meta_tittle    = tittle;
                grDetail.nhomMa         = maNhom;
                db.SaveChanges();
            }
            return(Json(new
            {
                status = true
            }));
        }
Пример #12
0
 public bool Insert(OrderDetailViewModel orderDetail)
 {
     try
     {
         ChiTietHoaDon Chitiet = new ChiTietHoaDon();
         Chitiet.ID_HoaDon  = orderDetail.OrderID;
         Chitiet.ID_SanPham = orderDetail.ProductID;
         Chitiet.ID_Size    = 3;
         Chitiet.Quantity   = orderDetail.Quantity;
         Chitiet.Price      = orderDetail.Price * orderDetail.Quantity;
         db.ChiTietHoaDon.Add(Chitiet);
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #13
0
        public JsonResult UpdateProduct(Product product)
        {
            FashionShopDbContext db = new FashionShopDbContext();
            Product pr = db.Product.Find(product.maSanPham);

            if (pr != null)
            {
                pr.tenSanPham    = product.tenSanPham;
                pr.soLuongDatMua = product.soLuongDatMua;
                pr.moTa          = product.moTa;
                pr.mauSac        = product.mauSac;
                pr.loaiSanPhamMa = product.loaiSanPhamMa;
                pr.giaSanPham    = product.giaSanPham;
                pr.chatLieu      = product.chatLieu;
                db.SaveChanges();
            }
            return(Json(new
            {
                status = true
            }));
        }
Пример #14
0
        public JsonResult CreateGroupDetail(string maLoai, string tenLoai, string tittle, string manhom)
        {
            FashionShopDbContext db   = new FashionShopDbContext();
            GroupDetail          temp = db.GroupDetail.Find(maLoai);

            if (temp == null)
            {
                var list = db.GroupDetail.Where(x => x.meta_tittle == tittle).ToList();
                if (list.Count() == 0)
                {
                    GroupDetail grDetail = new GroupDetail();
                    grDetail.maLoaiSanPham  = maLoai;
                    grDetail.tenLoaiSanPham = tenLoai;
                    grDetail.meta_tittle    = tittle;
                    grDetail.nhomMa         = manhom;
                    db.GroupDetail.Add(grDetail);
                    db.SaveChanges();
                    return(Json(new
                    {
                        status = 1
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        status = 3
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    status = 2
                }));
            }
        }
Пример #15
0
        public JsonResult DeleteGroupPr(string id)
        {
            FashionShopDbContext db = new FashionShopDbContext();
            GroupPr gr = db.GroupPr.Find(id);
            int     st = 1;

            if (gr != null)
            {
                try
                {
                    db.GroupPr.Remove(gr);
                    db.SaveChanges();
                }
                catch
                {
                    st = 2;
                }
            }
            return(Json(new
            {
                status = st
            }));
        }
Пример #16
0
        public JsonResult CreateGroupPr(string maNhom, string tenNhom, string tittle)
        {
            FashionShopDbContext db = new FashionShopDbContext();
            GroupPr temp            = db.GroupPr.Find(maNhom);

            if (temp == null)
            {
                var list = db.GroupPr.Where(x => x.meta_tittle == tittle).ToList();
                if (list.Count() == 0)
                {
                    GroupPr gr = new GroupPr();
                    gr.maNhom      = maNhom;
                    gr.tenNhom     = tenNhom;
                    gr.meta_tittle = tittle;
                    db.GroupPr.Add(gr);
                    db.SaveChanges();
                    return(Json(new
                    {
                        status = 1
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        status = 3
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    status = 2
                }));
            }
        }
Пример #17
0
 public long Insert(ProductCategory entity)
 {
     db.ProductCategories.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Пример #18
0
 public long Insert(Admin entity)
 {
     db.Admin.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Пример #19
0
 public IActionResult DeleteUser(int UserId)
 {
     _context.User.Remove(_context.User.Find(UserId));
     _context.SaveChanges();
     return(RedirectToAction("Dashboard"));
 }
Пример #20
0
 public long Insert(Product entity)
 {
     db.Products.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Пример #21
0
 public long Insert(User entity)
 {
     db.Users.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Пример #22
0
 public long Insert(Order order)
 {
     db.Orders.Add(order);
     db.SaveChanges();
     return(order.ID);
 }
Пример #23
0
 public int Insert(Receipt re)
 {
     db.Receipt.Add(re);
     db.SaveChanges();
     return(re.maHoaDon);
 }