Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Code sample for update field value on the front end page
jifeng
#1 Posted : Tuesday, October 25, 2011 8:08:21 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,555
Location: Xiamen China
Code:

@using Kooboo.CMS.Content.Query; 
@using Kooboo.CMS.Content.Models; 
@{

   if(ViewBag.Job!=null)
   {
         var textContent =(TextContent)ViewBag.Job;
         var totalReading = 1;
         if(textContent["TotalReading"]!=null)
        {
                totalReading = (int)textContent["TotalReading"] +1 ;
         }
     Kooboo.CMS.Content.Services.ServiceFactory.TextContentManager.Update(Repository.Current,textContent.GetSchema(),
textContent.UUID,"TotalReading",totalReading);

     }
}
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
Hrvoje_86
#2 Posted : Friday, October 28, 2011 7:37:59 PM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 1/28/2011(UTC)
Posts: 157
Location: Croatia
Can you give an example to update multiple fields?
NjayWu
#3 Posted : Saturday, October 29, 2011 2:14:15 PM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 3/14/2011(UTC)
Posts: 34
Location: XM
Code:


public void Update(string uuid, IEnumerable<string> fieldNames, IEnumerable<object> fieldValues, string userName = "")
{
ServiceFactory.TextContentManager.Update(
Repository.Current,
Folder.GetSchema(),
uuid,
fieldNames,
fieldValues,
userName);
}

public TEntity Update(string uuid, NameValueCollection values, string userName = "")
{
var content = ServiceFactory.TextContentManager.Update(
Repository.Current,
Folder.GetSchema(),
uuid,
values,
null,
userName);
return Get(content);
}


You can have a good read this TextContent CURD base class :

http://koobootoolkit.cod...ervices%2fServiceBase.cs
Regards,

NJ Wu

Kooboo3 Fans

http://www.qiyeqiye.com
1 user thanked NjayWu for this useful post.
Hrvoje_86 on 10/29/2011(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.5.5 | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.303 seconds.