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)); }
public object GetRelationNameValidation(string relationName) { return(new { ErrorMessage = _relationshipService.CheckRelationName(relationName) }); }