//--------------------------------------------------------------------------
        public void AfterBlogrollInsert( Blogroll br )
        {
            User owner = User.findById( br.OwnerId );
            int appId = br.AppId;

            LayoutCacher.Update( owner, appId );
        }
        private Blogroll Validate(Blogroll roll)
        {
            if (roll == null)
            {
                roll = new Blogroll();
            }

            roll.Name        = ctx.Post("Name");
            roll.OrderId     = ctx.PostInt("OrderId");
            roll.Link        = ctx.Post("Link");
            roll.Description = ctx.Post("Description");

            if (strUtil.IsNullOrEmpty(roll.Name))
            {
                errors.Add(lang("exName"));
            }
            if (strUtil.IsNullOrEmpty(roll.Link))
            {
                errors.Add(lang("exUrl"));
            }

            if (!(!strUtil.HasText(roll.Link) || roll.Link.ToLower().StartsWith("http://")))
            {
                roll.Link = "http://" + roll.Link;
            }

            return(roll);
        }
        //--------------------------------------------------------------------------



        public void AfterBlogrollInsert(Blogroll br)
        {
            User owner = User.findById(br.OwnerId);
            int  appId = br.AppId;

            LayoutCacher.Update(owner, appId);
        }
Exemple #4
0
        public virtual Blogroll GetById(long id, long appId)
        {
            Blogroll blogroll = db.findById <Blogroll>(id);

            if ((blogroll != null) && (blogroll.AppId != appId))
            {
                return(null);
            }
            return(blogroll);
        }
        public void Create()
        {
            Blogroll roll = Validate(null);

            if (errors.HasErrors)
            {
                echoError();
            }
            else
            {
                rollService.Insert(roll, ctx.owner.obj.Id, ctx.app.Id);
                echoRedirect(lang("opok"), AdminList);
            }
        }
        public void Delete(int id)
        {
            Blogroll blogroll = rollService.GetById(id, ctx.app.Id);

            if (blogroll != null)
            {
                rollService.Delete(blogroll);
                redirect(AdminList);
            }
            else
            {
                echoRedirect(lang("exDataNotFound"));
            }
        }
        public void Edit(int id)
        {
            Blogroll blogroll = rollService.GetById(id, ctx.app.Id);

            if (blogroll == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }
            set("roll.Name", blogroll.Name);
            set("roll.Link", blogroll.Link);
            set("roll.OrderId", blogroll.OrderId);
            set("roll.Description", blogroll.Description);
            target(Update, id);
        }
        public void Update(int id)
        {
            Blogroll blogroll = rollService.GetById(id, ctx.app.Id);

            blogroll = Validate(blogroll);
            if (errors.HasErrors)
            {
                echoError();
            }
            else
            {
                rollService.Update(blogroll);
                echoRedirect(lang("opok"), AdminList);
            }
        }
        public virtual void Update(long id)
        {
            Blogroll blogroll = rollService.GetById(id, ctx.app.Id);

            blogroll = Validate(blogroll);
            if (errors.HasErrors)
            {
                echoError();
            }
            else
            {
                rollService.Update(blogroll);
                echoRedirectPart(lang("opok"), to(AdminList));
            }
        }
Exemple #10
0
 public async Task UpdateAsync(Blogroll entity)
 {
     await _blogrollRepository.UpdateAsync(entity);
 }
        private Blogroll Validate( Blogroll roll ) {

            if (roll == null) roll = new Blogroll();

            roll.Name = ctx.Post( "Name" );
            roll.OrderId = ctx.PostInt( "OrderId" );
            roll.Link = ctx.Post( "Link" );
            roll.Description = ctx.Post( "Description" );

            if (strUtil.IsNullOrEmpty( roll.Name )) errors.Add( lang( "exName" ) );
            if (strUtil.IsNullOrEmpty( roll.Link )) errors.Add( lang( "exUrl" ) );

            if (!(!strUtil.HasText( roll.Link ) || roll.Link.ToLower().StartsWith( "http://" ))) {
                roll.Link = "http://" + roll.Link;
            }

            return roll;
        }
Exemple #12
0
        public async Task <Blogroll> CreateAsync(Blogroll entity)
        {
            entity.Id = await _blogrollRepository.InsertAndGetIdAsync(entity);

            return(entity);
        }
 public override void UpdateBlogroll(Blogroll blogroll)
 {
     var context = new BlogsEntities();
     var obj = new tblBlogs_Blogrolls {Id = blogroll.Id};
     context.AttachTo("tblBlogs_Blogrolls", obj);
     BizObject<Blogroll, int>.CopyToObject(blogroll, obj);
     context.SaveChanges();
 }
 public abstract void UpdateBlogroll(Blogroll blogroll);
 public virtual void Delete( Blogroll roll ) {
     db.delete( roll );
 }
 public virtual void Update( Blogroll roll ) {
     db.update( roll );
 }
 public virtual void Insert(Blogroll roll, long ownerId, long appId) {
     roll.AppId = appId;
     roll.OwnerId = ownerId;
     db.insert( roll );
 }
 public abstract int InsertBlogroll(Blogroll blogroll);
Exemple #19
0
 public virtual void Insert(Blogroll roll, long ownerId, long appId)
 {
     roll.AppId   = appId;
     roll.OwnerId = ownerId;
     db.insert(roll);
 }
 public override int InsertBlogroll(Blogroll blogroll)
 {
     var context = new BlogsEntities();
     var obj = new tblBlogs_Blogrolls();
     BizObject<Blogroll, int>.CopyToObject(blogroll, obj);
     context.AddTotblBlogs_Blogrolls(obj);
     context.SaveChanges();
     return obj.Id;
 }
Exemple #21
0
 public virtual void Update(Blogroll roll)
 {
     db.update(roll);
 }
 private static Blogroll Convert(tblBlogs_Blogrolls obj)
 {
     if (obj == null)
     {
         return null;
     }
     var blogroll = new Blogroll(obj.Id, obj.CreatedDate, obj.CreatedBy, obj.ModifiedDate, obj.ModifiedBy);
     BizObject<Blogroll, int>.CopyFromObject(blogroll, obj);
     return blogroll;
 }
Exemple #23
0
 public virtual void Delete(Blogroll roll)
 {
     db.delete(roll);
 }