public async Task <ActionResult> ChangeEmail(UpdateEmail em)
        {
            ToastModel tm   = new ToastModel();
            string     role = await _common.GetUserRoleName(User.Identity.Name);

            if (ModelState.IsValid)
            {
                string uId = await _account.GetUserIdByEmail(User.Identity.Name);

                bool isEmailExists = await _account.CheckIsEmailExists(em.Email);

                if (isEmailExists)
                {
                    tm.IsSuccess = false;
                    tm.Message   = "Email already exists";
                    return(Json(tm));
                }
                else
                {
                    UpdateEmail emailModel = new UpdateEmail();
                    emailModel.userId = uId;
                    emailModel.Email  = em.Email;
                    HttpResponseMessage userResponseMessage = await Utility.GetObject("/api/User/UpdateEmailAddress", emailModel, true);

                    tm.IsSuccess = true;
                    tm.Message   = "Email updated successfully";
                    return(Json(tm));
                }
            }

            return(RedirectToAction("EditEmail", "Common"));
        }
        public PartialViewResult EditEmail()
        {
            UpdateEmail em = new UpdateEmail();

            em.Email = User.Identity.Name;
            return(PartialView("_ChangeEmail", em));
        }
예제 #3
0
 /// <summary>
 /// updates email address
 /// </summary>
 /// <param name="el"> update email model </param>
 /// <returns> true or false </returns>
 public bool UpdateEmailAddress(UpdateEmail el)
 {
     using (var _ctx = new ChinmayaEntities())
     {
         var user = _ctx.Users.Where(r => r.Id == el.userId).FirstOrDefault();
         if (user != null)
         {
             user.Email = el.email;
         }
         try
         {
             _ctx.Entry(user).State = EntityState.Modified;
             _ctx.SaveChanges();
             return(true);
         }
         catch (DbEntityValidationException e)
         {
             foreach (var even in e.EntityValidationErrors)
             {
                 Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                   even.Entry.Entity.GetType().Name, even.Entry.State);
                 foreach (var ve in even.ValidationErrors)
                 {
                     Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                       ve.PropertyName, ve.ErrorMessage);
                 }
             }
             return(false);
         }
     }
 }
예제 #4
0
        public async Task <ActionResult> ChangeEmail(UpdateEmail em, string nextBtn)
        {
            ToastModel tm = new ToastModel();

            if (nextBtn != null)
            {
                if (ModelState.IsValid)
                {
                    string uId = await _account.GetUserIdByEmail(User.Identity.Name);

                    bool isEmailExists = await _account.CheckIsEmailExists(em.email);

                    if (isEmailExists)
                    {
                        tm.IsSuccess = false;
                        tm.Message   = "Select Email which does not exist already...!";
                        return(Json(tm));
                    }
                    else
                    {
                        UpdateEmail emailModel = new UpdateEmail();
                        emailModel.userId = uId;
                        emailModel.email  = em.email;
                        HttpResponseMessage userResponseMessage = await Utility.GetObject("/api/User/UpdateEmailAddress", emailModel, true);

                        tm.IsSuccess = true;
                        tm.Message   = "Email updated successfully";
                        return(Json(tm));
                    }
                }
            }
            return(RedirectToAction("MyAccount", "Account"));
        }
예제 #5
0
        public async Task <ActionResult> ChangeEmail(UpdateEmail em)
        {
            ToastModel tm = new ToastModel();

            //string role = await _common.GetUserRoleName(User.Identity.Name);
            if (ModelState.IsValid)
            {
                //string uId = await _account.GetUserIdByEmail(User.Identity.Name);
                string uId           = em.userId;
                bool   isEmailExists = await _account.CheckIsEmailExists(em.Email);

                if (isEmailExists)
                {
                    tm.IsSuccess = false;
                    tm.Message   = "Email already exists";
                    return(Json(tm));
                }
                else
                {
                    EncryptDecrypt objEncryptDecrypt = new EncryptDecrypt();
                    UpdateEmail    emailM            = await _user.GetEmailById(uId);

                    string      mailTo     = emailM.Email;
                    UpdateEmail emailModel = new UpdateEmail();
                    emailModel.userId = uId;
                    emailModel.Email  = em.Email;
                    UserModel usrm = await _user.GetUserInfo(emailM.Email);

                    HttpResponseMessage userResponseMessage = await Utility.GetObject("/api/User/UpdateEmailAddress", emailModel, true);

                    if (userResponseMessage.IsSuccessStatusCode)
                    {
                        EmailTemplateModel etm = await _account.GetEmailTemplate(1);

                        string approvalLink = configMngr["UserActivationLink"]
                                              + objEncryptDecrypt.Encrypt(emailM.Email, configMngr["ServiceAccountPassword"]);
                        string fullname  = usrm.FirstName + " " + usrm.LastName;
                        string emailBody = etm.Body
                                           .Replace("[Username]", fullname)
                                           .Replace("[URL]", approvalLink);
                        etm.Body = emailBody;

                        EmailManager emailmgr = new EmailManager
                        {
                            Body    = etm.Body,
                            To      = mailTo,
                            Subject = etm.Subject,
                            From    = ConfigurationManager.AppSettings["SMTPUsername"]
                        };
                        emailmgr.Send();
                    }
                    tm.IsSuccess = true;
                    tm.Message   = "Email updated successfully and an email has been sent to registered email. Please activate your account";
                    return(Json(tm));
                }
            }

            return(RedirectToAction("EditUserEmail", "Common"));
        }
예제 #6
0
        public async Task <IActionResult> UpdateChapterEmail(Guid id, EmailType type,
                                                             [FromForm] UpdateEmailApiRequest request)
        {
            UpdateEmail chapterEmail = _mapper.Map <UpdateEmail>(request);
            await _emailAdminService.UpdateChapterEmail(GetMemberId(), id, type, chapterEmail);

            return(NoContent());
        }
예제 #7
0
 public object Put(UpdateEmail request)
 {
     var entity = request.ConvertTo<Email>();
     return InTransaction(db =>
     {
         Logic.Update(entity);
         return new CommonResponse(Logic.GetById(entity.Id));
     });
 }
예제 #8
0
        public async Task <PartialViewResult> EditUserEmail(string id)
        {
            UpdateEmail em = new UpdateEmail();

            em = await _user.GetEmailById(id);

            em.userId = id;
            return(PartialView("_ChangeUserEmail", em));
        }
예제 #9
0
 public IHttpActionResult UpdateEmailAddress(UpdateEmail obj)
 {
     try
     {
         _user.UpdateEmailAddress(obj);
         return(Ok("Success"));
     }
     catch
     {
         throw;
     }
 }
예제 #10
0
 public IHttpActionResult UpdateEmailAddress(UpdateEmail obj)
 {
     try
     {
         _user.UpdateEmailAddress(obj);
         return(Ok("Success"));
     }
     catch (Exception)
     {
         return(Ok("Something went wrong"));
     }
 }
예제 #11
0
 /// <summary>
 /// gets user email
 /// </summary>
 /// <param name="Email"> user email </param>
 /// <returns> Update email model  </returns>
 public UpdateEmail getEmail(string Id)
 {
     using (var _ctx = new ChinmayaEntities())
     {
         UpdateEmail mail  = new UpdateEmail();
         var         eData = _ctx.Users.Where(f => f.Email == Id).FirstOrDefault();
         if (eData != null)
         {
             mail.Email = Id;
         }
         return(mail);
     }
 }
예제 #12
0
        public async Task <Result <SuccessfulEmailUpdate> > Update(UpdateEmail request,
                                                                   AccessToken accessToken = default, CancellationToken cancellationToken = default)
        {
            var requestUri = GetUri(path);

            var result = await HttpPut <SuccessfulEmailUpdate>(requestUri, data : request, administrationOrApiKey : AdministrationKey,
                                                               token : accessToken, cancellationToken : cancellationToken);

            if (result.IsSuccess && result.Success == null)
            {
                result.Success = new SuccessfulEmailUpdate();
            }

            return(result);
        }
예제 #13
0
        public UpdateEmail GetEmailById(string Id)
        {
            UpdateEmail email = new UpdateEmail();

            if (!string.IsNullOrEmpty(Id))
            {
                using (var _ctx = new ChinmayaEntities())
                {
                    var objUser = _ctx.Users.FirstOrDefault(x => x.Id == Id);
                    if (objUser != null)
                    {
                        email.Email = _ctx.Users.Where(r => r.Id == objUser.Id).Select(r => r.Email).FirstOrDefault();
                    }
                }
            }
            return(email);
        }
예제 #14
0
        public async Task <IHttpActionResult> updateemail(UpdateEmail loanDetails)
        {
            // To do - Move the following code to a single method & use it across the project
            IEnumerable <string> tokenValues;
            string tokenValue = "";

            if (Request.Headers.TryGetValues("AuthorizationToken", out tokenValues))
            {
                tokenValue = tokenValues.FirstOrDefault();
            }
            var payment = await loanService.PostupdateemailForAsync(tokenValue, loanDetails);

            if (payment == null)
            {
                return(NotFound());
            }
            return(Ok(payment));
        }
예제 #15
0
        public async Task <IActionResult> UpdateEmail([FromBody] UpdateEmail changeEmailModel)
        {
            string      token;
            string      resetToken;
            SensateUser user;
            EmailBody   mail;

            if (changeEmailModel == null || string.IsNullOrEmpty(changeEmailModel.NewEmail))
            {
                return(this.BadRequest(new Status {
                    Message = "Invalid email!",
                    ErrorCode = ReplyCode.BadInput
                }));
            }

            user = await this.GetCurrentUserAsync().AwaitBackground();

            var exists = await this._users.GetByEmailAsync(changeEmailModel.NewEmail).AwaitBackground();

            if (exists != null)
            {
                return(this.UnprocessableEntity(new Status {
                    Message = "Email already in use!",
                    ErrorCode = ReplyCode.BadInput
                }));
            }

            resetToken = await this._manager.GenerateChangeEmailTokenAsync(user, changeEmailModel.NewEmail).AwaitBackground();

            token = this._email_tokens.Create(resetToken, changeEmailModel.NewEmail);
            mail  = await this.ReadMailTemplate("Confirm_Update_Email.html", "Confirm_Update_Email.txt").AwaitBackground();

            if (mail == null)
            {
                return(this.StatusCode(500));
            }

            mail.HtmlBody = mail.HtmlBody.Replace("%%TOKEN%%", token);
            mail.TextBody = string.Format(mail.TextBody, token);
            await this._mailer.SendEmailAsync(changeEmailModel.NewEmail, "Confirm your new mail", mail).AwaitBackground();

            return(this.NoContent());
        }
예제 #16
0
        public static ResultState UpdateUserEmail(this DiscourseApi api, string username, string newEmail, string apiUserName = DefaultUsername)
        {
            var path = String.Format("/users/{0}/preferences/email", username);
            var data = new UpdateEmail(newEmail);

            var result = api.ExecuteRequest <RestResponse>(path, Method.PUT, true, apiUserName, null, data);

            switch (result.StatusCode)
            {
            case (HttpStatusCode)422:
                return(ResultState.Unchanged);

            case HttpStatusCode.Accepted:
                return(ResultState.Modified);

            default:
                return(ResultState.Error);
            }
        }
예제 #17
0
 /// <summary>
 /// updates email address
 /// </summary>
 /// <param name="el"> update email model </param>
 /// <returns> true or false </returns>
 public bool UpdateEmailAddress(UpdateEmail el)
 {
     using (var _ctx = new ChinmayaEntities())
     {
         var user = _ctx.Users.Where(r => r.Id == el.userId).FirstOrDefault();
         if (user != null)
         {
             user.Email = el.Email;
         }
         try
         {
             _ctx.Entry(user).State = EntityState.Modified;
             _ctx.SaveChanges();
             return(true);
         }
         catch
         {
             throw;
         }
     }
 }
예제 #18
0
 public ActionResult UpdateEmail(UpdateEmail up)
 {
     if (ModelState.IsValid)
     {
         //MembershipUser MemberUser = Membership.GetUser(User.Identity.Name);
         //string UserId = Convert.ToString(MemberUser.ProviderUserKey);
         string UserId = Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name));
         up.UserID = UserId;
         BLObj.saveUserEmailID(up);
         TempData["StatusMessage"] = "Saved successfuly";
         TempData["StatusMessageClass"] = "text-success bg-success";
         return RedirectToAction("UpdateEmail");
     }
     return View();
 }
 public Task <Response> UpdateEmail(UpdateEmail command)
 {
     return(_appLayer.Execute(command));
 }
예제 #20
0
        public void saveUserEmailID(UpdateEmail up)
        {
            try
            {
                clsParameterCollection clsParaCollection = new clsParameterCollection();
                clsParaCollection.ProcedureName = Constants.sp_UserProfile_SaveEmailID;
                clsParaCollection.Add(new clsParameter { ParameterName = "@UserID", ParameterValue = up.UserID });
                clsParaCollection.Add(new clsParameter { ParameterName = "@EmailID", ParameterValue = up.Email });
                DataAccess.ExecuteNonQuerySp(clsParaCollection);

            }
            catch (Exception ex)
            {
                BL_Exception.WriteLog(ex);
                throw ex;
            }
        }
예제 #21
0
 private void ChangeEmailBind_Click(object sender, RoutedEventArgs e)
 {
     _ = new UpdateEmail().ShowAsync();
 }
예제 #22
0
 public ActionResult UpdateEmail()
 {
     UpdateEmail up = new UpdateEmail();
     dtObj = new System.Data.DataTable();
     //MembershipUser MemberUser = Membership.GetUser(User.Identity.Name);
     //string UserId = Convert.ToString(MemberUser.ProviderUserKey);
     string UserId = Convert.ToString(Common.GetUserId(HttpContext.User.Identity.Name));
     dtObj = BLObj.GetUserEmailId(UserId);
     up.ExistingEmail = dtObj.Rows[0]["EmailID"].ToString();
     up.UserID = UserId;
     return View(up);
 }