Esempio n. 1
0
        public ActionResult Tags(TagModel tag)
        {
            ClearAlerts("Alert Tags M", 3);

            // get the list of tags from Session
            List <TagModel> tags = getTags();

            // we'll need to validate the data
            if (tags.Exists(t => t.Name == tag.Name))
            {
                Session.Add("Alert Tags M1", "Tag name already exists. Please use a distinct name.");
                return(View());
            }

            // we need to add the tag to the database first to get the Id
            tag.Id = TagProcessor.CreateTag(tag.Name, (int)Session["Language"], tag.Description);
            tags.Add(tag);

            // lastly, we'll need to clear the values in the fields
            ModelState.SetModelValue("Name", new ValueProviderResult("", "", ModelState["Name"].Value.Culture));
            ModelState.SetModelValue("Description", new ValueProviderResult("", "", ModelState["Description"].Value.Culture));

            return(View());
        }