private void BuildModule(int id)
        {
            var widget       = WorkContext.Resolve <IWidgetService>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            var sectionBannerSliderService = WorkContext.Resolve <ISlidersService>();
            var articlesService            = WorkContext.Resolve <IArticlesService>();

            articlesService.LanguageCode = WorkContext.CurrentCulture;
            var partnerService = WorkContext.Resolve <IPartnerService>();

            #region SectionBannerSlider
            var modelSectionBannerSlider = new DataViewerModel();
            modelSectionBannerSlider.BannerImages = sectionBannerSliderService.GetRecords(x => x.Type == (int)PageSlider.Partner).FirstOrDefault();
            var viewSectionBannerSlider = viewRenderer.RenderPartialView(Extensions.Constants.ViewPageBannerImage, modelSectionBannerSlider);
            WorkContext.Layout.SectionBannerSlider.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region SectionPageContent
            var modelSectionPageContent = new DataViewerModel();
            modelSectionPageContent.CategoryInfo = categoryService.GetByIdCache(id);
            BuildBreadcrumb(modelSectionPageContent);
            modelSectionPageContent.Articles     = articlesService.GetByCategoryId(modelSectionPageContent.CategoryInfo.RefId);
            modelSectionPageContent.ListPartners = partnerService.GetRecords(x => x.LanguageCode == WorkContext.CurrentCulture && !x.IsDeleted);
            var viewSectionPageContent = viewRenderer.RenderPartialView(Extensions.Constants.ViewOurPartner, modelSectionPageContent);
            WorkContext.Layout.SectionPageContent.Add(new MvcHtmlString(viewSectionPageContent));
            #endregion
        }
        private void BuildModule(CategoryInfo cate)
        {
            var widget       = WorkContext.Resolve <IWidgetService>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            var sectionBannerSliderService = WorkContext.Resolve <ISlidersService>();
            var recruitmentService         = WorkContext.Resolve <IRecruitmentService>();

            recruitmentService.LanguageCode = WorkContext.CurrentCulture;
            recruitmentService.CategoryId   = cate.RefId;

            #region SectionBannerSlider
            var modelSectionBannerSlider = new DataViewerModel();
            modelSectionBannerSlider.BannerImages = sectionBannerSliderService.GetRecords(x => x.Type == (int)PageSlider.Recruitment).FirstOrDefault();
            var viewSectionBannerSlider = viewRenderer.RenderPartialView(Extensions.Constants.ViewPageBannerImage, modelSectionBannerSlider);
            WorkContext.Layout.SectionBannerSlider.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region SectionPageContent
            var modelSectionPageContent = new DataViewerModel();
            modelSectionPageContent.CategoryInfo = cate;
            modelSectionPageContent.CategoryId   = cate.Id;
            BuildBreadcrumb(modelSectionPageContent, cate.Id);
            var total = 0;
            modelSectionPageContent.PageSize         = PageSize;
            modelSectionPageContent.PageIndex        = PageIndex;
            modelSectionPageContent.ListRecruitments = recruitmentService.GetByCategoryId(0, PageIndex, PageSize, out total);
            modelSectionPageContent.TotalRow         = total;
            var viewSectionPageContent = viewRenderer.RenderPartialView(Extensions.Constants.ViewRecruitment, modelSectionPageContent);
            WorkContext.Layout.SectionPageContent.Add(new MvcHtmlString(viewSectionPageContent));
            #endregion
        }
Beispiel #3
0
        private void BuildModule(int id)
        {
            var widget       = WorkContext.Resolve <IWidgetService>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };
            var sectionBannerSliderService = WorkContext.Resolve <ISlidersService>();
            var imageService    = WorkContext.Resolve <IImagesService>();
            var articlesService = WorkContext.Resolve <IArticlesService>();

            articlesService.LanguageCode = WorkContext.CurrentCulture;

            #region SectionBannerSlider
            var modelSectionBannerSlider = new DataViewerModel();
            modelSectionBannerSlider.BannerImages = sectionBannerSliderService.GetRecords(x => x.Type == (int)PageSlider.Businesses).FirstOrDefault();
            var viewSectionBannerSlider = viewRenderer.RenderPartialView(Extensions.Constants.ViewPageBannerImage, modelSectionBannerSlider);
            WorkContext.Layout.SectionBannerSlider.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region SectionPageContent
            var modelSectionPageContent = new DataViewerModel();
            modelSectionPageContent.CategoryInfo = categoryService.GetByIdCache(id);
            BuildBreadcrumb(modelSectionPageContent);
            modelSectionPageContent.Articles = articlesService.GetByCategoryId(id);
            if (modelSectionPageContent.Articles != null)
            {
                modelSectionPageContent.ListImages = imageService.GetRecords(x => x.ArticlesId == modelSectionPageContent.Articles.RefId).ToList();
            }
            var viewSectionPageContent = viewRenderer.RenderPartialView(Extensions.Constants.ViewConsultingServices, modelSectionPageContent);
            WorkContext.Layout.SectionPageContent.Add(new MvcHtmlString(viewSectionPageContent));
            #endregion
        }
        public ActionResult NewsDetails(string categoryAlias, string alias)
        {
            var serviceNews = WorkContext.Resolve <IArticlesService>();
            var articles    = serviceNews.GetByAlias(alias, WorkContext.CurrentCulture);

            if (articles != null)
            {
                ViewData[Extensions.Constants.SeoTitle]       = articles.Title;
                ViewData[Extensions.Constants.SeoKeywords]    = articles.Tags;
                ViewData[Extensions.Constants.SeoDescription] = articles.Description;
            }

            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            #region News
            var modelNews = new DataViewerModel();
            modelNews.Articles = articles;
            var viewSectionNews = viewRenderer.RenderPartialView("~/Views/Shared/NewsDetails.cshtml", modelNews);
            WorkContext.Layout.SectionBlog.Add(new MvcHtmlString(viewSectionNews));
            #endregion

            return(View("Empty"));
        }
Beispiel #5
0
        public ActionResult Index()
        {
            var categoryService = WorkContext.Resolve <ICategoriesService>();

            categoryService.LanguageCode = WorkContext.CurrentCulture;
            var category = categoryService.GetById((int)Category.ShoppingCart);

            if (category != null)
            {
                ViewData[Extensions.Constants.SeoTitle]       = category.Name;
                ViewData[Extensions.Constants.SeoKeywords]    = category.Tags;
                ViewData[Extensions.Constants.SeoDescription] = category.Description;
            }

            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            #region Product
            var modelCart    = new DataViewerModel();
            var listProducts = new List <CartInfo>();
            if (WorkContext.HttpContext.Session[Extensions.Constants.KeyDataCart] != null)
            {
                listProducts = (List <CartInfo>)WorkContext.HttpContext.Session[Extensions.Constants.KeyDataCart];
            }
            modelCart.ListCart = listProducts;
            var viewSectionNews = viewRenderer.RenderPartialView("~/Views/Shared/ShoppingCartDetails.cshtml", modelCart);
            WorkContext.Layout.SectionProducts.Add(new MvcHtmlString(viewSectionNews));
            #endregion

            return(View("Empty"));
        }
Beispiel #6
0
        public ActionResult ReceiveEmail()
        {
            var emailAddress = Request.Form["txtEmailAddress"];
            var model        = new DataViewerModel();

            if (string.IsNullOrEmpty(emailAddress))
            {
                model.Status = false;
                model.Data   = T("Địa chỉ email không để trống.");
                return(Json(model));
            }

            var service = WorkContext.Resolve <IEmailsService>();
            var status  = service.CheckEmailExist(emailAddress);

            if (!status)
            {
                var email = new EmailInfo
                {
                    Email     = emailAddress,
                    FullName  = string.Empty,
                    IsBlocked = false,
                    Notes     = "Yêu cầu nhận gửi thông tin qua email."
                };
                service.Save(email);
            }

            model.Status = true;
            model.Data   = T("Đã lưu lại địa chỉ email của bạn thành công.");

            return(Json(model));
        }
Beispiel #7
0
        public ActionResult PaymentCompleted(string ordercode)
        {
            var model = new DataViewerModel();

            model.Status = false;
            model.Data   = "Thanh toán thất bại.";
            if (WorkContext.HttpContext.Session[Extensions.Constants.KeyOrderId] != null)
            {
                var currentOrderId = WorkContext.HttpContext.Session[Extensions.Constants.KeyOrderId].ToString();
                if (ordercode == currentOrderId)
                {
                    var orderService = WorkContext.Resolve <IOrdersService>();
                    var entity       = orderService.GetByOrderCode(ordercode);
                    if (entity != null)
                    {
                        entity.IsPaid = true;
                        entity.Notes  = "Đã thanh toán online thành công qua ngân lượng.";
                        orderService.Save(entity);
                        model.Status = true;
                        model.Data   = "Đã thanh toán online thành công qua ngân lượng. Vui lòng chờ nhận hàng từ chúng tôi.";
                    }
                }
            }

            return(View("PaymentCompleted", model));
        }
Beispiel #8
0
        public ActionResult GetProductDetails()
        {
            var productId     = Request.Form["ProductId"];
            var model         = new DataViewerModel();
            var seviceProduct = WorkContext.Resolve <IProductsService>();

            model.Product = seviceProduct.GetById(Convert.ToInt32(productId));
            return(Json(model));
        }
Beispiel #9
0
        private void BuildModule(int parentId, int id)
        {
            var widget       = WorkContext.Resolve <IWidgetService>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };
            var sectionBannerSliderService = WorkContext.Resolve <ISlidersService>();
            var imageService    = WorkContext.Resolve <IImagesService>();
            var articlesService = WorkContext.Resolve <IArticlesService>();

            articlesService.LanguageCode = WorkContext.CurrentCulture;

            #region SectionBannerSlider
            var modelSectionBannerSlider = new DataViewerModel();
            modelSectionBannerSlider.BannerImages = sectionBannerSliderService.GetRecords(x => x.Type == (int)PageSlider.Businesses).FirstOrDefault();
            var viewSectionBannerSlider = viewRenderer.RenderPartialView(Extensions.Constants.ViewPageBannerImage, modelSectionBannerSlider);
            WorkContext.Layout.SectionBannerSlider.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region SectionPageContent
            var modelSectionPageContent = new DataViewerModel();
            modelSectionPageContent.CategoryInfo = categoryService.GetByIdCache(id);
            BuildBreadcrumb(modelSectionPageContent);
            modelSectionPageContent.Articles           = articlesService.GetByCategoryId(parentId);
            modelSectionPageContent.ListCategoryImages = new Dictionary <ImageInfo, List <CategoryInfo> >();

            var settingsCust = WorkContext.Resolve <CustomSettings>();
            var listIds      = settingsCust.ListCategoriesBusinesses;
            var list         = imageService.GetCategoriesBusinesses(listIds);

            foreach (var item in list)
            {
                if (string.IsNullOrEmpty(item.ListCategory))
                {
                    continue;
                }
                var cates = categoryService.GetByListId(item.ListCategory, false);
                if (cates != null)
                {
                    var listCates = new List <CategoryInfo>();
                    foreach (var categoryInfo in cates)
                    {
                        var cate = categoryService.GetRecords(x => x.RefId == categoryInfo.Id && x.LanguageCode == WorkContext.CurrentCulture).FirstOrDefault();
                        if (cate != null)
                        {
                            listCates.Add(cate);
                        }
                    }
                    modelSectionPageContent.ListCategoryImages.Add(item, listCates);
                }
            }

            var viewSectionPageContent = viewRenderer.RenderPartialView(Extensions.Constants.ViewOurBusinesses, modelSectionPageContent);
            WorkContext.Layout.SectionPageContent.Add(new MvcHtmlString(viewSectionPageContent));
            #endregion
        }
Beispiel #10
0
        private void BuildModule(int cateRootId, int categoryId, int year = 0)
        {
            if (Request.QueryString["page"] != null)
            {
                PageIndex = int.Parse(Request.QueryString["page"]);
            }
            PageSize = 10;

            var widget       = WorkContext.Resolve <IWidgetService>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            var sectionBannerSliderService = WorkContext.Resolve <ISlidersService>();
            var articlesService            = WorkContext.Resolve <IArticlesService>();

            articlesService.LanguageCode = WorkContext.CurrentCulture;

            #region SectionBannerSlider
            var modelSectionBannerSlider = new DataViewerModel();
            modelSectionBannerSlider.BannerImages = sectionBannerSliderService.GetRecords(x => x.Type == (int)PageSlider.Media).FirstOrDefault();
            var viewSectionBannerSlider = viewRenderer.RenderPartialView(Extensions.Constants.ViewPageBannerImage, modelSectionBannerSlider);
            WorkContext.Layout.SectionBannerSlider.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region SectionPageContent
            var modelSectionPageContent = new DataViewerModel();
            modelSectionPageContent.CategoryInfo = categoryService.GetByIdCache(cateRootId);
            var category = categoryService.GetByIdCache(categoryId);
            modelSectionPageContent.ListCategories = categoryService.GetChildenByParentId(modelSectionPageContent.CategoryInfo.RefId);
            articlesService.CategoryId             = category.RefId;
            modelSectionPageContent.CategoryId     = categoryId;
            modelSectionPageContent.ListYear       = articlesService.GetAllYear().Select(x => x.Year).ToList();
            if (year == 0 && modelSectionPageContent.ListYear.Count > 0)
            {
                year = modelSectionPageContent.ListYear.FirstOrDefault();
            }
            modelSectionPageContent.Year = year;
            BuildBreadcrumb(modelSectionPageContent, categoryId, year);
            modelSectionPageContent.CategoryChilden = categoryService.GetByIdCache(categoryId);
            var total = 0;
            modelSectionPageContent.PageSize     = PageSize;
            modelSectionPageContent.PageIndex    = PageIndex;
            modelSectionPageContent.ListArticles = articlesService.GetMediaByCategoryId(year, PageIndex, PageSize, out total);
            modelSectionPageContent.TotalRow     = total;
            var viewSectionPageContent = viewRenderer.RenderPartialView(Extensions.Constants.ViewMedia, modelSectionPageContent);
            WorkContext.Layout.SectionPageContent.Add(new MvcHtmlString(viewSectionPageContent));
            #endregion
        }
        public void BuildPage(int categoryId, bool isShowPartner = false)
        {
            var widget       = WorkContext.Resolve <IWidgetService>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };
            var categoryService = WorkContext.Resolve <ICategoriesService>();

            categoryService.LanguageCode = WorkContext.CurrentCulture;
            var partnerService = WorkContext.Resolve <IPartnerService>();

            #region PageHeaderTop
            var modelPageHeaderTop = new DataViewerModel();
            var languageService    = WorkContext.Resolve <ILanguageService>();
            modelPageHeaderTop.ListLanguages = languageService.GetRecords().Where(x => !x.IsBlocked).ToList();
            var viewPageHeaderTop = viewRenderer.RenderPartialView(Extensions.Constants.ViewPageHeaderTop, modelPageHeaderTop);
            WorkContext.Layout.PageHeaderTop.Add(new MvcHtmlString(viewPageHeaderTop));
            #endregion

            #region PageNavigationMenu
            var modelPageNavigationMenu = new DataViewerModel();
            modelPageNavigationMenu.CategoryId           = categoryId;
            modelPageNavigationMenu.ListCategoriesParent = categoryService.GetRecords(x => x.IsActived && !x.IsDeleted && x.IsDisplayMenu && x.ParentId == 0 && x.LanguageCode == WorkContext.CurrentCulture).OrderBy(x => x.OrderBy).ToList();
            modelPageNavigationMenu.ListCategories       = categoryService.GetRecords(x => x.IsActived && !x.IsDeleted && x.IsDisplayMenu && x.ParentId > 0 && x.LanguageCode == WorkContext.CurrentCulture);
            var viewPageNavigationMenu = viewRenderer.RenderPartialView(Extensions.Constants.ViewPageNavigationMenu, modelPageNavigationMenu);
            WorkContext.Layout.PageNavigationMenu.Add(new MvcHtmlString(viewPageNavigationMenu));
            #endregion

            #region SectionClient
            var modelSectionClient = new DataViewerModel();
            modelSectionClient.IsShowPartner = isShowPartner;
            var catePartner = categoryService.GetRecords(x => x.RefId == (int)CategoriesType.Partner && x.LanguageCode == WorkContext.CurrentCulture).FirstOrDefault();
            if (catePartner != null)
            {
                modelSectionClient.CategoryInfo = catePartner;
            }
            modelSectionClient.ListPartners = partnerService.GetRecords(x => !x.IsDeleted && x.LanguageCode == WorkContext.CurrentCulture).OrderBy(x => x.SortOrder).ToList();
            var viewSectionClient = viewRenderer.RenderPartialView(Extensions.Constants.ViewSectionClient, modelSectionClient);
            WorkContext.Layout.SectionClient.Add(new MvcHtmlString(viewSectionClient));
            #endregion

            #region PageFooter
            var modelPageFooter = new DataViewerModel();
            modelPageFooter.ListCategories = categoryService.GetRecords(x => x.IsActived && !x.IsDeleted && x.LanguageCode == WorkContext.CurrentCulture && x.IsDisplayFooter).OrderBy(x => x.OrderBy).ToList();
            var viewPageFooter = viewRenderer.RenderPartialView(Extensions.Constants.ViewPageFooter, modelPageFooter);
            WorkContext.Layout.PageFooter.Add(new MvcHtmlString(viewPageFooter));
            #endregion
        }
Beispiel #12
0
        public ActionResult Index()
        {
            var categoryService = WorkContext.Resolve <ICategoriesService>();

            categoryService.LanguageCode = WorkContext.CurrentCulture;
            var category = categoryService.GetHomePage();

            if (category != null)
            {
                ViewData[Extensions.Constants.SeoTitle]       = category.Name;
                ViewData[Extensions.Constants.SeoKeywords]    = category.Tags;
                ViewData[Extensions.Constants.SeoDescription] = category.Description;
            }

            var setting      = WorkContext.Resolve <CommonSettings>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            #region SectionBannerSlider
            var modelSectionBannerSlider = new DataViewerModel();
            var service = WorkContext.Resolve <IBannersService>();
            modelSectionBannerSlider.ListBannerImages = service.GetRecords(x => x.LanguageCode == WorkContext.CurrentCulture && x.CategoryId == category.Id).OrderBy(x => x.SortOrder).ToList();
            modelSectionBannerSlider.Settings         = setting;
            var viewSectionBannerSlider = viewRenderer.RenderPartialView("~/Views/Shared/SliderBanners.cshtml", modelSectionBannerSlider);
            WorkContext.Layout.SectionBanner.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region Products
            var modelProducts      = new DataViewerModel();
            var seviceProductGroup = WorkContext.Resolve <IProductsGroupService>();
            modelProducts.ListProductGroup = seviceProductGroup.GetRecords().OrderBy(x => x.GroupName).ToList();
            modelProducts.Settings         = setting;
            var viewSectionProducts = viewRenderer.RenderPartialView("~/Views/Shared/PageProducts.cshtml", modelProducts);
            WorkContext.Layout.SectionProducts.Add(new MvcHtmlString(viewSectionProducts));
            #endregion

            #region News
            var modelNews   = new DataViewerModel();
            var serviceNews = WorkContext.Resolve <IArticlesService>();
            var list        = serviceNews.GetRecords(x => x.IsPublished).OrderBy(x => x.Id).ToList();
            modelNews.Data = BuildHtml(list, setting);
            var viewSectionNews = viewRenderer.RenderPartialView("~/Views/Shared/PageBlog.cshtml", modelNews);
            WorkContext.Layout.SectionBlog.Add(new MvcHtmlString(viewSectionNews));
            #endregion

            return(View("Empty"));
        }
        private void BuildModule(string keyword)
        {
            if (Request.QueryString["page"] != null)
            {
                PageIndex = int.Parse(Request.QueryString["page"]);
            }
            PageSize = 10;

            var widget       = WorkContext.Resolve <IWidgetService>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            var sectionBannerSliderService = WorkContext.Resolve <ISlidersService>();
            var searchService = WorkContext.Resolve <ISearchService>();

            searchService.LanguageCode = WorkContext.CurrentCulture;

            #region SectionBannerSlider
            var modelSectionBannerSlider = new DataViewerModel();
            modelSectionBannerSlider.BannerImages = sectionBannerSliderService.GetRecords(x => x.Type == (int)PageSlider.Media).FirstOrDefault();
            var viewSectionBannerSlider = viewRenderer.RenderPartialView(Extensions.Constants.ViewPageBannerImage, modelSectionBannerSlider);
            WorkContext.Layout.SectionBannerSlider.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region SectionPageContent
            var modelSectionPageContent = new DataViewerModel();
            BuildBreadcrumb(modelSectionPageContent, -1);
            var condition = new List <SearchCondition>
            {
                new SearchCondition(new[]
                {
                    SearchField.Title.ToString(),
                    SearchField.Keyword.ToString(),
                    SearchField.Sumary.ToString()
                }, keyword)
            };
            var total = 0;
            modelSectionPageContent.PageSize   = PageSize;
            modelSectionPageContent.PageIndex  = PageIndex;
            modelSectionPageContent.ListSearch = searchService.Search(condition, PageIndex, PageSize, ref total);
            modelSectionPageContent.TotalRow   = total;
            modelSectionPageContent.Keyword    = keyword;
            var viewSectionPageContent = viewRenderer.RenderPartialView(Extensions.Constants.ViewSearchResults, modelSectionPageContent);
            WorkContext.Layout.SectionPageContent.Add(new MvcHtmlString(viewSectionPageContent));
            #endregion
        }
Beispiel #14
0
        public ActionResult ContactInformations()
        {
            var email       = Request.Form["txtEmail"];
            var fullName    = Request.Form["txtFullName"];
            var phoneNumber = Request.Form["txtPhoneNumber"];
            var messages    = Request.Form["txtMessages"];

            var result      = new DataViewerModel();
            var htmlBuilder = new StringBuilder();

            htmlBuilder.Append("<div style=\"float:left;width:100%;\">");
            htmlBuilder.AppendFormat("<div style=\"float:left;\">{0} </div>", T("Họ và Tên:"));
            htmlBuilder.AppendFormat("<div style=\"float:left;margin-left:5px;\">{0}</div>", fullName);
            htmlBuilder.Append("</div><br>");

            htmlBuilder.Append("<div style=\"float:left;width:100%;\">");
            htmlBuilder.AppendFormat("<div style=\"float:left;\">{0} </div>", T("Số điện thoại:"));
            htmlBuilder.AppendFormat("<div style=\"float:left;margin-left:5px;\">{0}</div>", phoneNumber);
            htmlBuilder.Append("</div><br>");

            htmlBuilder.Append("<div style=\"float:left;width:100%;\">");
            htmlBuilder.AppendFormat("<div style=\"float:left;\">{0} </div>", T("Địa chỉ email:"));
            htmlBuilder.AppendFormat("<div style=\"float:left;margin-left:5px;\">{0}</div>", email);
            htmlBuilder.Append("</div><br>");

            htmlBuilder.Append("<div style=\"float:left;width:100%;\">");
            htmlBuilder.AppendFormat("<div style=\"float:left;\">{0} </div>", T("Yêu cầu của bạn:"));
            htmlBuilder.AppendFormat("<div style=\"float:left;margin-left:5px;\">{0}</div>", messages);
            htmlBuilder.Append("</div><br>");

            string html = System.IO.File.ReadAllText(Server.MapPath("~/Media/Default/EmailTemplates/ContactInfo.html"));

            html = html.Replace("[MAILBODY]", htmlBuilder.ToString());
            try
            {
                SendEmail(T("Thông tin liên hệ"), html, email, string.Empty);
                result.Status = true;
                result.Data   = T("Gửi thành công.");
            }
            catch (Exception ex)
            {
                result.Status = false;
                result.Data   = ex.Message;
            }

            return(Json(result));
        }
Beispiel #15
0
        public void SendOrder(int orderId)
        {
            var serviceOrder        = WorkContext.Resolve <IOrdersService>();
            var serviceOrderDetails = WorkContext.Resolve <IOrderDetailsService>();
            var order = serviceOrder.GetById(orderId);
            var list  = serviceOrderDetails.GetRecords(x => x.OrderId == orderId).ToList();

            if (order != null && list.Count > 0)
            {
                var result      = new DataViewerModel();
                var htmlBuilder = new StringBuilder();
                var total       = 0;
                foreach (var orderDetailsInfo in list)
                {
                    htmlBuilder.Append("<tr>");
                    htmlBuilder.AppendFormat("<td>{0}</td>", orderDetailsInfo.ProductName);
                    htmlBuilder.AppendFormat("<td>{0}</td>", orderDetailsInfo.Capacity);
                    htmlBuilder.AppendFormat("<td>{0}</td>", orderDetailsInfo.Quantity);
                    htmlBuilder.AppendFormat("<td>{0}</td>", Utilities.GetCurrency(orderDetailsInfo.Price.ToString()));
                    htmlBuilder.AppendFormat("<td>{0}</td>", Utilities.GetCurrency(orderDetailsInfo.Total.ToString()));
                    htmlBuilder.Append("</tr>");
                    total += orderDetailsInfo.Total;
                }
                string html = System.IO.File.ReadAllText(Server.MapPath("~/Media/Default/EmailTemplates/ShoppingCartInfo.html"));
                html = html.Replace("[FULLNAME]", order.FullName);
                html = html.Replace("[PHONENUMBER]", order.PhoneNumber);
                html = html.Replace("[EMAILADDRESS]", order.Email);
                html = html.Replace("[PAYMENTTYPE]", CMSSolutions.Extensions.EnumExtensions.GetDisplayName((PaymentType)order.PaymentType));
                html = html.Replace("[DELIVERYTIME]", order.DeliveryTime);
                html = html.Replace("[DELIVERYADDRESS]", order.DeliveryPlace);
                html = html.Replace("[ORDERCODE]", order.OrderCode);
                html = html.Replace("[PRODUCTBODY]", htmlBuilder.ToString());
                html = html.Replace("[TOTALMONEY]", Utilities.GetCurrency(total.ToString()));
                try
                {
                    SendEmail(T("Thông tin đơn hàng mật ong QHoney"), html, order.Email, string.Empty);
                    result.Status = true;
                    result.Data   = T("Gửi thành công.");
                }
                catch (Exception ex)
                {
                    result.Status = false;
                    result.Data   = ex.Message;
                }
            }
        }
Beispiel #16
0
        private void AddModules()
        {
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            #region Product
            var modelCart    = new DataViewerModel();
            var listProducts = new List <CartInfo>();
            if (WorkContext.HttpContext.Session[Extensions.Constants.KeyDataCart] != null)
            {
                listProducts = (List <CartInfo>)WorkContext.HttpContext.Session[Extensions.Constants.KeyDataCart];
            }
            modelCart.ListCart = listProducts;
            var viewSectionNews = viewRenderer.RenderPartialView("~/Views/Shared/ConfirmCart.cshtml", modelCart);
            WorkContext.Layout.SectionProducts.Add(new MvcHtmlString(viewSectionNews));
            #endregion
        }
Beispiel #17
0
        private void ViewMediaDetails(ArticlesInfo articles)
        {
            var widget       = WorkContext.Resolve <IWidgetService>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            var sectionBannerSliderService = WorkContext.Resolve <ISlidersService>();
            var articlesService            = WorkContext.Resolve <IArticlesService>();

            articlesService.LanguageCode = WorkContext.CurrentCulture;

            #region SectionBannerSlider
            var modelSectionBannerSlider = new DataViewerModel();
            modelSectionBannerSlider.BannerImages = sectionBannerSliderService.GetRecords(x => x.Type == (int)PageSlider.MediaDetails).FirstOrDefault();
            var viewSectionBannerSlider = viewRenderer.RenderPartialView(Extensions.Constants.ViewPageBannerImage, modelSectionBannerSlider);
            WorkContext.Layout.SectionBannerSlider.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region SectionPageContent
            var modelSectionPageContent = new DataViewerModel();
            var custSetting             = WorkContext.Resolve <CustomSettings>();
            modelSectionPageContent.CategoryInfo = categoryService.GetRecords(x => x.RefId == custSetting.CategoryRootMedia && x.LanguageCode == WorkContext.CurrentCulture).FirstOrDefault();
            if (modelSectionPageContent.CategoryInfo != null)
            {
                modelSectionPageContent.ListCategories = categoryService.GetChildenByParentId(modelSectionPageContent.CategoryInfo.RefId);
            }

            var cate = categoryService.GetRecords(x => x.RefId == articles.CategoryId && x.LanguageCode == WorkContext.CurrentCulture).FirstOrDefault();
            if (cate != null)
            {
                articlesService.CategoryId         = cate.Id;
                modelSectionPageContent.CategoryId = cate.Id;
                BuildBreadcrumb(modelSectionPageContent, cate.Id, articles.Year);
                modelSectionPageContent.CategoryInfo = cate;
            }

            modelSectionPageContent.Year         = articles.Year;
            modelSectionPageContent.Articles     = articlesService.GetById(articles.Id);
            modelSectionPageContent.ListArticles = articlesService.GetMediaCountTop(articles.Year, articles.Id, 5);
            var viewSectionPageContent = viewRenderer.RenderPartialView(Extensions.Constants.ViewMediaDetails, modelSectionPageContent);
            WorkContext.Layout.SectionPageContent.Add(new MvcHtmlString(viewSectionPageContent));
            #endregion
        }
        public ActionResult Index(string categoryAlias)
        {
            var categoryService = WorkContext.Resolve <ICategoriesService>();

            categoryService.LanguageCode = WorkContext.CurrentCulture;
            var category = categoryService.GetByAlias(categoryAlias, WorkContext.CurrentCulture);

            if (category != null)
            {
                ViewData[Extensions.Constants.SeoTitle]       = category.Name;
                ViewData[Extensions.Constants.SeoKeywords]    = category.Tags;
                ViewData[Extensions.Constants.SeoDescription] = category.Description;

                var viewRenderer = new ViewRenderer {
                    Context = ControllerContext
                };
                if (Request.QueryString["trang"] != null)
                {
                    PageIndex = int.Parse(Request.QueryString["trang"]);
                }
                PageSize = 3;

                #region News
                var modelNews   = new DataViewerModel();
                var serviceNews = WorkContext.Resolve <IArticlesService>();
                var setting     = WorkContext.Resolve <CommonSettings>();
                modelNews.Settings = setting;
                var total = 0;
                var list  = serviceNews.GetRecords(PageIndex, PageSize, out total, x => x.CategoryId == category.Id && x.IsPublished).OrderBy(x => x.Id).ToList();
                foreach (var articlesInfo in list)
                {
                    articlesInfo.CategoryAlias = category.Alias;
                }
                modelNews.ListArticles = list;
                modelNews.TotalRow     = total;
                modelNews.PageIndex    = PageIndex;
                modelNews.PageSize     = PageSize;
                var viewSectionNews = viewRenderer.RenderPartialView("~/Views/Shared/ListNews.cshtml", modelNews);
                WorkContext.Layout.SectionBlog.Add(new MvcHtmlString(viewSectionNews));
                #endregion
            }

            return(View("Empty"));
        }
Beispiel #19
0
        public ActionResult ProductDetails(string alias)
        {
            var seviceProductGroup = WorkContext.Resolve <IProductsGroupService>();
            var group = seviceProductGroup.GetRecords(x => x.Alias == alias).FirstOrDefault();

            if (group != null)
            {
                ViewData[Extensions.Constants.SeoTitle]       = group.GroupName;
                ViewData[Extensions.Constants.SeoKeywords]    = group.GroupName;
                ViewData[Extensions.Constants.SeoDescription] = group.GroupName;
            }

            var setting      = WorkContext.Resolve <CommonSettings>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            #region Products
            var seviceProduct     = WorkContext.Resolve <IProductsService>();
            var seviceProductType = WorkContext.Resolve <IProductVolumeService>();
            var list = seviceProduct.GetRecords(x => x.GroupId == group.Id).OrderBy(x => x.Type).ToList();
            if (list.Count > 0 && group != null)
            {
                foreach (var productInfo in list)
                {
                    var type = seviceProductType.GetById(productInfo.Type);
                    productInfo.GroupName    = group.GroupName;
                    productInfo.CapacityName = type.Name;
                }
            }
            var modelProducts = new DataViewerModel
            {
                ProductGroup = group,
                Settings     = setting,
                Products     = list
            };
            var viewSectionProducts = viewRenderer.RenderPartialView("~/Views/Shared/ProductDetails.cshtml", modelProducts);
            WorkContext.Layout.SectionProducts.Add(new MvcHtmlString(viewSectionProducts));
            #endregion

            return(View("Empty"));
        }
        private void BuildModule(int id)
        {
            var widget       = WorkContext.Resolve <IWidgetService>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            #region SectionBannerSlider
            var viewSectionBannerSlider = viewRenderer.RenderPartialView(Extensions.Constants.ViewGoogleMap, null);
            WorkContext.Layout.SectionBannerSlider.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region SectionPageContent
            var modelSectionPageContent = new DataViewerModel();
            modelSectionPageContent.CategoryInfo = categoryService.GetByIdCache(id);
            BuildBreadcrumb(modelSectionPageContent);
            var viewSectionPageContent = viewRenderer.RenderPartialView(Extensions.Constants.ViewContact, modelSectionPageContent);
            WorkContext.Layout.SectionPageContent.Add(new MvcHtmlString(viewSectionPageContent));
            #endregion
        }
Beispiel #21
0
        public ActionResult Index()
        {
            var categoryService = WorkContext.Resolve <ICategoriesService>();

            categoryService.LanguageCode = WorkContext.CurrentCulture;
            var category = categoryService.GetById((int)Category.Product);

            if (category != null)
            {
                ViewData[Extensions.Constants.SeoTitle]       = category.Name;
                ViewData[Extensions.Constants.SeoKeywords]    = category.Tags;
                ViewData[Extensions.Constants.SeoDescription] = category.Description;
            }

            var setting      = WorkContext.Resolve <CommonSettings>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            #region SectionBannerSlider
            var modelSectionBannerSlider = new DataViewerModel();
            var service = WorkContext.Resolve <IBannersService>();
            modelSectionBannerSlider.Banner = service.GetRecords(x => x.LanguageCode == WorkContext.CurrentCulture && x.CategoryId == category.Id).FirstOrDefault();
            var viewSectionBannerSlider = viewRenderer.RenderPartialView("~/Views/Shared/ProductBanner.cshtml", modelSectionBannerSlider);
            WorkContext.Layout.SectionBanner.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region Products
            var modelProducts = new DataViewerModel();
            var seviceProduct = WorkContext.Resolve <IProductsGroupService>();
            modelProducts.ListProductGroup = seviceProduct.GetRecords().OrderBy(x => x.GroupName).ToList();
            modelProducts.Settings         = setting;
            var viewSectionProducts = viewRenderer.RenderPartialView("~/Views/Shared/PageListProducts.cshtml", modelProducts);
            WorkContext.Layout.SectionProducts.Add(new MvcHtmlString(viewSectionProducts));
            #endregion

            return(View("Empty"));
        }
Beispiel #22
0
        public ActionResult AddToCart()
        {
            var model  = new DataViewerModel();
            var status = UpdateShoppingCart();

            if (status == -1)
            {
                model.Status = false;
                model.Data   = T("Thêm sản phẩm vào giỏ hàng thất bại.");
            }
            if (status == 2)
            {
                model.Status = false;
                model.Data   = T("Bạn vui lòng nhập số lượng sản phẩm cần mua.");
            }
            if (status == 0)
            {
                model.Status = true;
                model.Data   = T("Đã thêm sản phẩm vào giỏ hàng thành công.");
            }

            return(Json(model));
        }
        public ActionResult Index()
        {
            var categoryService = WorkContext.Resolve <ICategoriesService>();

            categoryService.LanguageCode = WorkContext.CurrentCulture;
            var category = categoryService.GetById((int)Category.About);

            if (category != null)
            {
                ViewData[Extensions.Constants.SeoTitle]       = category.Name;
                ViewData[Extensions.Constants.SeoKeywords]    = category.Tags;
                ViewData[Extensions.Constants.SeoDescription] = category.Description;
            }

            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };

            #region SectionBannerSlider
            var modelSectionBannerSlider = new DataViewerModel();
            var service = WorkContext.Resolve <IBannersService>();
            modelSectionBannerSlider.Banner = service.GetRecords(x => x.LanguageCode == WorkContext.CurrentCulture && x.CategoryId == category.Id).FirstOrDefault();
            var viewSectionBannerSlider = viewRenderer.RenderPartialView("~/Views/Shared/PageBannerImage.cshtml", modelSectionBannerSlider);
            WorkContext.Layout.SectionBanner.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region News
            var modelNews   = new DataViewerModel();
            var serviceNews = WorkContext.Resolve <IArticlesService>();
            var list        = serviceNews.GetRecords(x => x.CategoryId == category.Id).OrderBy(x => x.Id).ToList();
            modelNews.ListArticles = list;
            var viewSectionNews = viewRenderer.RenderPartialView("~/Views/Shared/PageAbout.cshtml", modelNews);
            WorkContext.Layout.SectionBlog.Add(new MvcHtmlString(viewSectionNews));
            #endregion

            return(View("Empty"));
        }
Beispiel #24
0
        public ActionResult PaymentConfirm()
        {
            var model = new DataViewerModel();

            if (WorkContext.HttpContext.Session[Extensions.Constants.KeyDataCart] != null)
            {
                var txtCartFullName        = Request.Form["txtCartFullName"];
                var txtCartEmail           = Request.Form["txtCartEmail"];
                var txtCartSoDienThoai     = Request.Form["txtCartSoDienThoai"];
                var ddlPaymentType         = Request.Form["ddlPaymentType"];
                var txtCartDeliveryTime    = Request.Form["txtCartDeliveryTime"];
                var txtCartDeliveryAddress = Request.Form["txtCartDeliveryAddress"];
                var orderId = 0;
                if (WorkContext.HttpContext.Session[Extensions.Constants.KeyOrderId] != null)
                {
                    orderId = Convert.ToInt32(WorkContext.HttpContext.Session[Extensions.Constants.KeyOrderId]);
                }
                var order = new OrderInfo
                {
                    Id                   = orderId,
                    OrderCode            = "QH" + DateTime.Now.ToString(Extensions.Constants.DateTimeFomatFullNone),
                    FullName             = txtCartFullName,
                    PhoneNumber          = txtCartSoDienThoai,
                    Email                = txtCartEmail,
                    DeliveryTime         = txtCartDeliveryTime,
                    DeliveryPlace        = txtCartDeliveryAddress,
                    PaymentType          = Convert.ToInt32(ddlPaymentType),
                    PaymentCode          = string.Empty,
                    CreateDate           = DateTime.Now,
                    Notes                = string.Empty,
                    IsPaid               = false,
                    IsDeliverySuccessful = false
                };

                var listProducts = (List <CartInfo>)WorkContext.HttpContext.Session[Extensions.Constants.KeyDataCart];

                var orderService        = WorkContext.Resolve <IOrdersService>();
                var orderDetailsService = WorkContext.Resolve <IOrderDetailsService>();
                orderService.Save(order);
                orderId = order.Id;
                WorkContext.HttpContext.Session[Extensions.Constants.KeyOrderId] = orderId;
                var total = 0;
                foreach (var item in listProducts)
                {
                    var info = new OrderDetailsInfo
                    {
                        OrderId     = orderId,
                        ProductId   = item.ProductId,
                        ProductName = item.ProductName,
                        Capacity    = item.Capacity,
                        Quantity    = item.Quantity,
                        Price       = item.Price,
                        Total       = item.Price * item.Quantity
                    };
                    total += info.Total;
                    orderDetailsService.Save(info);
                }

                SendOrder(orderId);
                var type = (PaymentType)order.PaymentType;
                if (type == PaymentType.PaymentWhenReceive)
                {
                    model.Status      = true;
                    model.PaymentType = order.PaymentType;
                    model.Data        = T("Đã gửi đơn hàng của bạn tới chúng tôi thành công vui lòng kiểm tra email của bạn.");
                    model.Url         = Url.Action("Index", "Product");
                }

                if (type == PaymentType.PaymentOnline)
                {
                    model.Status      = true;
                    model.PaymentType = order.PaymentType;
                    model.Data        = T("Đã gửi đơn hàng của bạn tới chúng tôi thành công vui lòng kiểm tra email của bạn. Để thanh toán online hãy nhấn vào nút dưới đây.");
                    model.Url         = string.Format("https://www.nganluong.vn/button_payment.php?receiver={0}&product_name={1}&price={2}&return_url={3}&comments={4}",
                                                      "*****@*****.**",
                                                      order.OrderCode,
                                                      total,
                                                      Request.Url.Scheme + "://" + Request.Url.Authority + Url.Action("PaymentCompleted", "Payment", new { @ordercode = order.OrderCode }),
                                                      order.DeliveryTime + " " + order.DeliveryPlace);
                }
            }
            else
            {
                model.Status = false;
                model.Data   = T("Giỏ hàng của bạn không có sản phẩm.");
                model.Url    = Url.Action("Index", "Product");
            }

            return(Json(model));
        }
        protected void BuildBreadcrumb(DataViewerModel model, int categoryId = 0, int year = 0)
        {
            model.Breadcrumb = new StringBuilder();
            var categoryService = WorkContext.Resolve <ICategoriesService>();

            categoryService.LanguageCode = WorkContext.CurrentCulture;
            var categoryHome = categoryService.GetHomePage();

            model.Breadcrumb.Append("<ol class=\"breadcrumb\">");
            model.Breadcrumb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", categoryHome.Url, categoryHome.ShortName);
            if (categoryId > 0)
            {
                var cate = categoryService.GetByIdCache(categoryId);
                if (cate.ParentId > 0)
                {
                    var parent = categoryService.GetByIdCache(cate.ParentId);
                    if (parent != null)
                    {
                        var children = categoryService.GetByIdCache(parent.ParentId);
                        if (children != null)
                        {
                            model.Breadcrumb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", children.Url, children.ShortName);
                        }
                        model.Breadcrumb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", parent.Url, parent.ShortName);
                    }
                }

                if (year > 0)
                {
                    model.Breadcrumb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", Url.Action("Index", "HomeMediaNews", new { alias = cate.Alias }), cate.ShortName);
                    var url = Url.Action("MediaCategory", "HomeMediaNews", new { alias = cate.Alias, year = year });
                    model.Breadcrumb.AppendFormat("<li class=\"active\"><a href=\"{0}\">{1}</a></li>", url, year);
                }
                else
                {
                    model.Breadcrumb.AppendFormat("<li class=\"active\"><a href=\"{0}\">{1}</a></li>", cate.Url, cate.ShortName);
                }
            }
            else
            {
                if (categoryId == -1)
                {
                    model.Breadcrumb.AppendFormat("<li class=\"active\"><a href=\"#\">{0}</a></li>", T("Search"));
                }
                else
                {
                    if (model.CategoryInfo.ParentId > 0)
                    {
                        var parent = categoryService.GetByIdCache(model.CategoryInfo.ParentId);
                        if (parent != null)
                        {
                            var children = categoryService.GetByIdCache(parent.ParentId);
                            if (children != null)
                            {
                                model.Breadcrumb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", children.Url, children.ShortName);
                            }
                            model.Breadcrumb.AppendFormat("<li><a href=\"{0}\">{1}</a></li>", parent.Url, parent.ShortName);
                        }
                    }
                    model.Breadcrumb.AppendFormat("<li class=\"active\"><a href=\"{0}\">{1}</a></li>", model.CategoryInfo.Url, model.CategoryInfo.ShortName);
                }
            }
            model.Breadcrumb.Append("</ol>");
        }
        private void BuildModule()
        {
            var widget       = WorkContext.Resolve <IWidgetService>();
            var viewRenderer = new ViewRenderer {
                Context = ControllerContext
            };
            var categoryService = WorkContext.Resolve <ICategoriesService>();

            categoryService.LanguageCode = WorkContext.CurrentCulture;

            #region SectionBannerSlider
            var modelSectionBannerSlider   = new DataViewerModel();
            var sectionBannerSliderService = WorkContext.Resolve <ISlidersService>();
            modelSectionBannerSlider.ListSliderImages = sectionBannerSliderService.GetRecords(x => x.Type == (int)PageSlider.HomeBannerSlider).OrderBy(x => x.SortOrder).ToList();
            var viewSectionBannerSlider = viewRenderer.RenderPartialView(Extensions.Constants.ViewSectionBannerSlider, modelSectionBannerSlider);
            WorkContext.Layout.SectionBannerSlider.Add(new MvcHtmlString(viewSectionBannerSlider));
            #endregion

            #region SectionAbout

            var settings          = WorkContext.Resolve <CustomSettings>();
            var cateAboutUs       = categoryService.GetRecords(x => x.LanguageCode == WorkContext.CurrentCulture && x.RefId == settings.CategoryAboutUs).FirstOrDefault();
            var modelSectionAbout = new DataViewerModel();
            if (cateAboutUs != null)
            {
                modelSectionAbout.CategoryInfo = cateAboutUs;
            }
            var viewSectionAbout = viewRenderer.RenderPartialView(Extensions.Constants.ViewSectionAbout, modelSectionAbout);
            WorkContext.Layout.SectionAbout.Add(new MvcHtmlString(viewSectionAbout));
            #endregion

            #region SectionBusinesses
            var modelSectionBusinesses = new DataViewerModel();
            var cateBusinesses         = categoryService.GetRecords(x => x.LanguageCode == WorkContext.CurrentCulture && x.RefId == settings.CategoryBusinesses).FirstOrDefault();
            if (cateBusinesses != null)
            {
                modelSectionBusinesses.CategoryInfo = cateBusinesses;
            }
            modelSectionBusinesses.ListCategoryImages = new Dictionary <ImageInfo, List <CategoryInfo> >();

            var settingsCust = WorkContext.Resolve <CustomSettings>();
            var listIds      = settingsCust.ListCategoriesBusinesses;
            var imageService = WorkContext.Resolve <IImagesService>();
            var list         = imageService.GetCategoriesBusinesses(listIds);

            foreach (var item in list)
            {
                if (string.IsNullOrEmpty(item.ListCategory))
                {
                    continue;
                }
                var cates = categoryService.GetByListId(item.ListCategory, false);
                if (cates != null)
                {
                    var listCates = new List <CategoryInfo>();
                    foreach (var categoryInfo in cates)
                    {
                        var cate = categoryService.GetRecords(x => x.RefId == categoryInfo.Id && x.LanguageCode == WorkContext.CurrentCulture).FirstOrDefault();
                        if (cate != null)
                        {
                            listCates.Add(cate);
                        }
                    }
                    modelSectionBusinesses.ListCategoryImages.Add(item, listCates);
                }
            }
            var viewSectionBusinesses = viewRenderer.RenderPartialView(Extensions.Constants.ViewSectionBusinesses, modelSectionBusinesses);
            WorkContext.Layout.SectionBusinesses.Add(new MvcHtmlString(viewSectionBusinesses));
            #endregion
        }