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());
        }