Пример #1
0
        /// <summary>
        /// AsLinkEditModel
        /// </summary>
        /// <param name="link">链接实体</param>
        /// <returns></returns>
        public static LinkEditModel AsLinkEditModel(this LinkEntity link)
        {
            LinkEditModel linkEditModel = new LinkEditModel();

            linkEditModel.LinkId          = link.LinkId;
            linkEditModel.LinkName        = link.LinkName;
            linkEditModel.LinkNameForSite = link.LinkName;
            linkEditModel.LinkUrl         = link.LinkUrl;
            linkEditModel.Description     = link.Description;
            linkEditModel.ImageUrl        = link.ImageUrl;
            linkEditModel.LinkType        = link.LinkType;
            linkEditModel.IsEnabled       = link.IsEnabled;
            return(linkEditModel);
        }
Пример #2
0
        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 _EditLink(long? linkId)
        {
            LinkEntity link = LinkEntity.New();
            LinkEditModel linkEditModel = new LinkEditModel();

            if (linkId.HasValue)
            {
                link = linkService.Get(linkId.Value);
                linkEditModel = link.AsLinkEditModel();
                linkEditModel.LinkId = linkId.Value;
            }

            IEnumerable<Category> categories = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().Link());
            ViewData["categories"] = new SelectList(categories, "CategoryId", "CategoryName", link.Categories.Count() > 0 ? link.Categories.ElementAt(0).CategoryId : (long)0);

            return View(linkEditModel);
        }
Пример #4
0
 /// <summary>
 /// AsLinkEditModel
 /// </summary>
 /// <param name="link">链接实体</param>
 /// <returns></returns>
 public static LinkEditModel AsLinkEditModel(this LinkEntity link)
 {
     LinkEditModel linkEditModel = new LinkEditModel();
     linkEditModel.LinkId = link.LinkId;
     linkEditModel.LinkName = link.LinkName;
     linkEditModel.LinkNameForSite = link.LinkName;
     linkEditModel.LinkUrl = link.LinkUrl;
     linkEditModel.Description = link.Description;
     linkEditModel.ImageUrl = link.ImageUrl;
     linkEditModel.LinkType = link.LinkType;
     linkEditModel.IsEnabled = link.IsEnabled;
     return linkEditModel;
 }
Пример #5
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));
        }
Пример #6
0
        public ActionResult _EditTextLink(long linkId = 0)
        {
            LinkEditModel linkEditModel = new LinkEditModel();

            if (linkId > 0)
            {
                LinkEntity link = linkService.Get(linkId);
                if (!authorizer.Link_Edit(link))
                {
                    return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                    {
                        Body = "对不起,您没有这个权限",
                        Title = "没有权限",
                        StatusMessageType = StatusMessageType.Hint
                    }));
                }

                //编辑
                linkEditModel = link.AsLinkEditModel();
            }
            return View(linkEditModel);
        }
Пример #7
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)));
        }