Example #1
0
 public long Insert(User user)
 {
     user.CreatedDate = DateTime.Now;
     db.Users.Add(user);
     db.SaveChanges();
     return(user.ID);
 }
Example #2
0
 public long Insert(Slide slide)
 {
     slide.CreatedDate = DateTime.Now;
     db.Slides.Add(slide);
     db.SaveChanges();
     return(slide.ID);
 }
Example #3
0
        public long Create(Content content)
        {
            //Xử lý alias
            if (string.IsNullOrEmpty(content.MetaTitle))
            {
                content.MetaTitle = StringHelper.ToUnsignString(content.Name);
            }
            content.CreateDate = DateTime.Now;
            content.ViewCount  = 0;
            db.Content.Add(content);
            db.SaveChanges();

            //Xử lý tag
            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);

                    //insert to to tag table
                    if (!existedTag)
                    {
                        this.InsertTag(tagId, tag);
                    }

                    //insert to content tag
                    this.InsertContentTag(content.ID, tagId);
                }
            }

            return(content.ID);
        }
        public bool InsertShipper(int UserID, int OrderId)
        {
            try
            {
                List <ShipperOrder> valid = db.ShipperOrders.Where(x => x.UserID == UserID).ToList();
                foreach (var item in valid)
                {
                    if (!item.Status)
                    {
                        return(false);
                    }
                }

                var data = new ShipperOrder()
                {
                    UserID  = UserID,
                    OrderID = OrderId,
                    Status  = false
                };
                db.ShipperOrders.Add(data);
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #5
0
        //Thêm bản ghi username
        public long Insert(User entity)
        {
            db.Users.Add(entity);
            db.SaveChanges();

            return(entity.ID);
        }
        public bool SynChronizedData(string data)
        {
            var cat = new EF.ProductCategory();

            try
            {
                //var jObject = JObject.Parse(data);
                List <Model.EF.ProductCategory> jObject = JsonConvert.DeserializeObject <List <Model.EF.ProductCategory> >(data);


                foreach (EF.ProductCategory category in jObject)
                {
                    cat.Name         = category.Name;
                    cat.ParentID     = category.ParentID;
                    cat.DisplayOrder = category.DisplayOrder;
                    cat.CreateDate   = DateTime.Now;
                    cat.CreateBy     = category.CreateBy;
                    cat.ShowOnHome   = true;
                    cat.Status       = true;
                    db.ProductCategories.Add(cat);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                //write log
                return(false);
            }
        }
Example #7
0
 public long Insert(Product product)
 {
     product.CreatedDate = DateTime.Now;
     db.Products.Add(product);
     db.SaveChanges();
     return(product.ID);
 }
Example #8
0
 public long InsertUser(User user)
 {
     user.CreatedDate = DateTime.Now;
     onlineShopDbContext.Users.Add(user);
     onlineShopDbContext.SaveChanges();
     return(user.ID);
 }
Example #9
0
        //Thêm bản ghi slideshow
        public long Insert(Slide entity)
        {
            db.Slides.Add(entity);
            db.SaveChanges();

            return(entity.ID);
        }
Example #10
0
 public long Insert(ProductCategory productCategory)
 {
     productCategory.CreatedDate = DateTime.Now;
     db.ProductCategories.Add(productCategory);
     db.SaveChanges();
     return(productCategory.ID);
 }
Example #11
0
 public long Insert(About about)
 {
     about.CreatedDate = DateTime.Now;
     db.Abouts.Add(about);
     db.SaveChanges();
     return(about.ID);
 }
Example #12
0
 public long Edit(Content content)
 {
     //Xu ly alias
     if (string.IsNullOrEmpty(content.MetaTitle))
     {
         content.MetaTitle = StringHelper.toUnsignString(content.Name);
     }
     content.CreateDate = DateTime.Now;
     db.Content.Add(content);
     db.SaveChanges();
     //xu ly Tag
     if (!string.IsNullOrEmpty(content.Tags))
     {
         RemoveAllContentTag(content.ID);
         string[] tags = content.Tags.Trim().Split(',');
         foreach (var tag in tags)
         {
             var tagId      = StringHelper.toUnsignString(tag);
             var existedTag = this.CheckTag(tagId);
             //Insert to Tag Table
             if (!existedTag)
             {
                 this.InsertTag(tagId, tag);
             }
             //Insert to content tag
             this.InsertContentTag(content.ID, tagId);
         }
     }
     return(content.ID);
 }
        public void UpdateImages(long productId, string images)
        {
            var product = db.ProductDetails.Find(productId);

            product.MoreImages = images;
            db.SaveChanges();
        }
Example #14
0
 public long Insert(Product entity)
 {
     entity.CreatedDate = DateTime.Now;
     db.Products.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Example #15
0
 public long Insert(Category category)
 {
     category.CreatedDate = DateTime.Now;
     db.Categories.Add(category);
     db.SaveChanges();
     return(category.ID);
 }
Example #16
0
        public long Create(Content content)
        {
            // resolve alias
            if (string.IsNullOrEmpty(content.MetaTitle))
            {
                content.MetaTitle = StringHelper.ToUnsignString(content.Name);
            }
            content.CreateDate = DateTime.Now;
            content.ViewCount  = 0;
            db.Contents.Add(content);
            db.SaveChanges();

            // process tag
            if (!string.IsNullOrEmpty(content.Tags))
            {
                string[] tags = content.Tags.Split(',');
                foreach (var tagName in tags)
                {
                    var tagId        = StringHelper.ToUnsignString(tagName);
                    var isExistedtag = this.CheckTag(tagId);
                    if (!isExistedtag)
                    {
                        this.InsertToTagTable(tagId, tagName);
                    }
                    // Insert new tag to ContentTag
                    this.InsertToContentTag(content.ID, tagId);
                }
            }

            return(content.ID);
        }
Example #17
0
 public long Insert(Category entity)
 {
     entity.CreatedDate = DateTime.Now;
     db.Categories.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Example #18
0
 public bool createOrder(Order model, List <OrderDetail> lstItem)
 {
     using (var scope = new System.Transactions.TransactionScope())
     {
         try
         {
             var order = new Order();
             order.CustomerID  = model.CustomerID;
             order.CreateDate  = model.CreateDate;
             order.ShipName    = model.ShipName;
             order.ShipMobile  = model.ShipMobile;
             order.ShipEmail   = model.ShipEmail;
             order.ShipAddress = model.ShipAddress;
             order.Status      = model.Status;
             order.CustomerID  = model.CustomerID;
             context.Orders.Add(order);
             context.SaveChanges();
             foreach (var item in lstItem)
             {
                 item.OrderID = order.ID;
                 context.OrderDetails.Add(item);
             }
             context.SaveChanges();
             scope.Complete();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Example #19
0
 public bool Insert(Product product)
 {
     product.CreatedDate = DateTime.Now;
     db.Products.Add(product);
     db.SaveChanges();
     return(true);
 }
Example #20
0
        public bool changeStatus(long id)
        {
            var record = context.Abouts.Find(id);

            record.Status = !record.Status;
            context.SaveChanges();
            return((bool)record.Status);
        }
Example #21
0
        public bool ChangeStatus(long id)
        {
            var user = db.Users.Find(id);

            user.Status = !user.Status;
            db.SaveChanges();
            return(user.Status);
        }
Example #22
0
 public long Insert(About entity)
 {
     entity.CreatedDate = DateTime.Now;
     //entity.CreatedBy = nguoi dang nhap hien tai ;
     db.Abouts.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
Example #23
0
        public bool ChangeStatus(long id)
        {
            var user = db.Slides.Find(id);

            user.Status = !user.Status;
            db.SaveChanges();
            return(user.Status.Value);
        }
 public int Insert(Category category)
 {
     category.MetaTitle  = Utility.ConvertToUnSign(category.Name);
     category.CreateDate = DateTime.Now;
     db.Categories.Add(category);
     db.SaveChanges();
     return(category.ID);
 }
Example #25
0
        public long InsertProduct(Product product)
        {
            product.CreatedDate = DateTime.Now;

            onlineShopDbContext.Products.Add(product);
            onlineShopDbContext.SaveChanges();
            return(product.ID);
        }
Example #26
0
 public int Insert(Product product)
 {
     product.MetaTitle  = Utility.ConvertToUnSign(product.Name);
     product.CreateDate = DateTime.Now;
     product.Status     = false;
     db.Products.Add(product);
     db.SaveChanges();
     return(product.ID);
 }
Example #27
0
 // hàm insert
 public long Insert(ProductCategory category)
 {
     if (category != null)
     {
         db.ProductCategories.Add(category);
         db.SaveChanges();
         return(category.ID);
     }
     return(-1);
 }
        //TẠO SẢN PHẨM
        public long Create(Product product)
        {
            product.CreatedDate = DateTime.Now;
            product.ViewCount   = 0;
            product.Status      = true;

            db.Products.Add(product);
            db.SaveChanges();
            return(product.ID);
        }
Example #29
0
 public long Insert(Product product)
 {
     if (string.IsNullOrEmpty(product.MetaTitle))
     {
         product.MetaTitle = StringHelper.ToUnsignString(product.Name);
     }
     db.Product.Add(product);
     db.SaveChanges();
     return(product.ID);
 }
Example #30
0
 public long Insert(User entity)
 {
     if (entity.CreatedDate == null)
     {
         entity.CreatedDate = DateTime.Now;
     }
     db.Users.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }
        private static void SeedDatabase()
        {
            TestCleanUp();
            var context = new OnlineShopDbContext();

            var userStore = new UserStore<ApplicationUser>(context);
            var userManager = new ApplicationUserManager(userStore);

            var user = new ApplicationUser() { UserName = TestUsername, Email = TestUsername + "@gmail.com" };

            var result = userManager.CreateAsync(user, TestPassword).Result;
            if (!result.Succeeded)
            {
                Assert.Fail(string.Join(Environment.NewLine, result.Errors));
            }

            SeedCategories(context);
            SeedAdTypes(context);
            context.SaveChanges();
        }