Ejemplo n.º 1
0
        public ActionResult Add(FormCollection form)
        {
            ResourceEntity entity = new ResourceEntity()
            {
                Title = form["title"],
                Url = form["url"],
                Type = form["type"]
            };

            return ResultToMessagePage(ResourceManager.AdminInsertResource, entity, "Your have added resource successfully!");
        }
Ejemplo n.º 2
0
        public ActionResult Edit(Int32 id, FormCollection form)
        {
            ResourceEntity entity = new ResourceEntity()
            {
                ResourceID = id,
                Title = form["title"],
                Url = form["url"],
                Type = form["type"]
            };

            return ResultToMessagePage(ResourceManager.AdminUpdateResource, entity, "Your have edited resource successfully!");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="entity">对象实体</param>
        /// <returns>是否成功增加</returns>
        public static IMethodResult AdminInsertResource(ResourceEntity entity)
        {
            if (!AdminManager.HasPermission(PermissionType.ResourceManage))
            {
                throw new NoPermissionException();
            }

            if (String.IsNullOrEmpty(entity.Title))
            {
                return MethodResult.FailedAndLog("Resource title can not be NULL!");
            }

            if (String.IsNullOrEmpty(entity.Url))
            {
                return MethodResult.FailedAndLog("Resource url can not be NULL!");
            }

            if (String.IsNullOrEmpty(entity.Type))
            {
                return MethodResult.FailedAndLog("Resource type can not be NULL!");
            }

            Boolean success = ResourceRepository.Instance.InsertEntity(entity) > 0;

            if (!success)
            {
                return MethodResult.FailedAndLog("No resource was added!");
            }

            ResourceCache.RemoveResourceListCache();//删除缓存

            return MethodResult.SuccessAndLog("Admin add resource, title = {0}", entity.Title);
        }