public ActionResult Delete(int imageID, int userID, int compID) { try { ScoreCardImage scard = db.ScoreCardImages.Find(imageID); db.ScoreCardImages.Remove(scard); db.SaveChanges(); // Inform Admin that the pending scorecard has been removed MessageInfo messageInfo = new MessageInfo(); UserInfo userInfo = new UserInfo(); var AllAdmin = userInfo.GetAllAdmin(); string AdminEmail = ""; string Subject = ""; string Body = ""; string userName = userInfo.GetUserName(Convert.ToInt32(userID)); foreach (var item in AllAdmin) { // messageInfo.CreateMessage(newprofile.UserID, item.UserID, DateTime.Now, user.UserName + " has registered to join Tigerline Scores."); AdminEmail = item.Email; Subject = "PLAYER PENDING SCORECARD REMOVED"; Body = "<span style='font-family: Calibri; font-size: 24px; font-weight: bold; color: green'>TIGERLINE SCORES</span><br/><br/>"; Body += "<span style='font-family: Calibri'>Player " + userName + " has removed their pending scorecard ..<br/><br/>"; Body += "<a href='www.tigerlinescores.co.uk'>Tigerline Scores</a>"; messageInfo.SendEmail(AdminEmail, Subject, Body, null); } return(RedirectToAction("PendingScoreCards", new { userID = userID, compID = compID })); } catch {//TODO: Log error return(Content(Boolean.FalseString)); } }
public ActionResult Create([Bind(Include = "ImageID,CompID,CardImage,Processed,Note,UserID,RoundDate,CourseID,TeeColour,SSS")] ScoreCardImage scoreCardImage) { if (ModelState.IsValid) { // Deal with uploaded Score Card Photo PENDING ****************************** string scorecardfileName = ""; HttpPostedFileBase scorecard = Request.Files["UploadScoreCard"]; if (scorecard.FileName != "" && scoreCardImage.UserID != null) { scorecardfileName = scoreCardImage.UserID + new FileInfo(scorecard.FileName).Name; string path = Path.Combine(Server.MapPath("~/ScoreCards/Pending"), scorecardfileName); //Reduce size of file if required and save in large folder WebImage img = new WebImage(scorecard.InputStream); if (img.Height > 1200) { img.Resize(1200, 1200, true); } img.Save(path); TempData["FailUpload"] = null; TempData["SuccessUpload"] = "Score Card Image successfully Uploaded. You can edit this pending score card by selecting 'My Pending Score Cards' on the main menu .."; // Save the Score Card Image scoreCardImage.CardImage = "/ScoreCards/Pending/" + scorecardfileName; scoreCardImage.Processed = false; db.ScoreCardImages.Add(scoreCardImage); db.SaveChanges(); // Remove the FIRST Upcoming Round Record // List of Upcoming Rounds int CompID = scoreCardImage.CompID; int compPlayerID = Convert.ToInt32(Session["CompPlayerID"]); var FirstRnd = (from rd in db.UpcomingRnds where rd.CompPlayerID == compPlayerID && rd.CompID == CompID orderby rd.RndDate select rd).First(); db.UpcomingRnds.Remove(FirstRnd); db.SaveChanges(); // Send email to Admin to inform of new scorecard upload MessageInfo messageInfo = new MessageInfo(); UserInfo userInfo = new UserInfo(); var AllAdmin = userInfo.GetAllAdmin(); string AdminEmail = ""; string Subject = ""; string Body = ""; string userName = userInfo.GetUserName(Convert.ToInt32(scoreCardImage.UserID)); foreach (var item in AllAdmin) { // messageInfo.CreateMessage(newprofile.UserID, item.UserID, DateTime.Now, user.UserName + " has registered to join Tigerline Scores."); AdminEmail = item.Email; Subject = "PLAYER SCORECARD IMAGE UPLOADED"; Body = "<span style='font-family: Calibri; font-size: 24px; font-weight: bold; color: green'>TIGERLINE SCORES</span><br/><br/>"; Body += "<span style='font-family: Calibri'>Player " + userName + " has uploaded a new scorecard image ..<br/><br/>"; Body += "<a href='www.tigerlinescores.co.uk'>Tigerline Scores</a>"; messageInfo.SendEmail(AdminEmail, Subject, Body, null); } return(RedirectToAction("Index", "PLayerCompList")); } else { TempData["FailUpload"] = "Unable to upload the score card image .."; TempData["SuccessUpload"] = null; } } return(RedirectToAction("Index", "PLayerCompList")); }
public ActionResult Edit([Bind(Include = "ImageID,CompID,CardImage,Processed,Note,UserID,RoundDate,CourseID,TeeColour,SSS")] ScoreCardImage scoreCardImage) { if (ModelState.IsValid) { string scorecardfileName = ""; HttpPostedFileBase scorecard = Request.Files["UploadScoreCard"]; if (scorecard.FileName != "" && scoreCardImage.UserID != null) //Deal with New Score Card Image { scorecardfileName = scoreCardImage.UserID + new FileInfo(scorecard.FileName).Name; string path = Path.Combine(Server.MapPath("~/ScoreCards/Pending"), scorecardfileName); //Reduce size of file if required and save in large folder WebImage img = new WebImage(scorecard.InputStream); if (img.Height > 1200) { img.Resize(1200, 1200, true); } img.Save(path); TempData["FailUpload"] = null; TempData["SuccessUpload"] = "Your NEW score card image has been successfully uploaded"; // Save the Score Card Image scoreCardImage.CardImage = "/ScoreCards/Pending/" + scorecardfileName; } else { TempData["SuccessUpload"] = "Your pending score card has been successfully edited"; } db.Entry(scoreCardImage).State = EntityState.Modified; db.SaveChanges(); // Send email to Admin to inform of edited score card image. MessageInfo messageInfo = new MessageInfo(); UserInfo userInfo = new UserInfo(); var AllAdmin = userInfo.GetAllAdmin(); string AdminEmail = ""; string Subject = ""; string Body = ""; string userName = userInfo.GetUserName(Convert.ToInt32(scoreCardImage.UserID)); foreach (var item in AllAdmin) { // messageInfo.CreateMessage(newprofile.UserID, item.UserID, DateTime.Now, user.UserName + " has registered to join Tigerline Scores."); AdminEmail = item.Email; Subject = "PLAYER PENDING SCORECARD EDITED"; Body = "<span style='font-family: Calibri; font-size: 24px; font-weight: bold; color: green'>TIGERLINE SCORES</span><br/><br/>"; Body += "<span style='font-family: Calibri'>Player " + userName + " has edited their pending scorecard ..<br/><br/>"; Body += "<a href='www.tigerlinescores.co.uk'>Tigerline Scores</a>"; messageInfo.SendEmail(AdminEmail, Subject, Body, null); } // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.CourseList = courseInfo.GetCourseList(); // Tee Colour List List <SelectListItem> teecolor = new List <SelectListItem>(); teecolor.Add(new SelectListItem() { Text = "White", Value = "White" }); teecolor.Add(new SelectListItem() { Text = "Yellow", Value = "Yellow" }); teecolor.Add(new SelectListItem() { Text = "Red", Value = "Red" }); ViewBag.TeeColour = teecolor; } return(View(scoreCardImage)); }
public ActionResult Register(UserProfile userProfile) { if (ModelState.IsValid) { // Has email already been registered? var emailDuplicated = checkEmail(userProfile.Email); if (emailDuplicated == true) { TempData["Message"] = userProfile.Email + Environment.NewLine + "This Email address has already been registered."; return(RedirectToAction("Index")); } // Create the User Record User user = new Models.User(); user.UserName = userProfile.UserName; user.Email = userProfile.Email; user.Admin = false; // Create a random password for this user UserInfo uInfo = new UserInfo(); string password = uInfo.CreatePassword(6); user.Password = password; db.Users.Add(user); db.SaveChanges(); // Create the Profile Record var newprofile = new Profile(); newprofile.UserID = user.UserID; newprofile.HomeClubID = userProfile.HomeCourseID; newprofile.Handicap = userProfile.Handicap; newprofile.Photo = "/Images/Default Profile Photo.jpg"; db.Profiles.Add(newprofile); db.SaveChanges(); // Create New Message to Inform Admin of NEW user MessageInfo messageInfo = new MessageInfo(); var AllAdmin = uInfo.GetAllAdmin(); string AdminEmail = ""; string Subject = ""; string Body = ""; foreach (var item in AllAdmin) { messageInfo.CreateMessage(newprofile.UserID, item.UserID, DateTime.Now, user.UserName + " has registered to join Tigerline Scores."); AdminEmail = item.Email; // Send Email to Admin Subject = "NEW USER HAS REGISTERED"; Body = "<span style='font-family: Calibri; font-size: 24px; font-weight: bold; color: green'>TIGERLINE SCORES</span><br/><br/>"; Body += "<span style='font-family: Calibri'>New user " + user.UserName + " has registered to use Tigerline Scores..<br/><br/>"; Body += "<a href='www.tigerlinescores.co.uk'>Tigerline Scores</a>"; messageInfo.SendEmail(AdminEmail, Subject, Body, null); } // Send email to new user with NEW password (created above) and instructions on how to use Tigerline Scores Body = "<span style='font-family: Calibri; font-size: 24px; font-weight: bold; color: green'>TIGERLINE SCORES</span><br/><br/>"; Body += "<div style='font-family: Calibri; font-size: 14px'>" + user.UserName + "<br/><br/>Thanks for registering and welcome to Tigerline Scores.<br/><br/>"; Body += "Your login details are : <br/><br/>"; Body += "<span style='font-weight: bold'>" + user.Email + "</span><br/>"; Body += "Password <span style='font-weight: bold'>" + password + "</span><br/><br/>"; Body += "Attached to this email are instructions on how to find your way around the site, how to register an upcoming round and how to upload your score cards.<br/><br/>"; Body += "I hope you enjoy using Tigerline Scores. Please feel free to send me any comments you have about the site as I am still developing and improving it.<br/>"; Body += "Send your emails to [email protected]<br/><br/>"; Body += "Thanks again and good luck!<br/><br/>Martin<br/><br/>"; Body += "<a href='www.tigerlinescores.co.uk'>Tigerline Scores</a>"; Body += "</div>"; string userEmail = user.Email; Subject = "Welcome to Tigerline Scores"; string attachment = Server.MapPath("~/Images/Tigerline_Scores_Instructions.pdf"); messageInfo.SendEmail(userEmail, Subject, Body, attachment); TempData["Register"] = "Thanks for registering to join Tigerline Scores." + Environment.NewLine + "An email will be sent to you shortly with your password and information about how to use Tigerline Scores. Use your email address and the password to login into this site."; return(RedirectToAction("Index")); } return(View("Index")); }