示例#1
0
        public JsonResult _EditTextLink(LinkEditModel linkEditModel)
        {
            string statusMsg = string.Empty;
            LinkEntity link = linkEditModel.AsLink();

            if (link.LinkId > 0)
            {
                //编辑操作
                if (!authorizer.Link_Edit(link))
                {
                    return Json(new StatusMessageData(StatusMessageType.Error, "对不起,您没有这个权限"));
                }
                linkService.Update(link);

                statusMsg = "编辑成功!";
            }
            else
            {
                //创建操作
                long ownerIdResult = 0;
                int ownerTypeResult = 0;
                long.TryParse(Request.Form.Get("ownerId"), out ownerIdResult);
                int.TryParse(Request.Form.Get("ownerType"), out ownerTypeResult);
                link.OwnerId = ownerIdResult;
                link.OwnerType = ownerTypeResult;

                linkService.Create(link);

                if (link.LinkId > 0)
                {
                    statusMsg = "创建成功!";
                }
            }

            return Json(new StatusMessageData(StatusMessageType.Success, statusMsg));
        }
        public ActionResult _EditLink(LinkEditModel linkEditModel, IEnumerable<long> categoryId)
        {
            LinkEntity link = linkEditModel.AsLink();

            string successMsg = string.Empty;
            HttpPostedFileBase localImage = Request.Files["localImage"];

            //更新操作
            if (link.LinkId > 0)
            {
                //获取图片URL
                GetLinkImageUrl(link, localImage);

                //更新图片
                linkService.Update(link);

                //清除链接与类别的联系
                categoryService.ClearCategoriesFromItem(link.LinkId, 0, TenantTypeIds.Instance().Link());

                successMsg = "编辑成功!";
            }
            //创建操作
            else
            {
                linkService.Create(link);

                GetLinkImageUrl(link, localImage);

                linkService.Update(link);

                successMsg = "创建成功!";
            }

            categoryService.AddCategoriesToItem(categoryId, link.LinkId);

            return Content(System.Web.Helpers.Json.Encode(new StatusMessageData(StatusMessageType.Success, successMsg)));
        }
示例#3
0
        public ActionResult _EditImageLink(LinkEditModel linkEditModel)
        {
            LinkEntity link = linkEditModel.AsLink();
            link.LinkType = LinkType.ImageLink;
            ;
            string statusMsg = string.Empty;

            HttpPostedFileBase localImage = Request.Files["localImage"];

            if (link.LinkId > 0)
            {
                //编辑操作操作
                if (!authorizer.Link_Edit(link))
                {
                    return Json(new StatusMessageData(StatusMessageType.Error, "对不起,您没有这个权限"));
                }

                if (localImage != null && !string.IsNullOrEmpty(localImage.FileName))
                {
                    //本地图片
                    link.ImageUrl = logoService.UploadLogo(link.LinkId, localImage.InputStream);
                }

                linkService.Update(link);
                statusMsg = "编辑成功";
            }
            else
            {
                //添加操作
                long ownerIdResult = 0;
                int ownerTypeResult = 0;
                long.TryParse(Request.Form.Get("ownerId"), out ownerIdResult);
                int.TryParse(Request.Form.Get("ownerType"), out ownerTypeResult);
                link.OwnerId = ownerIdResult;
                link.OwnerType = ownerTypeResult;

                linkService.Create(link);
                if (localImage != null)
                {
                    //本地图片
                    link.ImageUrl = logoService.UploadLogo(link.LinkId, localImage.InputStream);
                    linkService.Update(link);
                }
                statusMsg = "添加成功";
            }

            return Content(System.Web.Helpers.Json.Encode(new StatusMessageData(StatusMessageType.Success, statusMsg)));
        }