Ejemplo n.º 1
0
        public ActionResult SendFeedback(FeedbackViewModel feedbackVM)
        {
            if (ModelState.IsValid)
            {
                var feedback = Mapper.Map <Feedback>(feedbackVM);
                feedback.CreatedDate = DateTime.Now;
                _feedbackService.Create(feedback);
                _feedbackService.Save();

                ViewData[Constant.ViewData_SuccessMsg] = ResourceManagement.GetResourceText(Constant.Resource_SendFeedbackSuccess);

                string content = System.IO.File.ReadAllText(Server.MapPath(Constant.Path_ContactTemplate));
                content = content.Replace("{{Name}}", feedbackVM.Name);
                content = content.Replace("{{Email}}", feedbackVM.Email);
                content = content.Replace("{{Message}}", feedbackVM.Message);
                var adminEmail = ConfigHelperUtility.GetByKey(Constant.AppSetting_AdminEmail);
                MailHelperUtility.SendMail(adminEmail, ResourceManagement.GetResourceText(Constant.Resource_ContactInformationFromWebsite), content);

                feedbackVM.Name    = string.Empty;
                feedbackVM.Message = string.Empty;
                feedbackVM.Email   = string.Empty;
            }
            feedbackVM.ContactDetail = GetDetail();

            return(View(Constant.Action_Index, feedbackVM));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var userByEmail = await _userManager.FindByEmailAsync(model.Email);

                if (userByEmail != null)
                {
                    ModelState.AddModelError(Constant.ModelError_Email, ResourceManagement.GetResourceText(Constant.Resource_UserExisted));
                    return(View(model));
                }
                var userByUserName = await _userManager.FindByNameAsync(model.UserName);

                if (userByUserName != null)
                {
                    ModelState.AddModelError(Constant.ModelError_Email, ResourceManagement.GetResourceText(Constant.Resource_UserExisted));
                    return(View(model));
                }
                var user = new ApplicationUser()
                {
                    UserName       = model.UserName,
                    Email          = model.Email,
                    EmailConfirmed = true,
                    Birthday       = DateTime.Now,
                    FullName       = model.FullName,
                    PhoneNumber    = model.PhoneNumber,
                    Address        = model.Address
                };

                await _userManager.CreateAsync(user, model.Password);


                var adminUser = await _userManager.FindByEmailAsync(model.Email);

                if (adminUser != null)
                {
                    await _userManager.AddToRolesAsync(adminUser.Id, new string[] { Constant.Role_User });
                }

                string content = System.IO.File.ReadAllText(Server.MapPath(Constant.Path_NewUserTemplate));
                content = content.Replace("{{UserName}}", adminUser.FullName);
                content = content.Replace("{{Link}}", ConfigHelperUtility.GetByKey(Constant.AppSetting_CurrentLink) + "dang-nhap.html");

                MailHelperUtility.SendMail(adminUser.Email, ResourceManagement.GetResourceText(Constant.Resource_RegisterSuccessfully), content);


                ViewData[Constant.ViewData_SuccessMsg] = ResourceManagement.GetResourceText(Constant.Resource_RegisterSuccessfully);
            }

            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult Search(string keyword, int page = 1, AppValue.SortProduct sort = AppValue.SortProduct.New)
        {
            int pageSize  = int.Parse(ConfigHelperUtility.GetByKey(Constant.AppSetting_PageSize));
            int totalRow  = 0;
            var product   = _productService.Search(keyword, page, pageSize, sort, out totalRow);
            var productVM = Mapper.Map <List <ProductViewModel> >(product);
            int totalPage = (totalRow % pageSize == 0) ? (totalRow / pageSize) : (totalRow / pageSize) + 1;

            ViewBag.Keyword = keyword;
            var paginationSet = new PaginationSet <ProductViewModel>()
            {
                Items      = productVM,
                MaxPage    = int.Parse(ConfigHelperUtility.GetByKey(Constant.AppSetting_MaxPage)),
                Page       = page,
                TotalCount = totalRow,
                TotalPages = totalPage
            };

            return(View(paginationSet));
        }
Ejemplo n.º 4
0
        public ActionResult Detail(int id)
        {
            var product   = _productService.GetById(id);
            var productVM = Mapper.Map <ProductViewModel>(product);

            var topRelatedProduct = int.Parse(ConfigHelperUtility.GetByKey(Constant.AppSetting_TopRelatedProduct));
            var relatedProducts   = _productService.GetRelatedProducts(product.ID, topRelatedProduct);

            ViewBag.RelatedProducts = Mapper.Map <List <ProductViewModel> >(relatedProducts);

            List <string> listImages = new JavaScriptSerializer().Deserialize <List <string> >(productVM.MoreImage);

            ViewBag.MoreImages = listImages;

            var tags = _productService.GetListTagByProductId(product.ID);

            ViewBag.Tags = Mapper.Map <IEnumerable <TagViewModel> >(tags);

            return(View(productVM));
        }
Ejemplo n.º 5
0
        public ActionResult Category(int id, int page = 1, AppValue.SortProduct sort = AppValue.SortProduct.New)
        {
            int pageSize  = int.Parse(ConfigHelperUtility.GetByKey(Constant.AppSetting_PageSize));
            int totalRow  = 0;
            var product   = _productService.GetListProductByCategoryIdPaging(id, page, pageSize, sort, out totalRow);
            var productVM = Mapper.Map <List <ProductViewModel> >(product);
            int totalPage = (totalRow % pageSize == 0) ? (totalRow / pageSize) : (totalRow / pageSize) + 1;

            var category = _productCategoryService.GetById(id);

            ViewBag.Category = Mapper.Map <ProductCategoryViewModel>(category);
            var paginationSet = new PaginationSet <ProductViewModel>()
            {
                Items      = productVM,
                MaxPage    = int.Parse(ConfigHelperUtility.GetByKey(Constant.AppSetting_MaxPage)),
                Page       = page,
                TotalCount = totalRow,
                TotalPages = totalPage
            };

            return(View(paginationSet));
        }
Ejemplo n.º 6
0
        public ActionResult GetListByTag(string tagId, int page = 1)
        {
            int pageSize  = int.Parse(ConfigHelperUtility.GetByKey(Constant.AppSetting_PageSize));
            int totalRow  = 0;
            var product   = _productService.GetListProductByTag(tagId, page, pageSize, out totalRow);
            var productVM = Mapper.Map <List <ProductViewModel> >(product);
            int totalPage = (totalRow % pageSize == 0) ? (totalRow / pageSize) : (totalRow / pageSize) + 1;

            var tag = _productService.GetTagById(tagId);

            ViewBag.Tag = Mapper.Map <TagViewModel>(tag);

            var paginationSet = new PaginationSet <ProductViewModel>()
            {
                Items      = productVM,
                MaxPage    = int.Parse(ConfigHelperUtility.GetByKey(Constant.AppSetting_MaxPage)),
                Page       = page,
                TotalCount = totalRow,
                TotalPages = totalPage
            };

            return(View(paginationSet));
        }
Ejemplo n.º 7
0
        //[OutputCache(Duration = 60, Location = System.Web.UI.OutputCacheLocation.Client)]
        public ActionResult Index()
        {
            var slide   = _commonService.GetSlide().ToList();
            var slideVM = Mapper.Map <List <SlideViewModel> >(slide);

            var numLatestProduct  = int.Parse(ConfigHelperUtility.GetByKey(Constant.AppSetting_NumLatestProduct));
            var numTopSaleProduct = int.Parse(ConfigHelperUtility.GetByKey(Constant.AppSetting_NumTopSaleProduct));

            var latestProducts   = _productService.GetLatest(numLatestProduct).ToList();
            var latestProductsVM = Mapper.Map <List <ProductViewModel> >(latestProducts);

            var topSaleProducts   = _productService.GetHotProduct(numTopSaleProduct).ToList();
            var topSaleProductsVM = Mapper.Map <List <ProductViewModel> >(topSaleProducts);

            var model = new HomeViewModel()
            {
                Slides          = slideVM,
                LatestProducts  = latestProductsVM,
                TopSaleProducts = topSaleProductsVM
            };

            return(View(model));
        }