how to POST two strings?

Posted by Garrith on Stack Overflow See other posts from Stack Overflow or by Garrith
Published on 2012-04-07T11:27:13Z Indexed on 2012/04/07 11:28 UTC
Read the original article Hit count: 206

Filed under:
|
|
|

Im trying to create a POST method for my AddTagtoGroup

which looks like this (altho still confused as string group never seems to be used):

    List<Group> Groups = new List<Group>();
    List<Tag> tags = new List<Tag>();
    public void AddTagtoGroup(string group, string tag)
    {
        var result = Groups.Where(n => String.Equals(n.GroupName, tag)).FirstOrDefault();
        if (result != null)
        {
            result.Tags.Add(new Tag() { TagName = tag });
        }
    }  

My data contracts looks like this:

[DataContract(Name = "Group")]
public class Group
{

    public Group() // not sure if this has to have a datamember
    {
        Tags = new List<Tag>();
    }
    [DataMember(Name = "GroupName")]
    public string GroupName { get; set; }
    public List<Tag> Tags { get; set; } // datamember or not?

}
[DataContract(Name = "Tag")]
public class Tag
{
    [DataMember(Name = "TagName")]
    public string TagName { get; set; }
}

And my post method looks like this but im unsure what to put in the uri template?

        [OperationContract]
        [WebInvoke(Method = "POST",
 BodyStyle = WebMessageBodyStyle.Bare, 
RequestFormat = WebMessageFormat.Xml, 
ResponseFormat = WebMessageFormat.Xml, 
UriTemplate = "/AddTagtoGroup{group}{tag}")]
        void AddTagtoGroup(string group, string tag);

© Stack Overflow or respective owner

Related posts about c#

Related posts about wcf