Exemple #1
0
        //Lấy ra 1 người dùng

        public int Update(user user)
        {
            user sql = WcDbContext.users.Single(u => u.UserId == user.UserId);

            sql.RoleId       = user.RoleId;
            sql.StatusUserId = user.StatusUserId;

            var n = WcDbContext.SaveChanges();

            return(n);
        }
        public int Add(String name)
        {
            category category = new category();

            category.NameCategory = name;
            WcDbContext.categories.Add(category);

            var n = WcDbContext.SaveChanges();

            return(n);
        }
Exemple #3
0
        public comment Add(comment comment)
        {
            var cmt = WcDbContext.comments.Add(comment);
            var n   = WcDbContext.SaveChanges();

            if (n > 0)
            {
                cmt.user = WcDbContext.users.Single(user => user.UserId == cmt.UserId);

                return(cmt);
            }

            return(null);
        }
Exemple #4
0
        public comic Add(comic comic, List <int> category)
        {
            var rs      = WcDbContext.comics.Add(comic);
            int comicId = rs.ComicId;

            foreach (int categoryId in category)
            {
                var cc = WcDbContext.comic_category.Add(new comic_category(comicId, categoryId));
            }

            var n = WcDbContext.SaveChanges();

            return(rs);
        }
Exemple #5
0
        public chapter Add(chapter chapter)
        {
            var c = WcDbContext.chapters.Add(chapter);

            WcDbContext.SaveChanges();

            c.FolderImage = String.Format("/Upload/truyen/{0}/{1}", c.ComicId, c.ChapterId);
            var comic = WcDbContext.comics.Single(comic1 => comic1.ComicId == c.ComicId);

            comic.UpdateAt = DateTime.Now;

            WcDbContext.SaveChanges();

            return(c);
        }
Exemple #6
0
        public chapter Add(chapter chapter, int userId)
        {
            var comic = WcDbContext.comics.Single(c =>
                                                  c.UserId == userId && c.user.RoleId < 3 && c.StatusComicId < 4 && c.ComicId == chapter.ComicId);

            if (comic != null)
            {
                var checkeName =
                    WcDbContext.chapters.Where(chapter1 =>
                                               chapter1.NameChapter.Equals(chapter.NameChapter) && chapter1.ComicId == chapter.ComicId)
                    .Count();

                if (checkeName == 0)
                {
                    var num = WcDbContext.chapters.Where(chapter1 => chapter1.ComicId == chapter.ComicId)
                              .Max(chapter1 => chapter1.NumChapter);

                    if (num != null)
                    {
                        chapter.NumChapter = num + 1;
                    }

                    //thêm chapter
                    var ct = WcDbContext.chapters.Add(chapter);

                    //Cập nhật time
                    comic.UpdateAt = DateTime.Now;

                    ct.FolderImage = String.Format("/Upload/truyen/{0}/{1}_{2}", ct.ComicId,
                                                   ct.NameChapter.Replace(" ", "_"), DateTime.Now.ToString("ddMMyy_hhmm"));

                    WcDbContext.SaveChanges();

                    return(ct);
                }
            }

            return(null);
        }
Exemple #7
0
        //đăng ký
        public int SignUp(user user)
        {
            var a = CheckMail(user.UserMail);

            if (a == 0)
            {
                var sql = WcDbContext.users.Add(user);
                var n   = WcDbContext.SaveChanges();
                //cho phép đăng ký
                return(n);
            }
            else
            {
                //email đã tồn tại
                return(-1);
            }
        }