예제 #1
0
        public ActionResult CreateOneToMany(OneToManyRelationshipModel oneToMany)
        {
            if (!Services.Authorizer.Authorize(Permissions.PublishContent, T("Not allowed to edit a content.")))
            {
                return(new HttpUnauthorizedResult());
            }

            if (oneToMany.IsCreate)
            {
                var checkNameMessage = _relationshipService.CheckRelationName(oneToMany.Name);
                if (!string.IsNullOrWhiteSpace(checkNameMessage))
                {
                    ModelState.AddModelError("OneToManyRelation", T(checkNameMessage).ToString());
                    return(ResponseError(""));
                }
                var backMessage = _relationshipService.CreateRelationship(oneToMany);
                int relationId;
                if (int.TryParse(backMessage.ToString(), out relationId))
                {
                    return(Json(new { relationId = relationId }));
                }
                if (!string.IsNullOrWhiteSpace(backMessage))
                {
                    ModelState.AddModelError("OneToManyRelation", T(backMessage).ToString());
                    return(ResponseError(""));
                }
            }
            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
예제 #2
0
 public object GetRelationNameValidation(string relationName)
 {
     return(new { ErrorMessage = _relationshipService.CheckRelationName(relationName) });
 }