Exemple #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 JsonResult Delete(long id)
        {
            if (id == 0)
            {
                return(Json(false));
            }

            EntityReferenceManager entityReferenceManager = new EntityReferenceManager();

            try
            {
                //check if entity ref in db exist
                var entityRef = entityReferenceManager.References.FirstOrDefault(e => e.Id.Equals(id));
                if (entityRef != null)
                {
                    //check if user has rights to edit a dataset
                    if (hasUserRights(entityRef.SourceId, entityRef.SourceEntityId, RightType.Write))
                    {
                        entityReferenceManager.Delete(id);
                        return(Json(true));
                    }
                    else
                    {
                        return(Json("Error : " + "you are not authorized!"));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json("Error : " + ex.Message));
            }
            finally
            {
                entityReferenceManager.Dispose();
            }

            return(Json(false));
        }