コード例 #1
0
ファイル: EmailService.cs プロジェクト: saeidmh83/MyCMS
        public SendingMailResult SendCommentReplyNotification(CommentReplyEmailNotificationData data, CommentReplyType replyType)
        {
            var urlHelper = new UrlHelper(_httpContext.Request.RequestContext);

            var link = string.Empty;

            switch (replyType)
            {
            case CommentReplyType.ReplyToArticleComment:
                link = urlHelper.Action(MVC.Article.ActionNames.Index, MVC.Article.Name, new
                {
                    title = UrlExtensions.ResolveTitleForUrl(data.PostTitle),
                    id    = data.PostId
                }, _httpContext.Request.Url.Scheme);
                break;

            case CommentReplyType.ReplyToPageComment:
                link = urlHelper.Action(MVC.Page.ActionNames.Index, MVC.Page.Name, new
                {
                    title = UrlExtensions.ResolveTitleForUrl(data.PostTitle),
                    id    = data.PostId
                }, _httpContext.Request.Url.Scheme);
                break;

            case CommentReplyType.ReplyToPostComment:
                link = urlHelper.Action(MVC.Post.ActionNames.Index, MVC.Post.Name, new
                {
                    title = UrlExtensions.ResolveTitleForUrl(data.PostTitle),
                    id    = data.PostId
                }, _httpContext.Request.Url.Scheme);
                break;
            }

            link += "#comment-" + data.CommentId;

            var model = new CommentReplyNotificationModel
            {
                FromUserName = data.FromUserName,
                ToUserName   = data.ToUserName,
                PostId       = data.PostId,
                PostTitle    = data.PostTitle,
                CommentText  = data.CommentText,
                CommentLink  = link
            };

            var htmlText = _viewConvertor.RenderRazorViewToString(MVC.EmailTemplates.Views._CommentReplyNotification, model);


            var result = Send(new MailDocument
            {
                Body    = htmlText,
                Subject =
                    string.Format("شما پاسخی از طرف {0} در مطلب {1} دریافت کرده اید.", data.FromUserName, data.PostTitle),
                ToEmail = data.ToEmail
            });


            return(result);
        }
コード例 #2
0
 private IEnumerable <FeedItem> MapCommentsToFeedItems(IEnumerable <RssCommentModel> list)
 {
     return(list.Select(item => new FeedItem
     {
         AuthorName = item.Author,
         Content = item.Body,
         LastUpdatedTime = item.UpdateDate ?? item.CreatedDate,
         PublishDate = item.CreatedDate,
         Title = item.Title,
         Url = Url.Action(MVC.Post.ActionNames.Index, MVC.Post.Name, new
         {
             id = item.Id,
             title = UrlExtensions.ResolveTitleForUrl(item.Title)
         }, "http")
     }).ToList());
 }
コード例 #3
0
ファイル: SearchController.cs プロジェクト: saeidmh83/MyCMS
        public virtual ActionResult AutoCompleteSearch(string term)
        {
            if (string.IsNullOrWhiteSpace(term))
            {
                return(Content(string.Empty));
            }

            IEnumerable <LucenePostModel> items =
                LucenePostSearch.Search(term, "Title", "Body", "Labels", "Keywords", "Description").Take(10);


            var data =
                items.Select(x => new
            {
                label = x.Title,
                url   =
                    Url.Action(MVC.Post.ActionNames.Index, MVC.Post.Name,
                               new { id = x.PostId, title = UrlExtensions.ResolveTitleForUrl(x.Title) })
            });

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public override IEnumerable <DynamicNode> GetDynamicNodeCollection()
        {
            var returnValue = new List <DynamicNode>();

            foreach (SiteMapModel post in _postService.GetSiteMapData(20))
            {
                var node = new DynamicNode
                {
                    Title            = post.Title,
                    Controller       = "Post",
                    Action           = "Index",
                    Area             = "",
                    LastModifiedDate = post.ModifiedDate ?? post.CreatedDate,
                    ChangeFrequency  = ChangeFrequency.Daily,
                    UpdatePriority   = UpdatePriority.Absolute_050,
                };
                node.RouteValues.Add("id", post.Id);
                node.RouteValues.Add("title", UrlExtensions.ResolveTitleForUrl(node.Title));
                returnValue.Add(node);
            }

            // Return
            return(returnValue);
        }
コード例 #5
0
ファイル: SearchController.cs プロジェクト: ArDotWeb/eShop
        public virtual ActionResult AutoCompleteSearch(string term)
        {
            IEnumerable <LuceneProductModel> model = LuceneProductSearch.Search(term, "Product_Name", "Product_Explain").Take(10);
            var list = model.Select(x => x.Product_Name).ToList();


            var data =
                model.Select(x => new
            {
                label = x.Product_Name,
                url   = Url.RouteUrl("DetailsProduct", new { productId = x.Product_Id, productName = UrlExtensions.ResolveTitleForUrl(x.Product_Name) })
            });

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
        public virtual ActionResult CreateProduct(ProductViewModel model, IEnumerable <HttpPostedFileBase> ImageProductAdditinal)
        {
            var product = new Product()
            {
                Explain = model.Explain, Category = _categoryService.GetById(model.Category_Id), Company = _companyService.GetById(model.Company_Id), Name = model.Name, Labels = _labelService.GetLabelsByIds(model.Labels), Time = model.Time, Date = model.Date, VisitNumber = 0, Price = model.Price, Recomend = 1, ModifiedDate = DateTime.Now
            };

            //save primary image with 3 size
            if (model.Image != null)
            {
                if (model.Image.ContentLength > 0)
                {
                    using (var img = Image.FromStream(model.Image.InputStream))
                    {
                        string fileName = TODO.CheckExistFile(Server.MapPath("~/Content/Images/Product/MainSize/"), model.Image.FileName);

                        TODO.UploadImage(img, new Size(180, 180), Server.MapPath("~/Content/Images/Product/MainSize/"), fileName);
                        TODO.UploadImage(img, new Size(70, 70), Server.MapPath("~/Content/Images/Product/ThumbLine_New/"), fileName);
                        TODO.UploadImage(img, new Size(60, 75), Server.MapPath("~/Content/Images/Product/ThumbLine_Offer"), fileName);
                        product.PrimryImage = fileName;
                    }
                }
            }

            //save other image for this prduct
            var listImage = new List <ImageProduct>();

            foreach (var item in ImageProductAdditinal)
            {
                if (item != null && item.ContentLength > 0)
                {
                    string fileName = TODO.CheckExistFile(Server.MapPath("~/Content/Images/Product/GallerySize/"), model.Image.FileName);

                    TODO.UploadImage(Image.FromStream(item.InputStream), new Size(450, 450), Server.MapPath("~/Content/Images/Product/GallerySize/"), fileName);
                    listImage.Add(new ImageProduct {
                        Image = fileName, Product = product
                    });
                }
            }


            product.ImageProducts = listImage;
            _productService.Create(product);

            if (_unitOfWork.SaveAllChanges() > 0)
            {
                //For Use Notification With SignalR
                //Response Redirect To Main Page In Site
                //return RedirectToAction(MVC.admin.Product.ActionNames.DetailsProduct, new { Id = product.Id });
                if (Request.Cookies["Cart"] != null)
                {
                    HttpCookie cookie = Request.Cookies["Cart"];
                    cookie.Value   = "true";
                    cookie.Expires = DateTime.Now.AddMinutes(2);
                    System.Web.HttpContext.Current.Response.Cookies.Set(cookie);
                }
                else
                {
                    HttpCookie cookie = new HttpCookie("Alert");
                    cookie.Value   = "true";
                    cookie.Expires = DateTime.Now.AddMinutes(2);
                    System.Web.HttpContext.Current.Response.Cookies.Add(cookie);
                }

                LuceneProductSearch.AddUpdateLuceneIndex(new LuceneProductModel
                {
                    Product_Id      = product.Id,
                    Product_Name    = product.Name,
                    Product_Explain = product.Explain.Length > 400 ?
                                      product.Explain.ToSafeHtml().RemoveHtmlTags().Substring(0, 400) :
                                      product.Explain.ToSafeHtml().RemoveHtmlTags()
                });

                return(RedirectToRoute("DetailsProduct", new { productId = product.Id, productName = UrlExtensions.ResolveTitleForUrl(product.Name) }));
            }
            else
            {
                TempData["createProduct"] = Helperalert.alert(new AlertViewModel {
                    Alert = AlertOperation.SurveyOperation(StatusOperation.FailInsert), Status = AlertMode.warning
                });
                return(RedirectToAction(MVC.admin.Product.ActionNames.CreateProduct));
            }
        }