private void SendEmployeeEmail(AppUser user) { var body = $@"Dear {user.FirstName}, you have been registered as an employee"; EmailMessaging.SendEmail(user.Email, "Team 11 Employee Registration Confirmation", body); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { //TODO: Add fields to user here so they will be saved to do the database bool date = (model.Birthday.AddYears(13) < DateTime.Today); if (date == false) { TempData["msg"] = "<script>alert('You must be at least 13 years old to make an account.');</script>"; return(Redirect(Request.UrlReferrer.ToString())); } if (User.IsInRole("Manager") == true) { bool employeedate = (model.Birthday.AddYears(18) < DateTime.Today); if (employeedate == false) { TempData["msg"] = "<script>alert('Employees must be at least 18 years old.');</script>"; return(Redirect(Request.UrlReferrer.ToString())); } } var user = new AppUser { UserName = model.Email, Email = model.Email, Birthday = model.Birthday, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.PhoneNumber, Address = model.Address, PopcornPoints = 0, }; var result = await UserManager.CreateAsync(user, model.Password); //TODO: Once you get roles working, you may want to add users to roles upon creation //UserManager.AddToRole(user.Id, "Customer"); if (User.IsInRole("Manager") == true) { await UserManager.AddToRoleAsync(user.Id, "Employee"); } else { await UserManager.AddToRoleAsync(user.Id, "Customer"); } if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://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>"); EmailMessaging.SendEmail(model.Email, "Thank you for creating an account!", "now keep working"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult PayBillsOnlineSavings([Bind(Include = "TransactionID,TransactionDate,Amount,Description")] Transaction transaction, int SavingsAccountID) { if (ModelState.IsValid) { transaction.TransactionType = "Bill Payment"; transaction.isBeingDisputed = false; transaction.EmployeeComments = ""; transaction.isPending = false; if (transaction.Description == null) { transaction.Description = ""; } SavingsAccount SavingsAccountToChange = db.SavingsAccounts.Find(SavingsAccountID); if (SavingsAccountToChange.Balance < 0) { return(View("Error", new string[] { "You cannot transfer money with a negative balance" })); } if (transaction.Amount > SavingsAccountToChange.Balance) { if ((transaction.Amount - SavingsAccountToChange.Balance) > 50) { return(View("Error", new string[] { "The transaction exceeds the $50 overdraft limit. Please try to input a transfer amount within Balance range or $50 overdraft limit range" })); } else { Transaction TransactionODFee = new Transaction(); TransactionODFee.Amount = 30; SavingsAccountToChange.Balance -= TransactionODFee.Amount; TransactionODFee.TransactionDate = transaction.TransactionDate; TransactionODFee.TransactionType = "Fee"; TransactionODFee.isBeingDisputed = false; TransactionODFee.EmployeeComments = ""; TransactionODFee.isPending = false; TransactionODFee.Description = "Overdraft Fee"; TransactionODFee.SavingsAccountAffected = SavingsAccountToChange; SavingsAccountToChange.Transactions.Add(TransactionODFee); db.Transactions.Add(TransactionODFee); EmailMessaging.SendEmail(TransactionODFee.SavingsAccountAffected.Customer.Email, "Overdraft", "Your account is now in overdraft status. "); } } SavingsAccountToChange.Balance -= transaction.Amount; transaction.SavingsAccountAffected = SavingsAccountToChange; SavingsAccountToChange.Transactions.Add(transaction); db.Transactions.Add(transaction); db.SaveChanges(); return(RedirectToAction("PaymentConfirmation", "Payees")); } AppUser user = db.Users.Find(User.Identity.GetUserId()); List <Payee> CustomerPayeeList = user.Payees.ToList(); PayBillsOnlineViewModel model = new PayBillsOnlineViewModel { Customer = user, Payees = CustomerPayeeList }; ViewBag.Payees = GetSavingsAccountsWithBalance(); return(View(model)); }
public ActionResult ConfirmScreen(Int32 id) { OrderDetail shoppingCart = db.OrderDetails.Find(id); if (shoppingCart.GifteeEmail.Length > 1) { db.OrderDetails.Find(shoppingCart.OrderDetailID).User = db.Users.FirstOrDefault(a => a.UserName.Contains(shoppingCart.GifteeEmail)); } db.OrderDetails.Find(shoppingCart.OrderDetailID).IsConfirmed = true; foreach (Discount item in shoppingCart.Discounts) { if (item.Album != null) { db.OrderDetails.Find(shoppingCart.OrderDetailID).Discounts.FirstOrDefault(a => a.DiscountID.Equals(item.DiscountID)).DiscountAmt = item.Album.DisplayPrice; } else { db.OrderDetails.Find(shoppingCart.OrderDetailID).Discounts.FirstOrDefault(a => a.DiscountID.Equals(item.DiscountID)).DiscountAmt = item.Song.DisplayPrice; } } db.SaveChanges(); StringBuilder strPurchasedItems = new StringBuilder(); foreach (Discount item in shoppingCart.Discounts) { if (item.Album != null && item.Song != null) { strPurchasedItems.Append(item.Song.SongTitle + ": $" + item.Song.SongPrice); strPurchasedItems.AppendLine(); strPurchasedItems.Append(item.Album.AlbumTitle + ": $" + item.Album.AlbumPrice); } if (item.Album != null && item.Song == null) { strPurchasedItems.Append(item.Album.AlbumTitle + ": $" + item.Album.AlbumPrice); strPurchasedItems.AppendLine(); } if (item.Album == null && item.Song != null) { strPurchasedItems.Append(item.Song.SongTitle + ": $" + item.Song.SongPrice); strPurchasedItems.AppendLine(); } } var orderid = shoppingCart.OrderDetailID; var linkurl = new StringBuilder(); linkurl.AppendFormat("longhornmusicteam7.azurewebsites.net/OrderDetails/RefundConfirm?OrderDetailID={0}", orderid); if (shoppingCart.GifteeEmail.Length < 2) { EmailMessaging.SendEmail(shoppingCart.GifterEmail, "Thanks for the Purchase!", "You purchased the Following Items: " + strPurchasedItems + " Follow this link for a refund. " + linkurl); } else { EmailMessaging.SendEmail(shoppingCart.GifterEmail, "Thanks for the Purchase!", "Your gift order has gone to " + shoppingCart.GifteeEmail + " Follow this link for a refund. " + linkurl); EmailMessaging.SendEmail(shoppingCart.GifteeEmail, "You have a gift!", "You have received the following items: " + strPurchasedItems); } return(View(db.OrderDetails.Find(id))); }
public ActionResult AssignAccessLevel(string id) { try { if (id != null) { var allusers = from usertabel in database.DX_USER where usertabel.userid == id select usertabel; if (allusers != null && allusers.ToList().Count == 1) { DX_USER user = allusers.ToList().First(); switch (user.role) { case "ceo": user.accesslevel = Constants.CEO_USER_ACCESS; break; case "manager": user.accesslevel = Constants.MANAGER_USER_ACCESS; break; case "employee": user.accesslevel = Constants.EMPLOYEE_USER_ACCESS; break; case "vp": user.accesslevel = Constants.VP_USER_ACCESS; break; default: break; } database.ObjectStateManager.ChangeObjectState(user, EntityState.Modified); if (user.accesslevel != Constants.EMPLOYEE_USER_ACCESS) { var userdept = from userdepttable in database.DX_USERDEPT where userdepttable.userid == id select userdepttable; if (userdept == null) { throw new Exception("error while retrieving user department"); } List <string> usersList = new List <string>(); foreach (DX_USERDEPT dept in userdept) { var deptmembers = from userdepttable in database.DX_USERDEPT where userdepttable.deptid == dept.deptid && userdepttable.userid != id select userdepttable; if (deptmembers != null) { foreach (DX_USERDEPT deptuser in deptmembers) { string deptUserid = deptuser.userid; if (!usersList.Contains(deptUserid)) { usersList.Add(deptUserid); } else { continue; } var useraccess = database.DX_USER.SingleOrDefault(x => x.userid == deptuser.userid); switch (user.accesslevel) { case "manager": { if (useraccess.accesslevel.Equals("ceo") || useraccess.accesslevel.Equals("vp")) { continue; } break; } case "vp": { if (useraccess.accesslevel.Equals("ceo")) { continue; } break; } } var employeeFiles = from files in database.DX_FILES where files.ownerid == useraccess.userid select files; if (employeeFiles != null) { foreach (DX_FILES employeeFile in employeeFiles) { var file = from prev in database.DX_PRIVILEGE where prev.userid == id && prev.fileid == employeeFile.fileid select prev; if (file != null && file.Count() < 1) { DX_PRIVILEGE filePriv = new DX_PRIVILEGE(); filePriv.fileid = employeeFile.fileid; filePriv.userid = id; filePriv.read = true; filePriv.update = true; filePriv.delete = true; filePriv.check = true; filePriv.reason = "inherit"; database.DX_PRIVILEGE.AddObject(filePriv); } } } } } } } int success = database.SaveChanges(); if (success > 0) { String message = Environment.NewLine + "Hi " + user.fname + "," + Environment.NewLine + "You request has been approved!" + Environment.NewLine + "You Can now login to your account to access your files" + Environment.NewLine + "- Docbox Team"; try { EmailMessaging.sendMessage(id, message, "Notification"); } catch { ModelState.AddModelError("", "User approved, but notification not send"); return(View("Error")); } //FormsAuthentication.SetAuthCookie(id, false); } } } } catch { ModelState.AddModelError("", "Error occured while assigning access level to the user"); } return(RedirectToAction("Index")); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { //TODO: Add fields to user here so they will be saved to the database //Create a new user with all the properties you need for the class var user = new AppUser { UserName = model.Email, Email = model.Email, FName = model.Fname, LName = model.Lname, StreetAddress = model.StreetAddress, City = model.City, ZipCode = model.ZipCode }; //Add the new user to the database var result = await UserManager.CreateAsync(user, model.Password); //TODO: Once you get roles working, you may want to add users to roles upon creation //await UserManager.AddToRoleAsync(user.Id, "User"); //adds user to role called "User" // --OR-- //await UserManager.AddToRoleAsync(user.Id, "Employee"); //adds user to role called "Employee" if (result.Succeeded) //user was created successfully { //sign the user in await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); string username = User.Identity.GetUserName(); AppUser currentuser = db.Users.FirstOrDefault(c => c.UserName == username); CreditCard creditcard1 = new CreditCard { CardNumber = model.CreditCard1, Customer = currentuser }; if (model.CreditCard1.Length == 15) { creditcard1.Cardtype = Cardtype.AmericanExpress; } else if (model.CreditCard1.StartsWith("54")) { creditcard1.Cardtype = Cardtype.MasterCard; } else if (model.CreditCard1.StartsWith("4")) { creditcard1.Cardtype = Cardtype.Visa; } else if (model.CreditCard1.StartsWith("6")) { creditcard1.Cardtype = Cardtype.Discover; } if (ModelState.IsValid) { db.CreditCards.Add(creditcard1); db.SaveChanges(); } if (model.CreditCard2 != null) { CreditCard creditcard2 = new CreditCard { CardNumber = model.CreditCard2, Customer = currentuser }; if (model.CreditCard2.Length == 15) { creditcard2.Cardtype = Cardtype.AmericanExpress; } else if (model.CreditCard2.StartsWith("54")) { creditcard2.Cardtype = Cardtype.MasterCard; } else if (model.CreditCard2.StartsWith("4")) { creditcard2.Cardtype = Cardtype.Visa; } else if (model.CreditCard2.StartsWith("6")) { creditcard2.Cardtype = Cardtype.Discover; } db.CreditCards.Add(creditcard2); db.SaveChanges(); } //Send a congratulatory email EmailMessaging.SendEmail(user.Email, "Welcome to Longhorn Music - Group 13!", "Thank you for signing up with Longhorn Music. You are now a registered user."); //send them to the home page return(RedirectToAction("Index", "Home")); } //if there was a problem, add the error messages to what we will display AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <IActionResult> Edit(int id, [Bind("InterviewID,InterviewDate,InterviewTiime,InterviewStatus,InterviewRoom,Recruiter,Student")] Interview interviewww, string SelectedRecruiter, int SelectedPosition, string SelectedStudent, int SelectedCompany) { //List<Interview> interviews = new List<Interview>(); //interviews = _context.Interviews.ToList(); ////foreach (Interview inter in interviews) //{ // if ((inter.InterviewDate == interviewww.InterviewDate) && (inter.InterviewTime == interviewww.InterviewTime) && (inter.InterviewRoom == interviewww.InterviewRoom)) // { // return View("Error"); // } //} AppUser recruiter = _context.AppUsers.Find(SelectedRecruiter); interviewww.Recruiter = recruiter; Position position = _context.Positions.Find(SelectedPosition); interviewww.Position = position; Company company = _context.Companies.Find(SelectedCompany); interviewww.Company = company; AppUser student = _context.AppUsers.Find(SelectedStudent); interviewww.Student = student; if (ModelState.IsValid) { _context.Update(interviewww); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } List <Interview> interviewsss = _context.Interviews.ToList(); AppUser interviewStatus; foreach (Interview i in interviewsss) { interviewStatus = (i.Student); if (interviewStatus != null) { String toEmailAddress = (i.Student.Email); String emailSubject = "Interview Confirmation"; String emailBody = "Interview Date: " + i.InterviewDate + "Interview Time: " + i.InterviewTime + "Interview Room: " + i.InterviewRoom + "Interview Position: " + i.Position + "Interviewer: " + i.Recruiter; EmailMessaging.SendEmail(toEmailAddress, emailSubject, emailBody); } } ViewBag.AllRecruiters = GetAllRecruiters(); ViewBag.AllPositions = GetAllPositions(); ViewBag.AllCompanies = GetAllCompanies(); ViewBag.AllStudents = GetAllStudents(); ViewBag.AllTimes = new SelectList(Enum.GetValues(typeof(InterviewTime))); return(View(interviewww)); }
private void SendCompleteCheckoutEmail(AppUser user) { var body = $@"Dear {user.FirstName}, you have placed an order and completed checkout"; EmailMessaging.SendEmail(user.Email, "Team 11 Order Completed Confirmation", body); }
private void SendOrderCancelEmail(AppUser user) { var body = $@"Dear {user.FirstName}, you have cancelled your order"; EmailMessaging.SendEmail(user.Email, "Team 11 Order Cancelled Confirmation", body); }
public ActionResult PurchaseConfirmed(int id) { Purchase purchase = db.Purchases.Find(id); string username = User.Identity.GetUserName(); AppUser currentuser = db.Users.FirstOrDefault(c => c.UserName == username); Cart cart = db.Carts.FirstOrDefault(c => c.Customer.UserName == currentuser.UserName); foreach (Product product in cart.Products) { AppUser recipient = purchase.Recipient; OrderDetail orderdetail = new OrderDetail(); orderdetail.ExtendedPrice = product.DiscountPrice; orderdetail.Product = product; orderdetail.Purchase = purchase; db.OrderDetails.Add(orderdetail); db.SaveChanges(); } db.Carts.Remove(cart); db.SaveChanges(); string name = currentuser.FName; name += currentuser.LName; ViewBag.Name = name; if (purchase.Gift == true) { string GiverEmailString = "Dear "; GiverEmailString += "<br />" + currentuser.FName + " " + currentuser.LName + ", <br /><br />"; //add new line GiverEmailString += "Thank you for your purchase! We have sent " + purchase.Recipient.Email; GiverEmailString += "<br /><br /> "; GiverEmailString += "If you feel you are being charged in error, click"; GiverEmailString += " < a href =\"http://CHYProject.azurewebsites.net/purchases/delete/" + purchase.PurchaseID + "\">here</a>"; GiverEmailString += "to pursue a refund."; EmailMessaging.SendEmail(currentuser.Email, "Thanks for your purchase!", GiverEmailString); string ReceiverEmailString = "Hello"; ReceiverEmailString += purchase.Recipient.FName + ", <br /><br />"; ReceiverEmailString += purchase.Customer.FName + "Has sent you a gift! To see what you've got, click"; ReceiverEmailString += " < a href =\"http://CHYProject.azurewebsites.net/purchases/details/" + purchase.PurchaseID + "\">here</a>"; ReceiverEmailString += ". Happy listening!"; EmailMessaging.SendEmail(currentuser.Email, "You've got a gift!", ReceiverEmailString); } else { string BuyerEmailString = "Dear"; BuyerEmailString += purchase.Customer.FName + ",<br /><br />"; BuyerEmailString += "Thank you for your purchase! To review it, click < a href =\"http://CHYProject.azurewebsites.net/purchases/details/" + purchase.PurchaseID + "\">here</a>"; BuyerEmailString += "<br /><br />If you feel you are being charged in error, click < a href =\"http://CHYProject.azurewebsites.net/purchases/delete/" + purchase.PurchaseID + "\">here</a>"; BuyerEmailString += "to pursue a refund."; EmailMessaging.SendEmail(currentuser.Email, "Thanks for your purchase!", BuyerEmailString); } return(View()); }
public ActionResult Payment(String Date, int SelectedAccount, int SelectedPayee, decimal Amount, string Description) { AppUser current = db.Users.Find(User.Identity.GetUserId()); BankAccount currentBank = db.BankAccounts.Find(SelectedAccount); List <BankAccount> outter = new List <BankAccount>(); foreach (BankAccount account in current.BankAccounts) { if (account.Type == AccountTypes.Savings || account.Type == AccountTypes.Checking) { outter.Add(account); } } if (Amount < 0) { ViewBag.Message = "You must enter a positive number for payment"; ViewBag.Accounts = new SelectList(outter, "BankAccountID", "NameNo"); ViewBag.Payees = new SelectList(current.Payees, "PayeeID", "Name"); return(View()); } else if (DateTime.Parse(Date) < DateTime.Now.AddDays(-1)) { ViewBag.Message = "You cannot make a Payment in the past"; ViewBag.Accounts = new SelectList(outter, "BankAccountID", "NameNo"); ViewBag.Payees = new SelectList(current.Payees, "PayeeID", "Name"); return(View()); } //if overdraft else if (Amount > currentBank.Balance && Amount < currentBank.Balance + 50) { currentBank.Balance -= 30; Transaction overdraftfee = new Transaction() { Date = DateTime.Now, Type = TransactionTypes.Fee, Amount = 30, Description = "Overdraft Fee", Customer = current, FromAccount = currentBank }; currentBank.Transactions.Add(overdraftfee); db.Transactions.Add(overdraftfee); //TODO: Send email. EmailMessaging.SendEmail("*****@*****.**", "Team 22:Overdraft Notification", "You have overdrafter from account " + currentBank.NameNo + ". \n There was a $30 fee. The account's current Balance is " + Convert.ToString(currentBank.Balance)); db.SaveChanges(); } else if (Amount > currentBank.Balance + 50) { ViewBag.Message = "You have exceed the overdraft limit with this transaction"; ViewBag.Accounts = new SelectList(outter, "BankAccountID", "NameNo"); ViewBag.Payees = new SelectList(current.Payees, "PayeeID", "Name"); return(View()); } //regular currentBank.Balance -= Amount; Transaction trans = new Transaction() { Date = DateTime.Parse(Date), Type = TransactionTypes.Withdrawal, Amount = Amount, Description = Description, Customer = current, FromAccount = currentBank }; currentBank.Transactions.Add(trans); db.Transactions.Add(trans); db.SaveChanges(); return(RedirectToAction("Index", "Customers")); }
private void SendMovieCancelEmail(AppUser user) { var body = $@"Dear {user.FirstName}, you have cancelled a movie"; EmailMessaging.SendEmail(user.Email, "Team 11 Movie Cancelled Confirmation", body); }
private void SendMovieRescheduleEmail(AppUser user) { var body = $@"Dear {user.FirstName}, you have rescheduled a movie"; EmailMessaging.SendEmail(user.Email, "Team 11 Movie Reschedule Confirmation", body); }
public ActionResult Register(RegisterModel model) { try { populateDepartmenetsList(); if (ModelState.IsValid) { FormsAuthentication.SignOut(); if (validateModelRegister(model) == false) { ViewBag.CaptchaGuid = Guid.NewGuid().ToString("N"); return(View(model)); } ViewBag.CaptchaGuid = Guid.NewGuid().ToString("N"); var allusers = from usertabel in database.DX_USER where usertabel.userid == model.Email select usertabel; if (allusers.ToList().Count == 1) { ModelState.AddModelError("", "Email id not unique, please enter a diffrent valid email id!"); return(View(model)); } var alldepartment = from usertabel in database.DX_DEPARTMENT where model.Department.Contains(usertabel.deptid) select usertabel; if (Constants.POSITION_CEO_USER.Equals(model.Position)) { alldepartment = from usertabel in database.DX_DEPARTMENT select usertabel; } if (alldepartment.ToList().Count >= 1) { DX_USER user = new DX_USER(); user.fname = model.FirstName; user.lname = model.LastName; user.phone = model.Phone; user.questionid = model.Squestion; user.role = model.Position; user.userid = model.Email; user.anshash = generateHash(model.Answer.ToLower()); user.accesslevel = Constants.TEMP_USER_ACCESS; user.salt = generateSalt(); user.pwdhash = generateHash(user.salt, model.Password); user.actcodehash = "dummycode"; database.DX_USER.AddObject(user);//Add user foreach (DX_DEPARTMENT dept in alldepartment.ToList()) { DX_USERDEPT userDept = new DX_USERDEPT(); userDept.deptid = dept.deptid; userDept.userid = model.Email; database.DX_USERDEPT.AddObject(userDept);//Add department } int success = database.SaveChanges(); if (success > 0) { String message = Environment.NewLine + "Hi " + model.FirstName + "," + Environment.NewLine + "Thank you for registering with Docbox!" + Environment.NewLine + "You will soon get notification, once you are been approved by Docbox Administrator" + Environment.NewLine + "- Docbox Team"; try { EmailMessaging.sendMessage(model.Email, message, "Notification"); } catch { ModelState.AddModelError("", "User created but unabe to log in at this point of time try logging in after some time!"); return(View(model)); } FormsAuthentication.SetAuthCookie(model.Email, false); return(RedirectToAction("Index", "TempUser")); } else { ModelState.AddModelError("", "User can not be registered, Please try after some time!"); return(View(model)); } } else { ModelState.AddModelError("", "Invalid Department Select Correct Department"); return(View(model)); } } } catch (Exception) { ModelState.AddModelError("", "Invalid request please try after some time! "); } // If we got this far, something failed, redisplay form return(View(model)); }