Example #1
0
        public ActionResult ReferenceTest()
        {
            EntityReferenceManager entityReferenceManager = new EntityReferenceManager();

            var x = entityReferenceManager.Create(1, 1, 2, 2, 2, 3, "test", "testType");

            entityReferenceManager.Delete(x);

            return(View("index"));
        }
        public ActionResult Create(CreateSimpleReferenceModel model)
        {
            EntityReferenceHelper  helper = new EntityReferenceHelper();
            EntityReferenceManager entityReferenceManager = new EntityReferenceManager();

            try
            {
                if (hasUserRights(model.SourceId, model.SourceTypeId, RightType.Write))
                {
                    SetViewData(model.SourceId, model.SourceTypeId, false, true);

                    if (!ModelState.IsValid)
                    {
                        return(PartialView("_create", model));
                    }

                    EntityReference entityReference = helper.Convert(model);
                    entityReferenceManager.Create(entityReference);

                    // if successfuly created a entity link return a json true
                    return(Json(true));
                }

                ModelState.AddModelError("", "you are not authorized!");
                return(PartialView("_create", model));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message.ToString());
                return(PartialView("_create", model));
            }
            finally
            {
                entityReferenceManager.Dispose();
            }
        }