public IHttpActionResult UpdateProfileInfo(CourierDto userData) { var courier = _courierService.GetById(userData.Id); //courier = userData.MapPropertiesToInstance(courier); courier.CarNo = userData.CarNo; courier.User.Email = userData.User.Email; courier.User.MobilePhone = userData.User.MobilePhone.RemoveFormatPhone(); var newPassword = PasswordHelper.HashString(userData.User.Password, courier.User.UserName); courier.User.Password = newPassword; var result = _courierService.Update(courier); var courierDto = result.MapTo <CourierDto>(); courierDto.User.Password = userData.User.Password; return(Ok(courierDto)); }
public ActionResult Edit(string id) { try { return(View(Mapper.Map <CourierViewModel>(_courierService.GetById(id)))); } catch (Exception ex) { return(JavaScript($"ShowResult('{ex.Message}','failure')")); } }
public ActionResult ForgotPassword(string email) { const string randomPassword = "******"; var user = _userService.FirstOrDefault(o => o.Email == email); if (user != null) { var courier = _courierService.GetById(user.Id); if (courier != null) { var webLink = AppSettingsReader.GetValue("Url", typeof(String)) as string; var imgSrc = webLink + "/Content/quickspatch/img/logo-o.svg"; var urlChangePass = webLink + "/Authentication/ChangePasswordCourier?code=" + PasswordHelper.HashString(courier.Id.ToString(), courier.User.UserName); var fromEmail = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string; var displayName = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string; var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); var franchiseeName = franchiseeConfiguration != null?franchiseeConfiguration.Name:""; var emailContent = Framework.Utility.TemplateHelpper.FormatTemplateWithContentTemplate( TemplateHelpper.ReadContentFromFile(TemplateConfigFile.CreateCourierEmailTemplate, true), new { img_src = imgSrc, full_name = Framework.Utility.CaculatorHelper.GetFullName(courier.User.FirstName, courier.User.MiddleName, courier.User.LastName), web_link = webLink, user_name = courier.User.UserName, password = randomPassword, url_change_pass = urlChangePass, franchisee_Name = franchiseeName }); // send email var logo = franchiseeConfiguration != null ? franchiseeConfiguration.Logo : new byte[0]; _emailHandler.SendEmailSsl(fromEmail, new[] { courier.User.Email }, SystemMessageLookup.GetMessage("SubjectToSendEmailForCreateUser"), emailContent, logo, true, displayName); } else { user.Password = PasswordHelper.HashString(randomPassword, user.UserName); _userService.Update(user); var webLink = AppSettingsReader.GetValue("Url", typeof(String)) as string; var urlSignIn = webLink + "/Authentication/SignIn"; var imgSrc = webLink + "/Content/quickspatch/img/logo-o.svg"; var urlChangePass = webLink + "/Authentication/ChangePassword?code=" + PasswordHelper.HashString(user.Id.ToString(), user.UserName); var fromEmail = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string; var displayName = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string; var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); var franchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : ""; var emailContent = TemplateHelpper.FormatTemplateWithContentTemplate( TemplateHelpper.ReadContentFromFile(TemplateConfigFile.RestorePasswordTemplate, true), new { img_src = imgSrc, full_name = Framework.Utility.CaculatorHelper.GetFullName(user.FirstName, user.MiddleName, user.LastName), web_link = webLink, user_name = user.UserName, password = randomPassword, url_change_pass = urlChangePass, franchisee_Name = franchiseeName, url_sign_in = urlSignIn }); // send email var logo = franchiseeConfiguration != null ? franchiseeConfiguration.Logo : new byte[0]; _emailHandler.SendEmailSsl(fromEmail, new[] { user.Email }, SystemMessageLookup.GetMessage("SubjectToSendEmailForCreateUser"), emailContent, logo, true, displayName); } } else { throw new UserVisibleException("EmailInvalidText"); } return(Json(new { }, JsonRequestBehavior.AllowGet)); }