public static System.Web.Mvc.ActionResult Result(object data, DSH.Main.Web.RESTComponents.ContentTypes contentType, HttpStatusCode statusCode)
 {
     switch (contentType)
     {
         case DSH.Main.Web.RESTComponents.ContentTypes.Html:
         case DSH.Main.Web.RESTComponents.ContentTypes.Text:
         case DSH.Main.Web.RESTComponents.ContentTypes.FormEncoded:
             return new StringActionResult(data, contentType, statusCode);
         case DSH.Main.Web.RESTComponents.ContentTypes.Binary:
             return new BinaryActionResult(data, contentType, statusCode);
         case DSH.Main.Web.RESTComponents.ContentTypes.Xml:
             return new XmlActionResult(data, contentType, statusCode);
         case DSH.Main.Web.RESTComponents.ContentTypes.Json:
             return new JsonActionResult(data, contentType, statusCode);
         default:
             throw Errors.ContentTypeNotSupported(contentType);
     }
 }
        public ActionResult Create(DSH.Access.DataModels.Comment comment)
        {
            try
            {
                //comment.ClosedDate = DateTime.Now;
                //comment.CommentCount = 0;
                //comment.CommunityOwnedDate = DateTime.Now;
                comment.CreationDate = DateTime.Now;
                //comment.FavoriteCount = 3;
                //comment.IsAnonymous = false;
                comment.LastActivityDate = DateTime.Now;
                comment.LastEditDate = DateTime.Now;

                Users u = _userDataAccess.GetUserInfo(Session["id"].ToString());

                comment.LastEditorDisplayname = u.DisplayName;
                comment.LastEditorUserId = u.Id;
                comment.OwnerDisplayName = u.DisplayName;
                comment.OwnerUserId = u.Id;
                comment.Score = 0;
                //comment.Tags = "No Tags";
                //comment.Title = "No Title";
                //comment.ViewCount = 0;
                var newComment = _commentDataAccess.InsertComment(comment);
                return Json(new
                {
                    Status = "SUCCESS",
                    Result = Json(newComment)
                });
            }
            catch (Exception)
            {
                return Json(new
                {
                    Status = "FAILED",
                    Result = ""
                });
            }
        }
Beispiel #3
0
 public static Exception ContentTypeNotSupported(DSH.Main.Web.RESTComponents.ContentTypes contentType)
 {
     return new Exception(string.Format(
         RestfulContent.ContentTypeNotSupported,
         contentType.ToString()));
 }