Esempio n. 1
0
        public long Create(Content content)
        {
            //Alias
            if (string.IsNullOrEmpty(content.MetaTile))
            {
                content.MetaTile = StringHelper.ToUnsignString(content.Name);
            }
            content.CreateDate = DateTime.Now;
            db.Contents.Add(content);
            db.SaveChanges();
            if (!string.IsNullOrEmpty(content.Tags))
            {
                string[] tags = content.Tags.Split(',');
                foreach (var tag in tags)
                {
                    var tagId      = StringHelper.ToUnsignString(tag);
                    var existedTag = this.CheckTag(tagId);

                    //chèn vào bảng tag
                    if (!existedTag)
                    {
                        this.InsertTag(tagId, tag);
                    }
                    //insert to content tag
                    this.InsertContentTag(content.ID, tagId);
                }
            }
            return(content.ID);
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "MaChatLieu,TenChatLieu")] ChatLieu chatLieu)
        {
            if (ModelState.IsValid)
            {
                db.ChatLieux.Add(chatLieu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(chatLieu));
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "UserId,UserName,PassWord,Email,Phone,Avatar,Allowed")] USER uSER)
        {
            if (ModelState.IsValid)
            {
                db.USERS.Add(uSER);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(uSER));
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "MaNhanVien,TenNhanVien,GioiTinh,NgaySinh,DienThoai,DiaChi")] NhanVien nhanVien)
        {
            if (ModelState.IsValid)
            {
                db.NhanViens.Add(nhanVien);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nhanVien));
        }
        public ActionResult Create([Bind(Include = "MaNhaSanXuat,TenNhaSanXuat,DiaChiNhaSanXuat,DienThoaiNhaSanXuat")] NhaSanXuat nhaSanXuat)
        {
            if (ModelState.IsValid)
            {
                db.NhaSanXuats.Add(nhaSanXuat);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nhaSanXuat));
        }
        public ActionResult Create([Bind(Include = "MaDoiTuong,TenDoiTuong")] DoiTuong doiTuong)
        {
            if (ModelState.IsValid)
            {
                db.DoiTuongs.Add(doiTuong);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(doiTuong));
        }
Esempio n. 7
0
        public ActionResult Create([Bind(Include = "MaTheLoai,TenTheLoai")] TheLoai theLoai)
        {
            if (ModelState.IsValid)
            {
                db.TheLoais.Add(theLoai);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(theLoai));
        }
Esempio n. 8
0
        public ActionResult Create([Bind(Include = "MaKhachHang,TenKhachHang,DiaChiKhachHang,DienThoaiKhach,TenDangNhap,MatKhau,NgaySinh,GioiTinh,Email")] KhachHang khachHang)
        {
            if (ModelState.IsValid)
            {
                db.KhachHangs.Add(khachHang);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(khachHang));
        }
Esempio n. 9
0
        public ActionResult Create([Bind(Include = "MaKichCo,TenKichCo")] KichCo kichCo)
        {
            if (ModelState.IsValid)
            {
                db.KichCoes.Add(kichCo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(kichCo));
        }
Esempio n. 10
0
        public ActionResult Create([Bind(Include = "SoHoaDon,MaSanPham,MaKhachHang,SoLuong,DonGia,ThanhTien,NgayDatHang,NgayGiaoHang")] ChiTietDatHang chiTietDatHang)
        {
            if (ModelState.IsValid)
            {
                db.ChiTietDatHangs.Add(chiTietDatHang);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaKhachHang = new SelectList(db.KhachHangs, "MaKhachHang", "TenKhachHang", chiTietDatHang.MaKhachHang);
            ViewBag.MaSanPham   = new SelectList(db.SanPhams, "MaSanPham", "TenSanPham", chiTietDatHang.MaSanPham);
            return(View(chiTietDatHang));
        }
Esempio n. 11
0
        public ActionResult Create([Bind(Include = "MaSanPham,TenSanPham,MaDoiTuong,MaTheLoai,MaKichCo,MaChatLieu,MaNhaSanXuat,DonViTinh,SoLuong,SoLuongBan,DonGia,MoTa,NgayCapNhat,HinhMinhHoa")] SanPham sanPham)
        {
            if (ModelState.IsValid)
            {
                db.SanPhams.Add(sanPham);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaChatLieu   = new SelectList(db.ChatLieux, "MaChatLieu", "TenChatLieu", sanPham.MaChatLieu);
            ViewBag.MaDoiTuong   = new SelectList(db.DoiTuongs, "MaDoiTuong", "TenDoiTuong", sanPham.MaDoiTuong);
            ViewBag.MaKichCo     = new SelectList(db.KichCoes, "MaKichCo", "TenKichCo", sanPham.MaKichCo);
            ViewBag.MaNhaSanXuat = new SelectList(db.NhaSanXuats, "MaNhaSanXuat", "TenNhaSanXuat", sanPham.MaNhaSanXuat);
            ViewBag.MaTheLoai    = new SelectList(db.TheLoais, "MaTheLoai", "TenTheLoai", sanPham.MaTheLoai);
            return(View(sanPham));
        }
Esempio n. 12
0
 public bool Insert(OrderDetail detail)
 {
     try
     {
         db.OrderDetails.Add(detail);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 13
0
 public bool Insert(DetailOrder detail)
 {
     try
     {
         data.DetailOrders.Add(detail);
         data.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public ActionResult Create(SanPham model)
        {
            //
            model.CreateDate = DateTime.Now;

            var dao = new WebBanHangDbContext();

            dao.SanPhams.Add(model);
            int result = dao.SaveChanges();

            if (result > 0)
            {
                return(RedirectToAction("Index"));
            }

            SetViewBag();
            return(View(model));
        }
Esempio n. 15
0
 public string Insert(Admin entity)
 {
     data.Admins.Add(entity);
     data.SaveChanges();
     return(entity.UserName);
 }
Esempio n. 16
0
 public void UpdateUser(User user)
 {
     data.Users.AddOrUpdate(user);
     data.SaveChanges();
 }
Esempio n. 17
0
 public long Insert(User entity)
 {
     db.Users.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Esempio n. 18
0
 public void UpdateCategory(Category cgy)
 {
     data.Categories.AddOrUpdate(cgy);
     data.SaveChanges();
 }
Esempio n. 19
0
 public long Insert(Order order)
 {
     db.Orders.Add(order);
     db.SaveChanges();
     return(order.ID);
 }
Esempio n. 20
0
 public long Insert(Order order)
 {
     data.Orders.Add(order);
     data.SaveChanges();
     return(order.IDOrder);
 }
Esempio n. 21
0
 public void AddBlogPost(BlogPost post)
 {
     data.BlogPosts.Add(post);
     data.SaveChanges();
 }
Esempio n. 22
0
 public void SendMessage(Contact contact)
 {
     data.Contacts.Add(contact);
     data.SaveChanges();
 }
Esempio n. 23
0
 public void AddBlog(Blog blog)
 {
     data.Blogs.Add(blog);
     data.SaveChanges();
 }
Esempio n. 24
0
 public void UpdateTradeMark(TradeMark tm)
 {
     data.TradeMarks.AddOrUpdate(tm);
     data.SaveChanges();
 }
Esempio n. 25
0
 public void UpdateProduct(Product prd)
 {
     data.Products.AddOrUpdate(prd);
     data.SaveChanges();
 }
Esempio n. 26
0
 public void AddComment(Comment comment)
 {
     data.Comments.Add(comment);
     data.SaveChanges();
 }
Esempio n. 27
0
 public virtual void Add(T entity)
 {
     dbSet.Add(entity);
     context.SaveChanges();
 }