Exemplo n.º 1
0
        private void addPhotoPosts(MvcContext ctx)
        {
            User       creator = ctx.viewer.obj as User;
            PhotoApp   app     = getPhotoAppByUser(creator);
            PhotoAlbum album   = createUserAlbum(creator, app);

            List <PhotoSysCategory> cats = PhotoSysCategory.findAll();

            for (int i = 0; i < 20; i++)
            {
                PhotoPost x = new PhotoPost();
                x.AppId   = app.Id;
                x.DataUrl = Img.CopyToUploadPath("/__installer/pic/pic" + i + ".jpg");
                x.Title   = Path.GetFileName(x.DataUrl);

                if (cats.Count > 0)
                {
                    int idxCat = getCatIndex(cats.Count, i);
                    x.SysCategoryId = cats[idxCat].Id;
                }

                x.PhotoAlbum = album;

                x.Creator    = creator;
                x.CreatorUrl = creator.Url;
                x.OwnerId    = creator.Id;
                x.OwnerType  = creator.GetType().FullName;
                x.OwnerUrl   = creator.Url;

                postService.CreatePost(x, app);
            }
        }
 public virtual List<PhotoSysCategory> GetForDroplist() {
     List<PhotoSysCategory> list = this.GetAll();
     PhotoSysCategory c = new PhotoSysCategory();
     c.Name = lang.get( "plsSelect" ) + "...";
     list.Insert( 0, c );
     return list;
 }
        public virtual List <PhotoSysCategory> GetForDroplist()
        {
            List <PhotoSysCategory> list = this.GetAll();
            PhotoSysCategory        c    = new PhotoSysCategory();

            c.Name = lang.get("plsSelect") + "...";
            list.Insert(0, c);
            return(list);
        }
Exemplo n.º 4
0
        public void List(int categoryId)
        {
            PhotoSysCategory     category = categoryService.GetById(categoryId);
            DataPage <PhotoPost> list     = photoService.GetSysPostPage(categoryId, 35);

            bindOneCategory(this.utils.getCurrentView(), category, list.Results);
            set("page", list.PageBar);

            WebUtils.pageTitle(this, category.Name, lang("photo"));
        }
Exemplo n.º 5
0
        private List<PhotoSysCategory> addSelectInfo( List<PhotoSysCategory> categories )
        {
            PhotoSysCategory category = new PhotoSysCategory();
            category.Id = -1;
            category.Name = lang( "setCategory" );

            List<PhotoSysCategory> list = new List<PhotoSysCategory>();
            list.Add( category );
            foreach (PhotoSysCategory cat in categories) {
                list.Add( cat );
            }
            return list;
        }
Exemplo n.º 6
0
        public void List(int categoryId)
        {
            set("appLink", to(Index));

            PhotoSysCategory category = categoryService.GetById(categoryId);

            ctx.Page.SetTitle(category.Name, lang("photo"));

            DataPage <PhotoPost> list = photoService.GetSysPostPage(categoryId, 20);

            bindOneCategory(this.utils.getCurrentView(), category, list.Results);
            set("page", list.PageBar);
        }
Exemplo n.º 7
0
 private PhotoSysCategory validate(PhotoSysCategory c)
 {
     if (c == null)
     {
         c = new PhotoSysCategory();
     }
     c = ctx.PostValue(c) as PhotoSysCategory;
     if (strUtil.IsNullOrEmpty(c.Name))
     {
         errors.Add(lang("exName"));
     }
     return(c);
 }
Exemplo n.º 8
0
        public void Edit(int id)
        {
            target(Update, id);

            PhotoSysCategory c = categoryService.GetById(id);

            if (c == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            bind("category", c);
        }
Exemplo n.º 9
0
        public void Delete(int id)
        {
            PhotoSysCategory c = categoryService.GetById(id);

            if (c == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }
            db.delete(c);
            log(SiteLogString.DeletePhotoSysCategory(), c);

            redirect(List);
        }
Exemplo n.º 10
0
        public void Create()
        {
            PhotoSysCategory c = validate(null);

            if (ctx.HasErrors)
            {
                run(Add);
                return;
            }

            db.insert(c);
            log(SiteLogString.InsertPhotoSysCategory(), c);

            echoToParentPart(lang("opok"));
        }
Exemplo n.º 11
0
        private List <PhotoSysCategory> addSelectInfo(List <PhotoSysCategory> categories)
        {
            PhotoSysCategory category = new PhotoSysCategory();

            category.Id   = -1;
            category.Name = lang("setCategory");

            List <PhotoSysCategory> list = new List <PhotoSysCategory>();

            list.Add(category);
            foreach (PhotoSysCategory cat in categories)
            {
                list.Add(cat);
            }
            return(list);
        }
Exemplo n.º 12
0
        private List<PhotoSysCategory> addSelectInfo( List<PhotoSysCategory> categories ) {
            PhotoSysCategory category = new PhotoSysCategory();
            category.Id = -1;
            category.Name = lang( "setCategory" );

            PhotoSysCategory nullCat = new PhotoSysCategory();
            nullCat.Id = zeroCatId;
            nullCat.Name = "--无分类--";

            List<PhotoSysCategory> list = new List<PhotoSysCategory>();
            list.Add( category );
            list.Add( nullCat );
            foreach (PhotoSysCategory cat in categories) {
                list.Add( cat );
            }
            return list;
        }
Exemplo n.º 13
0
        private void bindOneCategory(IBlock block, PhotoSysCategory c, List <PhotoPost> photos)
        {
            block.Set("category.Name", c.Name);
            block.Set("category.LinkShow", to(List, c.Id));

            IBlock pblock = block.GetBlock("photos");

            foreach (PhotoPost p in photos)
            {
                if (p.Creator == null)
                {
                    continue;
                }

                pblock.Set("p.LinkShow", alink.ToAppData(p));
                pblock.Set("p.ImgThumbUrl", p.ImgThumbUrl);
                pblock.Set("p.CreatorName", p.Creator.Name);
                pblock.Set("p.CreatorLink", toUser(p.Creator));
                pblock.Set("p.Hits", p.Hits);
                pblock.Next();
            }
        }
Exemplo n.º 14
0
        public void Update(int id)
        {
            PhotoSysCategory c = categoryService.GetById(id);

            if (c == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            c = validate(c);
            if (ctx.HasErrors)
            {
                run(Edit, id);
                return;
            }

            db.update(c);
            log(SiteLogString.UpdatePhotoSysCategory(), c);

            echoToParentPart(lang("opok"));
        }
Exemplo n.º 15
0
        private List <PhotoSysCategory> addSelectInfo(List <PhotoSysCategory> categories)
        {
            PhotoSysCategory category = new PhotoSysCategory();

            category.Id   = -1;
            category.Name = lang("setCategory");

            PhotoSysCategory nullCat = new PhotoSysCategory();

            nullCat.Id   = zeroCatId;
            nullCat.Name = "--无分类--";

            List <PhotoSysCategory> list = new List <PhotoSysCategory>();

            list.Add(category);
            list.Add(nullCat);
            foreach (PhotoSysCategory cat in categories)
            {
                list.Add(cat);
            }
            return(list);
        }
Exemplo n.º 16
0
        public virtual void SaveSort()
        {
            int    id  = ctx.PostInt("id");
            String cmd = ctx.Post("cmd");

            PhotoSysCategory        target = categoryService.GetById(id);
            List <PhotoSysCategory> list   = categoryService.GetAll();

            if (cmd == "up")
            {
                new SortUtil <PhotoSysCategory>(target, list).MoveUp();
                echoRedirect("ok");
            }
            else if (cmd == "down")
            {
                new SortUtil <PhotoSysCategory>(target, list).MoveDown();
                echoRedirect("ok");
            }
            else
            {
                echoError(lang("exUnknowCmd"));
            }
        }
Exemplo n.º 17
0
 private void log( String msg, PhotoSysCategory c )
 {
     String dataInfo = "{Id:" + c.Id + ", Name:'" + c.Name + "'}";
     logService.Add( (User)ctx.viewer.obj, msg, dataInfo, typeof( PhotoSysCategory ).FullName, ctx.Ip );
 }
Exemplo n.º 18
0
        private void log(String msg, PhotoSysCategory c)
        {
            String dataInfo = "{Id:" + c.Id + ", Name:'" + c.Name + "'}";

            logService.Add((User)ctx.viewer.obj, msg, dataInfo, typeof(PhotoSysCategory).FullName, ctx.Ip);
        }
Exemplo n.º 19
0
        private void bindOneCategory( IBlock block, PhotoSysCategory c, List<PhotoPost> photos )
        {
            block.Set( "category.Name", c.Name );
            block.Set( "category.LinkShow", to( List, c.Id ) );

            IBlock pblock = block.GetBlock( "photos" );
            foreach (PhotoPost p in photos) {

                if (p.Creator == null) continue;

                pblock.Set( "p.LinkShow", alink.ToAppData( p ) );
                pblock.Set( "p.ImgThumbUrl", p.ImgThumbUrl );
                pblock.Set( "p.CreatorName", p.Creator.Name );
                pblock.Set( "p.CreatorLink", toUser( p.Creator ) );
                pblock.Set( "p.Hits", p.Hits );
                pblock.Next();
            }
        }
Exemplo n.º 20
0
 private PhotoSysCategory validate( PhotoSysCategory c )
 {
     if (c == null) c = new PhotoSysCategory();
     c = ctx.PostValue( c ) as PhotoSysCategory;
     if (strUtil.IsNullOrEmpty( c.Name )) errors.Add( lang( "exName" ) );
     return c;
 }