Example #1
0
        //public OrderDetail UpdateOrderDetail(string id,DateTime deliveryTime, int )
        //{

        //    mergedEntities db = new mergedEntities();
        //    OrderDetail orderDetail = db.OrderDetails.Where(o => o.Id == id)
        //                    .FirstOrDefault();
        //    orderDetail.orderNumber = productID;
        //    orderDetail.deliveryTime = deliveryTime;

        //    db.SaveChanges();
        //    return orderDetail;
        //}




        //Get profile details
        // change public AspNetUser to public RegisteredUser
        public RegisteredUser GetProfileDetail(Login login)
        {
            UserStore<IdentityUser> userStore = new UserStore<IdentityUser>();
            UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
            IdentityUser identityUser = manager.Find(login.UserName, login.Password);
            mergedEntities db = new mergedEntities();
            RegisteredUser USER = new RegisteredUser();

            var query =
            from a in db.AspNetUsers
            where (a.Id == identityUser.Id)
             select new
            {
                ID = a.Id,
                UserName = a.UserName,
                PhoneNumber = a.PhoneNumber,
                Email = a.Email,           
            };

            foreach (var item in query)
            {
                USER.Id = item.ID;
                USER.UserName = item.UserName;
                USER.TelNumber = item.PhoneNumber;
                USER.Email = item.Email;
            }

            return USER;
        }
Example #2
0
        //const string TO = "*****@*****.**"; // Specify where you want this email sent.
        // This value may/may not be constant.
        // To get started use one of your email 
        // addresses.
        public string EmailFromArvixe(RegisteredUser registeredUser)
        {

            // Use credentials of the Mail account that you created with the steps above.
            const string FROM = "*****@*****.**";
            const string FROM_PWD = "tv20021809";
            const bool USE_HTML = true;
            string TO = registeredUser.Email;

            // Get the mail server obtained in the steps described above.
            const string SMTP_SERVER = "143.95.249.35";
            try
            {
                MailMessage mailMsg = new MailMessage(FROM, TO);
                mailMsg.Subject = "Confirmation Email for " + registeredUser.UserName;
                mailMsg.Body = registeredUser.ConfirmLink + "<br/>Sent by: 2Hours Inc" ;
                mailMsg.IsBodyHtml = USE_HTML;

                SmtpClient smtp = new SmtpClient();
                smtp.Port = 25;
                smtp.Host = SMTP_SERVER;
                smtp.Credentials = new System.Net.NetworkCredential(FROM, FROM_PWD);
                smtp.Send(mailMsg);
            }
            catch//(System.Exception ex)
            {
                //return ex.Message;
                return FAILURE;
            }
            return SUCCESS;
        }
Example #3
0
        public ActionResult Register(RegisteredUser newUser) {
            var userStore         = new UserStore<IdentityUser>();
            UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore)
            {
                UserLockoutEnabledByDefault = true,
                DefaultAccountLockoutTimeSpan = new TimeSpan(0, 10, 0),
                MaxFailedAccessAttemptsBeforeLockout = 3
            };

            var identityUser      = new IdentityUser() { UserName = newUser.UserName, 
                                                         Email    = newUser.Email };
            IdentityResult result = manager.Create(identityUser, newUser.Password);

            if (result.Succeeded) {
                CreateTokenProvider(manager, EMAIL_CONFIRMATION);

                var code = manager.GenerateEmailConfirmationToken(identityUser.Id);
                var callbackUrl = Url.Action("ConfirmEmail", "Account",
                                                new { userId = identityUser.Id, code = code },
                                                    protocol: Request.Url.Scheme);

                string link = "Please confirm your account by clicking this link: <a href=\""
                                + callbackUrl + "\">Confirm Registration</a>";
                newUser.ConfirmLink = link;                
                // sending Email Start
                MailHelper mailer = new MailHelper();
                string response = mailer.EmailFromArvixe(
                                           new RegisteredUser(newUser.Email, newUser.UserName,newUser.ConfirmLink ));
                
                if (response != "Failure sending mail."){
                    ViewBag.Success = response;
                }else{
                    ViewBag.Failure = response;
                }

                // sending Email End
            }
            return View();
            }
Example #4
0
 public ActionResult Update(RegisteredUser registeredUser)
 {
     AccountRepo accountRepo = new AccountRepo();
     accountRepo.UpdateUser(registeredUser.TelNumber, registeredUser.UserName);
     
     return View();
 }