当前位置: 首页>>代码示例>>C#>>正文


C# UserModel.GetCurrentEmail方法代码示例

本文整理汇总了C#中UserModel.GetCurrentEmail方法的典型用法代码示例。如果您正苦于以下问题:C# UserModel.GetCurrentEmail方法的具体用法?C# UserModel.GetCurrentEmail怎么用?C# UserModel.GetCurrentEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserModel的用法示例。


在下文中一共展示了UserModel.GetCurrentEmail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SavePersonalInfo

 public ActionResult SavePersonalInfo(UserModel.User user)
 {
     if (ModelState.IsValid)
     {
         var UpdateEmail = false;
         string email = user.BillingEmail;
         var UserCurrentEmail = user.GetCurrentEmail(User.Identity.Name);
         var UserCurrentCompany = user.GetCompany(User.Identity.Name);
         var EnteredEmailValid = user.IsEmailValid(email);
         var regexItem = new Regex(@"\d");
         Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
         Match match = regex.Match(email);
         if (!match.Success)
         {
             //Bad Email
             ModelState.AddModelError("BillingEmail", "Invalid Email");
         }
         else if (EnteredEmailValid && UserCurrentEmail != email)
         {
             //Email Taken
             ModelState.AddModelError("BillingEmail", "Email in use on another account");
             TempData["ViewData"] = ViewData;
         }
         else
         {
             UpdateEmail = true;
         }
         if (user.BillingName.Length < 5)
         {
             //Bad Username
             ModelState.AddModelError("BillingName", "Username must be a least 5 characters in length");
         }
         else if (user.DoesUsernameExist(user.BillingName) && user.BillingName != User.Identity.Name)
         {
             //Username already exists
             ModelState.AddModelError("BillingName", "Username is not available");
         }
         else if (user.Company.Length < 1)
         {
             //No company entered
             ModelState.AddModelError("Company", "Company name is not valid");
         }
         else if (UpdateEmail)
         {
             if (EnteredEmailValid && UserCurrentEmail == email)
             {
                 //Same email
             }
             else
             {
                 //Update email
                 var emailUpdateStatus = user.UpdateEmail(email, User.Identity.Name);
                 if (emailUpdateStatus == BusinessEntities.EmailUpdateStatus.Error)
                 {
                     //error view
                     return RedirectToAction("Error", "User");
                 }
             }
             //Update Username
             if (user.BillingName != User.Identity.Name)
             {
                 var userEmail = user.GetCurrentEmail(User.Identity.Name);
                 if (user.UpdateUsername(user.BillingName, User.Identity.Name))
                 {
                     //Authentication
                     HttpCookie userNameCookie = new HttpCookie("QueueViewUserName");
                     DateTime now = DateTime.Now;
                     userNameCookie.Value = User.Identity.Name;
                     userNameCookie.Expires = now.AddDays(-1D);
                     Response.Cookies.Add(userNameCookie);
                     FormsAuthentication.SignOut();
                     FormsAuthentication.SetAuthCookie(user.BillingName, false);
                 }
                 else
                 {
                     //error view
                     return RedirectToAction("Error", "User");
                 }
             }
             if (UserCurrentCompany != user.Company)
             {
                 if (!user.UpdateCompany(user.Company, User.Identity.Name))
                 {
                     //error view
                     return RedirectToAction("Error", "User");
                 }
             }
         }
     }
     TempData["ViewData"] = ViewData;
     return RedirectToAction("AccountDashboard", "User", new {ADID = "PersonalInfo"});
 }
开发者ID:rtom1986,项目名称:The-Queue-View,代码行数:92,代码来源:UserController.cs

示例2: SaveBillingCardInfo

 public ActionResult SaveBillingCardInfo(UserModel.User user, System.Web.Mvc.FormCollection collection)
 {
     var billingID = user.GetBillingID(User.Identity.Name);
     if (billingID != String.Empty)
     {
         Customer customer = Gateway.BrainTreeGateway.Customer.Find(billingID);
         string token = customer.CreditCards[0].Token;
         var request = new CustomerRequest
         {
             CreditCard = new CreditCardRequest
             {
                 CardholderName = collection["name"],
                 Number = collection["number"],
                 ExpirationMonth = collection["month"],
                 ExpirationYear = collection["year"],
                 CVV = collection["cvv"],
                 Options = new CreditCardOptionsRequest
                 {
                     UpdateExistingToken = token
                 }
             }
         };
         Result<Customer> updateResult = Gateway.BrainTreeGateway.Customer.Update(billingID, request);
         if (updateResult.IsSuccess())
         {
             var mongo = new Mongo();
             var config = mongo.GetUserConfiguration(User.Identity.Name);
             if (config.AccountInfoNotification)
             {
                 MailgunAgent.SendChangeEmail(user.GetCurrentEmail(User.Identity.Name), "Your Queue View credit card has been changed.");
             }
             return RedirectToAction("AccountDashboard", "User", new { ADCC = "ChangeCard" });
         }
         else
         {
             //Fail to update with Braintree
             return RedirectToAction("AccountDashboard", "User", new { ADCCFAIL = updateResult.Message });
         }
     }
     else
     {
         //Fail to retrieve Billing ID
         return RedirectToAction("Error", "User");
     }
 }
开发者ID:rtom1986,项目名称:The-Queue-View,代码行数:45,代码来源:UserController.cs


注:本文中的UserModel.GetCurrentEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。