Esempio n. 1
0
        public ActionResult Create([Bind(Include = "product_ID,Amount")] Bid bid)
        {
            if (ModelState.IsValid)
            {
                Product prod   = db.Products.Find(bid.product_ID);
                var     userid = User.Identity.GetUserId();
                var     user   = db.Users.Find(userid);
                bid.User_ID = userid;
                bid.Time    = DateTime.Now;
                db.Bids.Add(bid);
                db.SaveChanges();
                EmailUtility.sendMail(user.EmailAddress, "This is to confirm your bid on " + prod.productName + " for the amount of " + bid.Amount);
                ViewBag.confirmMsg = "A confirmation email for your bid has been sent to you.";

                return(View("EmailConfirmation"));



                return(RedirectToAction("Index"));
            }

            ViewBag.product_ID = new SelectList(db.Products, "product_ID", "Auction1", bid.product_ID);
            ViewBag.User_ID    = new SelectList(db.Users, "User_ID", "LastName", bid.User_ID);
            return(View(bid));
        }
        public async Task <ActionResult> RegisterManager(int id, RegisterViewModel model)
        {
            if (model.isOwner || model.RestaurantId != id)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            model.Password        = GeneratePassword();
            model.ConfirmPassword = model.Password;
            var user = await CreateUser(model);

            if (user != null)
            {
                string path   = Url.Action("Login");
                string domain = Url.RequestContext.HttpContext.Request.Url.GetLeftPart(UriPartial.Authority);
                string url    = domain + path;
                string body   = "You have been registered for the 68 application.  Your temporary password is as follows:\n\n";
                body += model.Password;
                body += "\n\nThe following is a link to the login page:\n\n" + url;
                EmailUtility.sendMail(model.Email, body, "68 Manager Registration: Confirm Password");
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View(model));
            }
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                EmailUtility.sendMail(model.Email, "Welcome to An Apple A Day. Thank you " + model.firstName + "for Registering. This is a place where teachers can get hello from the community. We are happy that have joined us.");

                //User Role code
                var roleStore   = new RoleStore <IdentityRole>(context);
                var roleManager = new RoleManager <IdentityRole>(roleStore);
                var userStore   = new UserStore <ApplicationUser>(context);
                var userManager = new UserManager <ApplicationUser>(userStore);

                ////user role code --end


                if (result.Succeeded)
                {
                    var teacher = new Teacher
                    {
                        firstName = model.firstName,
                        lastName  = model.lastName,
                        gender    = model.gender.ToString(),
                        state     = model.state,
                        city      = model.city,
                        dob       = model.dob,
                        zip       = model.zip,
                        teachId   = user.Id
                    };

                    using (var db = new AnAppleADay_01Entities())
                    {
                        db.Teachers.Add(teacher);
                        db.SaveChanges();
                    }

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    userManager.AddToRole(user.Id, "User");
                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
 public ActionResult SendEmail([Bind(Include = "emailID,name,email,subject,category,message")] Email emailModel)
 {
     if (ModelState.IsValid)
     {
         db.Emails.Add(emailModel);
         db.SaveChanges();
     }
     EmailUtility.sendMail(emailModel.email, emailModel.message, emailModel.subject);
     return(View("Index"));
 }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "listId,teachId,itemName,itemAbout,cost,current,expDate")] TeachersWishlist teachersWishlist)
        {
            if (ModelState.IsValid)
            {
                EmailUtility.sendMail("*****@*****.**", "Your List for item " + teachersWishlist.itemName + " was created. It will expire on " + teachersWishlist.expDate);
                db.TeachersWishlists.Add(teachersWishlist);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.teachId = new SelectList(db.Teachers, "teachId", "firstName", teachersWishlist.teachId);
            return(View(teachersWishlist));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                EmailUtility.sendMail(model.Email, "Welcome to Next Generation Productions! We look forward to providing you with all you may need for your next event.");
                //User Role code
                var roleStore   = new RoleStore <IdentityRole>(context);
                var roleManager = new RoleManager <IdentityRole>(roleStore);

                var userStore   = new UserStore <ApplicationUser>(context);
                var userManager = new UserManager <ApplicationUser>(userStore);
                //user role code --end



                if (result.Succeeded)
                {
                    var customer = new Customer();
                    customer.Name   = model.Name;
                    customer.UserID = user.Id;
                    using (var db = new NGPEntities())
                    {
                        db.Customers.Add(customer);
                        db.SaveChanges();
                    }

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    userManager.AddToRole(user.Id, "user");

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Esempio n. 7
0
        public ActionResult Buy([Bind(Include = "product_ID")] Product product)
        {
            //Get the hidden productId to customise the email to the user.

            //For bids - get the productId and the Bid amount for the email.
            Product prod   = db.Products.Find(product.Product_ID);
            var     userid = User.Identity.GetUserId();
            var     user   = db.Users.Find(userid);


            EmailUtility.sendMail(user.EmailAddress, "This is to confirm your purchase of " + prod.productName + " for the amount of " + prod.price);
            ViewBag.confirmMsg = "A confirmation email for your purchase has been sent to you.";

            return(View("EmailConfirmation"));
        }
Esempio n. 8
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    User efUser = new User();
                    efUser.Address      = model.Address;
                    efUser.DOB          = model.DOB;
                    efUser.EmailAddress = model.Email;
                    efUser.FirstName    = model.FirstName;
                    efUser.LastName     = model.LastName;
                    efUser.PhoneNumber  = model.PhoneNumber;

                    var newAspUser = UserManager.FindByEmail(model.Email);
                    efUser.User_ID = newAspUser.Id;

                    using (var db = new EbayforCarsEntities())
                    {
                        db.Users.Add(efUser);
                        db.SaveChanges();
                    }
                    EmailUtility.sendMail(model.Email, "Welcome to Bid Up - Antique(s) Where You New Hot Rod Awaits! Happy Bidding");



                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Esempio n. 9
0
        public void SendAlert(Person employee, string restaurantName, UrlHelper helper)
        {
            string email   = employee.Email;
            string subject = "Alert posted from " + restaurantName;
            string path    = helper.Action("Respond", "Alerts", new { id = Id, employeeId = employee.Id });
            string domain  = helper.RequestContext.HttpContext.Request.Url.GetLeftPart(UriPartial.Authority);
            string url     = domain + path;
            string body    = employee.FirstName + ",\n\n";

            body += "We could use the following items if you have the chance to get them before your shift today:\n";
            foreach (var item in ItemAlerts)
            {
                body += item.RestaurantItem.Item.Name + "\n";
            }
            body += "\nClick on the following link to respond:\n\n" + url;
            EmailUtility.sendMail(email, body, subject);
        }
Esempio n. 10
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    var UserId      = UserManager.FindByEmail(model.Email).Id;
                    var UserProfile = new UserInfo()
                    {
                        Name         = model.Name,
                        Email        = model.Email,
                        PricePerPack = model.PricePerPack,
                        UserID       = UserId
                    };

                    UserProfile.SetPlan(db, model.StartDate, model.PlanID, model.CigsPerDay);
                    db.UserInfoes.Add(UserProfile);
                    db.SaveChanges();
                    EmailUtility.sendMail(model.Email, "Welcome to Breathe Easy! Congratulations on taking the first step to a healthier, happier life.");

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    //string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    //var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    //await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Dashboard", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }