public static void ChangeClasses(int showId, int userId, int dogId, int[] newClsIds) { AppException.LogEvent($"Change Classes Dog (UserId={userId}, DogId={dogId}) showid={showId}"); try { var dc = new DogClasses(dogId, showId); dc.Save(dogId, showId, newClsIds.ToList(), null, dc.Lho); var us = new UserShows(userId, showId); var comms = new EmailManager(); comms.SendEntryEmail(showId, userId, us.RefCode); } catch (Exception e) { AppException.LogError($"Error:ChangeClasses:{e.Message}, {e.StackTrace}"); } }
public static UserShows SaveEntry(ShowEntry showEntry) { DogClasses dc = new DogClasses(); String[] dogs = new String[] { }; if (showEntry.EnterData != null) { dogs = showEntry.EnterData.Split(','); } else { AppException.LogEvent(string.Format("SaveEntry: data length = 0, {0}{1}", showEntry.ShowId, showEntry.UserId)); } var altHandlersList = new string[] { }; if (showEntry.AltHandlersList != null) { altHandlersList = showEntry.AltHandlersList.Split(','); } // // Multidog format is packed as // <dogid>@<clsid>:<handlername>.<dogname>[;<handlername>.<dogname>][,<dogid>#<clsid>:<handlername>.<dogname>[;<handlername>.<dogname>]](captain$$teamname) // MultiDog.DeleteUserFromShow(showEntry.UserId, showEntry.ShowId); if (!string.IsNullOrEmpty(showEntry.PairsTeams)) { var spt = Regex.Split(showEntry.PairsTeams, "[|]"); var captain = ""; var teamName = ""; if (spt.Length > 1) { var s = Regex.Split(spt[1], "[$]"); captain = s[0]; teamName = s[1]; if (captain.Length > 0 && teamName.Length > 0) { MultiDog.AddTeamPairsDetails(showEntry.ShowId, showEntry.UserId, captain, teamName,1,-1); } } var pairTeams = spt[0].Split(','); foreach (String pairTeam in pairTeams) { String[] pt = pairTeam.Split(';'); int DogID = -1; int ClsID = -1; ; foreach (String p in pt) { String[] dogcls; String[] otherHandlerDog; if (p.IndexOf(':') > 0) { dogcls = p.Split(':')[0].Split('@'); DogID = Convert.ToInt32(dogcls[0]); ClsID = Convert.ToInt32(dogcls[1]); otherHandlerDog = p.Split(':')[1].Split('.'); String[] handlerDetails = otherHandlerDog[0].Split('-'); if (handlerDetails.Length > 1) { String handlerName = handlerDetails[0]; int handlerID = -1; int.TryParse(handlerDetails[1], out handlerID); String[] dogDetails = otherHandlerDog[1].Split('-'); String dogName = dogDetails[0]; int dogID = -1; int.TryParse(dogDetails[1], out dogID); MultiDog.Add(1, showEntry.UserId, DogID, ClsID, showEntry.ShowId, handlerName, dogName, handlerID, dogID,1); } else { MultiDog.Add(showEntry.UserId, DogID, ClsID, showEntry.ShowId, otherHandlerDog[0], otherHandlerDog[1]); } } else { otherHandlerDog = p.Split('.'); String[] handlerDetails = otherHandlerDog[0].Split('-'); if (handlerDetails.Length > 1) { String handlerName = handlerDetails[0]; int handlerID = -1; int.TryParse(handlerDetails[1], out handlerID); String[] dogDetails = otherHandlerDog[1].Split('-'); String dogName = dogDetails[0]; int dogID = -1; int.TryParse(dogDetails[1], out dogID); MultiDog.Add(1, showEntry.UserId, DogID, ClsID, showEntry.ShowId, handlerName, dogName, handlerID, dogID,1); } } } } } foreach (String dog in dogs) { String[] details = dog.Split(':'); int dogid = Convert.ToInt32(details[0]); String[] clslist = details[1].Split('.'); List<int> classes = new List<int>(); List<int> altHandlers = new List<int>(); foreach (String clsid in clslist) { if (clsid.Length > 0) { int altid = 0; classes.Add(Convert.ToInt32(clsid)); for (int ii = 0; ii < altHandlersList.Length; ii++) { String[] kvPairs = altHandlersList[ii].Split(':'); if (kvPairs[0] == clsid && kvPairs[2] == details[0]) { altid = Convert.ToInt32(kvPairs[1]); } } altHandlers.Add(altid); } } dc.Save(dogid, showEntry.ShowId, classes, altHandlers, -1); } UserShows us = new UserShows(showEntry.UserId, showEntry.ShowId); us.Status = us.Status = (int)UserShows.UserStatus.STATUS_SAVED; // // add check to see if this person is on the judging list. if (showEntry.HandlerType != (int)UserShows.HandlerTypes.MEMBER && Judge.isJudgeAtShow(showEntry.UserId, showEntry.ShowId)) { us.HandlerType = (int)UserShows.HandlerTypes.JUDGE; } else { us.HandlerType = showEntry.HandlerType; } us.Optout = showEntry.OptOut; us.DogsMeasured = showEntry.DogsMeasured; us.Save(); Camping camping = new Camping(showEntry.ShowId); if (camping.ID > -1) { if (!string.IsNullOrEmpty(showEntry.CampingDays)) { UserCamping.DeleteForUser(us.ID); for (var i = 0; i < showEntry.Plots; i++) { UserCamping.Add(us.ID, showEntry.CampingParty, showEntry.CampComments, showEntry.CampingDays, showEntry.PitchSize); } } } if (showEntry.WaitingList == 1) { WaitingList.Add(us.ShowID, us.Userid); } return us; }
public static UserShows SaveEntryv2(UserShowEntry showEntry) { DogClasses dc = new DogClasses(); var altHandlersList = new string[] { }; UserShows us = new UserShows(showEntry.UserId, showEntry.ShowId); try { MultiDog.DeleteUserFromShow(showEntry.UserId, showEntry.ShowId); try { if (showEntry.MultiDogEntries != null && showEntry.MultiDogEntries.Any()) { var idx = 1; var teamPairsId = 0; foreach (var md in showEntry.MultiDogEntries) { teamPairsId = MultiDog.AddTeamPairsDetails(showEntry.ShowId, showEntry.UserId, md.TeamDetails.Captain, md.TeamDetails.TeamName, idx, md.ClassId); foreach (var member in md.Members) { MultiDog.Add(teamPairsId, showEntry.UserId, member.DogId, md.ClassId, showEntry.ShowId, member.HandlerName ?? "", member.DogName ?? "", member.HandlerId, member.DogId, idx); } idx++; } } } catch (Exception e) { AppException.Log(string.Format("SaveEntryv2 Error MultiDogs (ShowId={0}, UserId={1} [{2}][{3}]", showEntry.ShowId, showEntry.UserId, e.Message, e.StackTrace), ""); } foreach (DogsModel dog in showEntry.Dogs) { dc.Save(showEntry.ShowId, dog); if (dog.ClassNo != null) { var ykc = dog.ClassNo.Where(y => y.Juniors != null); if (ykc.Any()) { var y = ykc.First(); if (y.Juniors.Id == 0) { Juniors.AddJunior(dog.Id, y.Id, y.Juniors.DoB, y.Juniors.YKCNumber); } else { var jnr = new Juniors(y.Juniors.Id); jnr.DogId = dog.Id; jnr.ClassId = y.Id; jnr.YKCNumber = y.Juniors.YKCNumber; jnr.DoB = y.Juniors.DoB; jnr.Save(); } } var g7dogs = dog.ClassNo.Where(x => x.ChampWins != null && x.ChampWins.Any()); foreach (var d in g7dogs) { foreach (var win in d.ChampWins) { if (!string.IsNullOrEmpty(win.ShowName) && !string.IsNullOrEmpty(win.ShowClass)) { DateTime parsedDate = DateTime.MinValue; if (!DateTime.TryParseExact(win.ShowDate, "dd-MM-yy", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedDate)) { DateTime.TryParseExact(win.ShowDate, "dd-MM-yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedDate); } Fpp.Business.DogHistory.AddChampWins(new Core.Views.UpgradeDogView { Id = win.Id, ShowName = win.ShowName, ClassWon = win.ShowClass, WinDate = parsedDate, UserId = showEntry.UserId, DogId = dog.Id, NewGrade = 7, Comments = "Win towards grade 7", UpgradeType = win.UpgradeType, DateOfWin = win.ShowDate }); } } } } } if (us.Status != (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID) { us.Status = us.Status = (int)UserShows.UserStatus.STATUS_SAVED; } // // add check to see if this person is on the judging list. if (showEntry.HandlerType != (int)UserShows.HandlerTypes.MEMBER && Judge.isJudgeAtShow(showEntry.UserId, showEntry.ShowId)) { us.HandlerType = (int)UserShows.HandlerTypes.JUDGE; } else { us.HandlerType = showEntry.HandlerType; } us.Optout = showEntry.OptOut; us.DogsMeasured = showEntry.DogsMeasured; us.Save(); Camping camping = new Camping(showEntry.ShowId); if (camping.ID > -1) { var oldcamp = new UserCamping(us.ID); UserCamping.DeleteForUser(us.ID); if (showEntry.UserCamping != null) { for (var i = 0; i < showEntry.UserCamping.Plots; i++) { UserCamping.Add(us.ID, showEntry.UserCamping); } var uc = new UserCamping(us.ID); if (oldcamp.ID > -1 && oldcamp.PitchDetails.Any() ) { UserCamping.SetCode(uc.PitchDetails[0].ID, oldcamp.PitchDetails[0].CampingCode); UserCamping.SetComments(uc.PitchDetails[0].ID, oldcamp.PitchDetails[0].Comments); UserCamping.SetPitchNo(uc.PitchDetails[0].ID, oldcamp.PitchDetails[0].PitchNo); if (uc.PitchDetails.Count > 1 && oldcamp.PitchDetails.Count > 1) { UserCamping.SetCode(uc.PitchDetails[1].ID, oldcamp.PitchDetails[1].CampingCode); UserCamping.SetComments(uc.PitchDetails[1].ID, oldcamp.PitchDetails[1].Comments); UserCamping.SetPitchNo(uc.PitchDetails[1].ID, oldcamp.PitchDetails[1].PitchNo); } } } } if (showEntry.UserCamping != null && showEntry.UserCamping.WaitingList == 1) { WaitingList.Add(showEntry.ShowId, showEntry.UserId); } } catch (Exception e) { AppException.Log( string.Format("SaveEntryv2 Error (ShowId={0}, UserId={1} [{2}][{3}]", showEntry.ShowId, showEntry.UserId, e.Message, e.StackTrace), ""); } return us; }
private void printRingForUser(UserShows userShow, int UserID, Document doc, ref List<int> defaultUsers, ref int pageCount) { float[] ringColumns = new float[] { 300, 300, 300, 300 }; User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); List<ShowDetails> showDetailsList = ShowDetails.GetShowDetails(userShow.ShowID); Rings r = new Rings(); DataSet ringList = r.GetAllRingsForShow(userShow.ShowID, "ShowDate"); Dogs d = new Dogs(); DogClasses dc = new DogClasses(); DateTime dt = DateTime.Now; string currentJudge = ""; int currentRingID = 0; int ShowDetailsID = -1; int PrevShowDetailsID = -1; PdfPTable rings = new PdfPTable(ringColumns); int ringCnt = 0; PdfPCell cell = null; PdfPTable ringDetails = null; PdfPTable classDetailsTable = null; List<int> dogsRunningToday = new List<int>(); PdfPTable headerPage = null; List<TeamPairsTrioDto> pairsTeams = new List<TeamPairsTrioDto>(); try { foreach (DataRow ringRow in ringList.Tables[0].Rows) { Rings ring = new Rings(ringRow); int RingID = Convert.ToInt32(ringRow["RingID"]); int EntryType = Convert.ToInt32(ringRow["EntryType"]); int Lho = Convert.ToInt32(ringRow["Lho"]); ShowDetailsID = Convert.ToInt32(ringRow["ShowDetailsID"]); if (ringRow.IsNull("ClassID")) { continue; } int ClassID = Convert.ToInt32(ringRow["ClassID"]); int ClassNo = Convert.ToInt32(ringRow["ClsNo"]); DateTime rowDT = Convert.ToDateTime(ringRow["ShowDate"]); if (rowDT != dt) { if (currentRingID != 0) { if (ringCnt % MaxColumns != 0) { var remind = ringCnt % MaxColumns; while (remind-- > 0) { cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; rings.AddCell(cell); } } if (dogsRunningToday.Count() > 0 || UserID == -1) { doc.Add(headerPage); doc.Add(rings); if (UserID > -1) { if (currentUser.UserID != UserID) { User defaultHandler = new User(UserID); } } doc.NewPage(); pageCount++; } } dogsRunningToday.Clear(); if (UserID > -1) { if (currentUser.UserID == UserID) { headerPage = DrawHeader(show, rowDT, currentUser, userShow); } else { User defaultHandler = new User(UserID); headerPage = DrawHeader(show, rowDT, defaultHandler, userShow); } } else { headerPage = DrawHeader(show, rowDT, null, null); } dt = rowDT; rings = new PdfPTable(ringColumns); rings.WidthPercentage = 100; ringCnt = 0; } if (currentRingID != RingID) { currentJudge = ""; ringCnt++; ringDetails = new PdfPTable(1); rings.AddCell(new PdfPCell(ringDetails)); //List<Judge> judgeList = Judge.getJudgesForRingList(RingID); string JudgeName = Judge.getJudgeForClass(ClassID).Name; int ClsCount = DogClasses.GetDogsInRing(RingID); cell = new PdfPCell(new Phrase(new Chunk(string.Format("Ring No {0} ({1})", ringRow["RingNo"].ToString(), ClsCount), judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); if (currentJudge != JudgeName) { cell = new PdfPCell(new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(JudgeName), judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); currentJudge = JudgeName; } currentRingID = RingID; classDetailsTable = new PdfPTable(DetailsColWidths); classDetailsTable.DefaultCell.BorderWidth = 0; ringDetails.AddCell(classDetailsTable); } else { string JudgeName = Judge.getJudgeForClass(ClassID).Name; if (currentJudge != JudgeName) { cell = new PdfPCell(new Phrase(new Chunk(" ", judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(JudgeName), judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); classDetailsTable = new PdfPTable(DetailsColWidths); classDetailsTable.DefaultCell.BorderWidth = 0; ringDetails.AddCell(classDetailsTable); currentJudge = JudgeName; } } DataSet dogsList = d.GetDogsInClass(userShow.Userid, ClassID); int dogsInClass = d.dogsInClassCount(ClassID); List<DogClassCount> dcCounts = DogClasses.GetEntryCountsByClassId(userShow.ShowID, ClassID); String clsName; var part = Convert.ToInt32(ringRow["Part"]); var lhoInd = ""; var dogsInClassDisplay = ""; if (dcCounts.Count > 1) { if (Lho == 1) { dogsInClassDisplay = String.Format("({0}/{1})", dcCounts[0].Count, dcCounts[1].Count); } else { dogsInClassDisplay = String.Format("({0}/{1})", dcCounts[1].Count, dcCounts[0].Count); } } else { dogsInClassDisplay = String.Format("({0})", dogsInClass); } if (Lho == 1) { lhoInd = "(FH 1st)"; } else if (Lho == 2) { lhoInd = "(LHO 1st)"; } if (EntryType != 10) { clsName = new ShowClasses(ClassID).NormalName(withClassNo:false, useAbbrFlag:true); } else { clsName = String.Format("{0} {1} {2} ", ShowClasses.expandHeight(ringRow), ringRow["LongName"].ToString().Trim(), ringRow["name"].ToString().Trim()); } clsName = clsName.Replace("(Special Class", "S"); clsName = clsName.Replace("(Money Class", "Money"); clsName = clsName.Replace("First Place Processing", "FPP"); clsName = clsName.Replace("First Contact", "FC"); clsName = clsName.Replace("Qualifier", "Q"); if (part > 0 && EntryType != 10) { clsName += "Pt " + part; } if (dogsList.Tables[0].Rows.Count > 0) { /* Combined 1-7 All Allsorts Agility sponsored by paws for a walk Combined 6-7 Medium Agility * */ var WrapClassDescription = clsName.Length > 45; Phrase[] tmpCells = new Phrase[3]; tmpCells[0] = new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogInClass)); tmpCells[1] = new Phrase(new Chunk(clsName, dogInClass)); tmpCells[2] = new Phrase(new Chunk(dogsInClassDisplay, dogNotInClass )); int countDogs = 0; int DefaultHandler; Paragraph p = new Paragraph(); List<Paragraph> allDogsInClass = new List<Paragraph>(); foreach (DataRow dogRow in dogsList.Tables[0].Rows) { var dogLho = Convert.ToInt32(dogRow["Lho"]); int DogID = Convert.ToInt32(dogRow["DogID"]); DefaultHandler = Convert.ToInt32(dogRow["DefaultHandler"]); if (DefaultHandler == 0) DefaultHandler = -1; if ((DefaultHandler == -1 && currentUser.UserID == UserID) || (DefaultHandler == UserID) ) { if (countDogs == 0) { cell = new PdfPCell(tmpCells[0]); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); var namePara = new Paragraph(); namePara.Add(tmpCells[1]); namePara.Add(new Phrase(new Chunk(lhoInd, lhoFontBold))); p.Add(namePara); } if (!dogsRunningToday.Contains(DogID)) { dogsRunningToday.Add(DogID); } String dogName = dogRow["DogName"].ToString(); if (dogName.Length == 0) { dogName = dogRow["KCName"].ToString(); } var chunk = new Chunk(" ", dogDetailsInClass); chunk.SetBackground(new Color(System.Drawing.ColorTranslator.FromHtml(dogRow["DogColour"].ToString()))); var dogPara = new Paragraph(); dogPara.Add(new Phrase(chunk)); if (TeamPairsManager.isMultiDog( EntryType )) { pairsTeams.Add(new TeamPairsTrioDto { ClassId = ClassID, ClassNo = ClassNo, DogId = DogID, DogName = dogName, RO = -1 }); } dogPara.Add(new Phrase(new Chunk(String.Format(" [{1}] {0}", Fpp.Core.Utils.TitleCaseString(dogName), dogRow["RO"]), dogDetailsInClass))); dogPara.Add(new Phrase(new Chunk(String.Format("{0}", (dogLho == 0 ? "" : " (LHO)")), font8))); dogPara.Add(Chunk.NEWLINE); int AltHandler = Convert.ToInt32(dogRow["AltHandler"]); String HandlerName = ""; if (AltHandler > 0) { User u = new User(AltHandler); HandlerName = u.Name; dogPara.Add(new Phrase(new Chunk(String.Format("Handler:{0}", Fpp.Core.Utils.TitleCaseString(HandlerName)), dogInClass))); } allDogsInClass.Add(dogPara); countDogs++; } else { if (defaultUsers != null && defaultUsers.IndexOf(DefaultHandler) == -1) { defaultUsers.Add(DefaultHandler); } } } if (countDogs == 0) { cell = new PdfPCell(new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); var namePara = new Paragraph(); namePara.Add(new Phrase(new Chunk(clsName, dogNotInClass))); namePara.Add(new Phrase(new Chunk(lhoInd, lhoFontBold))); p.Add(namePara); cell = new PdfPCell(p); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dogsInClassDisplay, dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); } else { cell = new PdfPCell(p); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); cell = new PdfPCell(tmpCells[2]); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", dogDetailsInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); var tbl4Dogs = new PdfPTable(1); foreach (var item in allDogsInClass) { cell = new PdfPCell(new Phrase(item)); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; tbl4Dogs.AddCell(cell); } cell = new PdfPCell(); cell.BorderWidth = 0; cell.FixedHeight = 4f; tbl4Dogs.AddCell(cell); cell = new PdfPCell(tbl4Dogs); cell.BorderWidth = 0; cell.Colspan = 2; classDetailsTable.AddCell(cell); } } else { cell = new PdfPCell(new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); var namePara = new Paragraph(); namePara.Add(new Phrase(new Chunk(clsName, dogNotInClass))); namePara.Add(new Phrase(new Chunk(lhoInd, lhoFontBold))); cell = new PdfPCell(namePara); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dogsInClassDisplay, dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); } PrevShowDetailsID = ShowDetailsID; } if (dogsRunningToday.Count() > 0 || UserID == -1) { if (ringCnt % MaxColumns != 0) { var remind = ringCnt % MaxColumns; while (remind-- > 0) { cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; rings.AddCell(cell); } doc.Add(headerPage); doc.Add(rings); } if (UserID > -1) { if (currentUser.UserID != UserID) { User defaultHandler = new User(UserID); } } doc.NewPage(); pageCount++; } else { if (dogsRunningToday.Count() > 0) { if (ringCnt % MaxColumns != 0) { var remind = ringCnt % MaxColumns; while (remind-- > 0) { cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; rings.AddCell(cell); } doc.Add(headerPage); doc.Add(rings); } if (UserID > -1) { if (currentUser.UserID != UserID) { User defaultHandler = new User(UserID); } } doc.NewPage(); pageCount++; } } } catch (Exception e) { AppException.LogError($"Error Running Plan:{e.Message},{e.StackTrace}"); } }
public void ChangeHandlerName(int classId, int dogId, string handlerName) { var dc = new DogClasses(); dc.ChangeHandlerName(classId, dogId, handlerName); }
private String getEntrySummary(UserShows us) { Shows thisShow = new Shows(us.ShowID); UserDogDetails userDetails = new UserDogDetails(); Dogs dog = new Dogs(); userDetails.DogDetails = Dogs.GetAllDogsForHandler(us.Userid, thisShow.ShowDate); userDetails.UserDetails = new User(us.Userid); UserCamping userCamping = new UserCamping(us.ID); List<Business.Helpers> helpersList = Business.Helpers.HelperForShow(us.ShowID, us.Userid); List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(us.ShowID); String html = "<input type='hidden' name='showid' value='" + us.ShowID.ToString() + "' /><input type='hidden' name='userid' value='" + us.Userid.ToString() + "' /><div class='entryAdminLeft'>"; html += "<div id='showEntryDetails'><ul>"; html += "<li><a href='#showdetails'>Show Details</a></li>"; html += "<li><a href='#entrydetails'>Entry Details</a></li>"; if (userCamping.ID > -1) { html += "<li><a href='#campingdetails'>Camping Details</a></li>"; } if (helpersList.Count > 0) { html += "<li><a href='#helperdetails'>Helper Details</a></li>"; } html += "</ul>"; String schedule = "../Schedules/" + thisShow.ShowDate.ToString("yyyy") + "/"; String entryForm = schedule; String filename = thisShow.ShowName.Replace(' ', '_'); String fthing = thisShow.ShowDate.ToString("dd_yyyy"); schedule += filename + fthing + "Schedule.pdf"; entryForm += filename + fthing + "EntryForm.pdf"; html += "<div id='showdetails'>"; html += "<h2>" + thisShow.ShowName + "</h2>" + "<p>Start Date:" + thisShow.ShowDate.ToString("dd MMM yyyy") + "</p>" + "<p>Closing Date:" + thisShow.ClosingDate.ToString("dd MMM yyyy") + "</p>"; html += "<p>Venue:" + thisShow.Venue + "</p>" + "<p>" + thisShow.VenuePostcode + "(<a target='_blank' href='https://maps.google.co.uk/maps?q=" + thisShow.VenuePostcode + "'>map</a>)</p>"; var showDocs = ShowDocuments.getShowDocumentsFor(us.ShowID); foreach (var doc in showDocs) { html += string.Format("<div><a class='scheduleLocation' target='_blank' href='../Schedules/{2}/{1}'>{0}</a></div>", doc.Name, doc.Url, thisShow.ShowDate.ToString("yyyy")); } html += "</div>"; html += "<div id='entrydetails'>"; html += "<table class='dogsToEnter themeBorder'>"; html += "<tr><th class='dogName'>Dog Name</th><th class='classNos'>Classes</th>"; List<validClassesForDog> validDogClasses = new List<validClassesForDog>(); int dogCnt = 0; foreach (Dogs d in userDetails.DogDetails.Where(d => d.Grade > 0)) { validClassesForDog vc4d = new validClassesForDog(d.ID); validDogClasses.Add(vc4d); DogClasses dc = new DogClasses(d.ID, us.ShowID); dc.getDogsClasses(us.ShowID); String altBackground = "infoTextBackground"; if (dogCnt % 2 == 0) altBackground = "infoTextBackgroundAlt"; html += String.Format("<tr class='dogClass {4}' dogid='{0}' height='{3}' grade='{2}'><td valign='top'><div >{1}</div>{5}</td>", d.ID, d.KCName, d.Grade, d.Height, altBackground, (dc.Lho == 0 ? "": "**** Entered lower height option")); String classesEntered = ""; foreach (ShowClasses cls in classList) { int clsIndex = dc.Classlist.IndexOf(cls.ID); if (clsIndex > -1) { if (classesEntered.Length > 0) { classesEntered += "<br>"; } if (dc.AltHandlerList[clsIndex] > 0) { classesEntered += String.Format("<span class='classNumber althandler' data-althandlerid='{1}'>{0}</span>", cls.ClassNo, dc.AltHandlerList[clsIndex]); } else { //classesEntered += String.Format("<span class='classNumber' style='padding:5px'>{0}</span>", cls.ClassNo); classesEntered += String.Format("<span class='classNumber' style='padding:5px'>{0}</span> {1} {2} {3} {4}", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.longCatagory, cls.getGrades); } } // // if veterans/anysize or anything that is valid for that dog, add to list; if (d.Grade == 99) { if (cls.EntryType == 2) { vc4d.addClassDetails(cls); } } else { if (cls.EntryType == 2 || (d.Height == cls.Height && cls.Grades.Contains(d.Grade.ToString()))) { vc4d.addClassDetails(cls); } } } dogCnt++; html += "<td class=''><div class='classNos'><div class='classContainer'>" + classesEntered + "</div></div></td></tr>"; } html += "</table>"; html += "</div>"; if (userCamping.ID > -1) { String[] campDays = userCamping.PitchDetails[0].CampingDays.Split(','); html += "<div id='campingdetails' class='infoText'>"; html += "<h2>Camping Days Booked</h2><ul>"; foreach (String cdays in campDays.Where(x => x.Length > 0)) { html += "<li>" + CampDateFormat(cdays) + "</li>"; } html += "</ul>"; html += "<p>No of pitches:<span style='color:#fff'>" + userCamping.PitchDetails.Count + "</span></p>"; html += "<p>Camping With:<span style='color:#fff'>" + userCamping.PitchDetails[0].PartyName + "</span></p>"; html += "<p>Special Requests:<span style='color:#fff'>" + userCamping.PitchDetails[0].Comments + "</span></p>"; html += "</div>"; } if (helpersList.Count > 0) { html += "<div id='helperdetails' class='infoText'>"; html += "<h2>Helping Details</h2>"; var helperComment = ""; foreach (Business.Helpers helper in helpersList) { String judge = ""; if (helper.JudgeID > -1) { Judge j = new Judge(helper.JudgeID); judge = "Judge: " + j.Name; } String ring = ""; if (helper.RingNo > 0) { ring = "Ring No:" + helper.RingNo.ToString(); } html += String.Format("<div >{0:ddd dd MMM} - {1} {2} {3}</div>", helper.HelpDate, helper.expandJob(), judge, ring); helperComment = helper.Comments; } if (helperComment.Length > 0) { html += string.Format("<p>{0}</p>", helperComment); } html += "</div>"; } html += "</div>"; return html; }
public static void Cancel(User currentUser, Shows show) { DogClasses dc = new DogClasses(); UserShows us = new UserShows(currentUser.ID, show.ID); var showTransactions = Transaction.getTransactionForShowUser(us.RefCode); var refundAmount = showTransactions.Where(x => x.TransactionType == TransactionTypes.ShowEntryPayment ).Sum(x => x.Amount); var entryAmount = Math.Abs(showTransactions.Where(x => x.TransactionType == TransactionTypes.ShowEntry || x.TransactionType == TransactionTypes.TransactionCharge).Sum(x => x.Amount)); DogClasses.deleteUserDogs(currentUser.ID, show.ID); MultiDog.DeleteUserFromShow(currentUser.ID, show.ID); UserCamping.DeleteForUser(us.ID); Helpers.DeleteFromShow(show.ID, currentUser.ID); String refcode = us.ID.ToString("000000"); us.Delete(); //us.Status =(int) UserShows.UserStatus.STATUS_PENDING_REFUND; //us.Save(); if (showTransactions.Any()) { String htmlContents = readTemplate("CancelledEntry", "html", show, refcode); String plainContents = readTemplate("CancelledEntry", "txt", show, refcode); if (us.Status == (int)UserShows.UserStatus.STATUS_ENTERED_NOT_PAID || us.Status == (int)UserShows.UserStatus.STATUS_SAVED) { htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", ""); plainContents = plainContents.Replace("[PAYMENT_NOTE]", ""); } Transaction.Add(refcode, TransactionTypes.EntryCancelled, -entryAmount, "Entry Fee Cancelled", show.ID, currentUser.ID, DateTime.Now); if (refundAmount > 0) { // // if handler is cancelling the show and they have paid, then // mark in their account history that there have a refund htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", "Your payment will be refunded in the next 5 working days"); plainContents = plainContents.Replace("[PAYMENT_NOTE]", "Your payment will be refunded in the next 5 working days"); var allDiscounts = ShowDiscounts.getClassChargeDetails(show.ID); var onlineCharge = allDiscounts.FirstOrDefault(x => x.DiscountName == "Transaction Charge"); int transid = Transaction.Add(refcode, TransactionTypes.RefundRequest, -refundAmount, "Refund Requested", show.ID, currentUser.ID, DateTime.Now); PendingRefunds.Add(us.ID, refundAmount, us.ShowID, us.Userid); Transaction.SetEnteredBy(transid, Transaction.ENTERED_BY.ONLINE_ENTRY); } else { htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", ""); plainContents = plainContents.Replace("[PAYMENT_NOTE]", ""); } MailMessage mm = new MailMessage(); AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); LinkedResource logoImage = new LinkedResource(HttpContext.Current.Server.MapPath("~/Assets/logo.gif"), MediaTypeNames.Image.Gif); logoImage.ContentId = "LogoImage"; //htmlView.LinkedResources.Add(logoImage); AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.AlternateViews.Add(plainView); mm.AlternateViews.Add(htmlView); SmtpClient client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(currentUser.EmailAddress, currentUser.Name)); mm.Subject = String.Format("Entry Cancellation {0} ({1:dd MMM yyyy})", show.ShowName, show.ShowDate); client.Send(mm); if (us.Status == (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID) { mm = new MailMessage(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress("*****@*****.**", "First Place Processing")); mm.Subject = "Entry Cancellation Request"; mm.Body = String.Format("Refund Request from {0}\r\n\r\nRefcode: {1}\r\n\r\nEmail: {2}\r\n\r\nShow: {3}\r\n", currentUser.Name, refcode, currentUser.EmailAddress, show.ShowName); client.Send(mm); } } }
public JsonResult GenerateRingNumbers(int ShowId) { DogClasses dogClasses = new DogClasses(); dogClasses.GenerateRingNumbers(ShowId); return Json(new { Status = 0 }); }
public JsonResult GenerateRO(int ShowId, int ClassId) { DogClasses dogClasses = new DogClasses(); var clsDetails = new ShowClasses(ClassId); if (TeamPairsManager.isMultiDog(clsDetails.EntryType)) { dogClasses.GenerateROsForTeams(ShowId, ClassId); } else { dogClasses.GenerateROs(ShowId, ClassId); } return Json(new { Status = 0 }); }
// From Admin Site public UserDogDetails GetDetails(int ShowId, int UserId, int handlerType) { var userDetails = new UserDogDetails(); userDetails.MultiDogClasses = new List<MultiDogClasses>(); List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(ShowId).Where(sc => sc.Part == 0).ToList(); userDetails.MultiDogClasses = TeamPairsManager.GetTeamPairClasses(ShowId); userDetails.Juniors = new List<Juniors>(); var us = new UserShows(UserId, ShowId); // // if user entering a new show then set up the handler type, cos that is pasted in if (us.ID == -1) { us.HandlerType = handlerType; if (handlerType == 0) { if (Judge.isJudgeAtShow(UserId, ShowId)) { handlerType = 2; us.HandlerType = 2; } else { // // check if alt handlers are judging // List<AltHandler> altHList = AltHandler.GetAllAltHandlersList(us.Userid); foreach (AltHandler alt in altHList) { if (Judge.isJudgeAtShow(alt.AltHandlerID, ShowId)) { handlerType = 2; us.HandlerType = 2; } } } } } var discountTotal = 0M; var addNewTransation = 0; var singleEntryId = getSingleEntry(ShowId); userDetails.Camping = new Camping(ShowId); userDetails.CampingSummary = UserCamping.GetCampingSummary(us.ShowID, us.Userid); var totals = calcNewTotalForEntry(us, userDetails.Camping, singleEntryId, ref discountTotal, ref addNewTransation); if (!userDetails.CampingSummary.Any()) { for (DateTime dt = userDetails.Camping.Startdate; dt <= userDetails.Camping.Enddate; dt = dt.AddDays(1)) { userDetails.CampingSummary.Add(new Core.Dto.CampingSummary { CampingDay = dt, Count = 0 }); } } else { userDetails.CampingFull = userDetails.CampingSummary.Where(x => x.Count >= userDetails.Camping.Limit).Count() == userDetails.CampingSummary.Count(); } userDetails.PaymentSummary = CreatePaymentSummary(us, true, userDetails.CampingFull); userDetails.AltHandlers = AltHandler.GetAllAltHandlers(UserId); if (us.ID > 0) { userDetails.ShowTransactions = Transaction.getTransactionForShowUser(us.ID.ToString("000000")); } else { userDetails.ShowTransactions = new List<Transaction>(); } userDetails.helperDetails = Business.Helpers.HelperForShow(ShowId, UserId); Shows thisShow = new Shows(ShowId); Dogs dog = new Dogs(); userDetails.DogDetails = Dogs.GetAllDogsForHandler(UserId, thisShow.ShowDate); userDetails.UserDetails = new User(UserId); userDetails.HandlerType = us.HandlerType; userDetails.UserShowID = us.ID.ToString("000000"); userDetails.Optout = us.Optout; userDetails.SaveStatus = us.Status; userDetails.MultiDogEntries = TeamPairsManager.GetTeamPairs(ShowId, UserId, userDetails.MultiDogClasses); String html = ""; List<validClassesForDog> validDogClasses = new List<validClassesForDog>(); if (true) { html = "<input type='hidden' name='ShowId' value='" + ShowId.ToString() + "' /><input type='hidden' name='userid' value='" + UserId.ToString() + "' /><div class='entryAdminLeft'><table class='dogsToEnter'>"; html += @"<tr> <th class='dogName'>Dog Name</th> <th class='lho-handler'>LHO</th> <th class='classNos'>Classes</th>"; foreach (Dogs d in userDetails.DogDetails) { validClassesForDog vc4d = new validClassesForDog(d.ID); validDogClasses.Add(vc4d); DogClasses dc = new DogClasses(d.ID, ShowId); dc.getDogsClasses(ShowId); String tmpNFC = d.Grade.ToString(); if (d.Grade == 0) { tmpNFC = "NFC"; } else if (d.Grade == 99) { tmpNFC = "Vet"; } html += String.Format("<tr class='dogClass' lho='{6}' dogid='{0}' height='{3}' grade='{2}'><td class='dogName'><div ><b>[{4}] </b>{1}</div><div class='altHandler'>{5}</div></td>", d.ID, d.KCName, d.Grade, d.Height, tmpNFC, d.AltHandlerName, dc.Lho); html += "<td class='lho'><input type='checkbox' class='lho' value='1' " + (dc.Lho == 1 ? "checked" : "") + " /></td>"; //html += "<td class='vet'><input type='checkbox' class='vet' value='1' " + (dc.Veteran == 1 ? "checked" : "") + " /></td>"; //html += "<td class='any'><input type='checkbox' class='any' value='1' " + (dc.Anysize == 1 ? "checked" : "") + " /></td>"; String classesEntered = ""; foreach (ShowClasses cls in classList) { int otherDogs = 0; int reserves = 0; bool teamName = false; if (cls.EntryType == 4 || cls.EntryType == 8) { otherDogs = 1; } else if (cls.EntryType == 5) { otherDogs = 3; reserves = 2; teamName = true; } else if (cls.EntryType == 9) { otherDogs = 2; reserves = 2; teamName = true; } int clsIndex = dc.Classlist.IndexOf(cls.ID); if (clsIndex > -1) { classesEntered += String.Format("<span entrytype='{1}' chargetype='{2}' classtype='{3}' classno='{0}' clsid='{4}' class='classNumber ", cls.ClassNo, cls.EntryType, cls.ChargeType, cls.ClassType, cls.ID); if (dc.AltHandlerList[clsIndex] > 0) { var jnrHtml = ""; if (cls.EntryType == 11) { var jnr = new Juniors(cls.ID, d.ID); if (jnr != null && jnr.ID > 0) { jnrHtml += string.Format("<span class='junior-details' data-id='{2}' data-dob='{0:dd-MM-yyyy}' data-ykcnumber='{1}'></span>", jnr.DoB, jnr.YKCNumber, jnr.ID); } } classesEntered += String.Format("althandler ykc' data-althandlerid='{1}'>{0}{2}</span>", cls.ClassNo, dc.AltHandlerList[clsIndex], jnrHtml); } else { if (otherDogs > 0) { classesEntered += String.Format("' data-otherdogs='{1}' data-reserves='{2}' data-team='{3}' >{0}", cls.ClassNo, otherDogs, reserves, teamName); classesEntered += "<img class='otherdogs' src='/Content/Assets/mdSet.png' />"; classesEntered += "</span>"; } else { var extrahtml = ""; if (cls.EntryType == 10) { var wins = DogHistory.GetRecordedWins(d.ID); foreach (var dogH in wins) { extrahtml += string.Format("<span class='champ-details' data-upgradetype='{4}' data-winid='{3}' data-showname='{0}' data-showdate='{1:dd-MM-yy}' data-showclass='{2}'></span>", dogH.ShowName, dogH.DateOfWin, dogH.ClassWon, dogH.Id, dogH.UpgradeType); } classesEntered += String.Format("' >{0}{1}</span>", cls.ClassNo, extrahtml); } else if (cls.EntryType == 11 || cls.EntryType == 3) { var jnr = new Juniors(cls.ID, d.ID); if (jnr != null && jnr.ID > 0) { extrahtml += string.Format("<span class='junior-details' data-id='{2}' data-dob='{0:dd-MM-yyyy}' data-ykcnumber='{1}'></span>", jnr.DoB, jnr.YKCNumber, jnr.ID); } classesEntered += String.Format("ykc' >{0}{1}</span>", cls.ClassNo, extrahtml); } else { classesEntered += String.Format("' >{0}</span>", cls.ClassNo); } } } } if (isDogInClass(cls, d)) { vc4d.addClassDetails(cls); } } html += "<td class='classNos'><div >" + classesEntered + "</div></td></tr>"; } html += "</table></div><div class='entryAdminRight'></div>"; } userDetails.Data = html; userDetails.ValidClassesForDogs = validDogClasses; userDetails.TransactionSummaryData = TransactionSummary.getTransactionSummary(ShowId, UserId); userDetails.UserCamping = new UserCamping(us.ID); if (us.ID > 0) { userDetails.ShowTransList = ShowTransaction.getTransactionForShowRef(us.ID); } else { userDetails.ShowTransList = new List<ShowTransaction>(); } return userDetails; }
public StatusCls GetEntryForm(int ShowId, int UserId, int handlerType) { StatusCls status = new StatusCls { MultiDogClasses = new List<MultiDogClasses>() }; Shows thisShow = new Shows(ShowId); User currentUser = new User(UserId); List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(ShowId).Where(sc => sc.Part == 0).ToList(); var lhoLabel = false; var fouthHeightLabel = false; if (classList.Any(x => x.Lho > 0)) { lhoLabel = true; if (classList.Any(x => x.Lho == 3)) { lhoLabel = false; fouthHeightLabel = true; } } status.MultiDogClasses = TeamPairsManager.GetTeamPairClasses(ShowId); UserShows us = new UserShows(UserId, ShowId); // // if user entering a new show then set up the handler type, cos that is pasted in if (us.ID == -1) { us.HandlerType = handlerType; } // // add check to see if this person is on the judging list. // and there are not a member as members override the judging discounts. if (Judge.isJudgeAtShow(UserId, ShowId) && handlerType == 0) { handlerType = 2; us.HandlerType = 2; } else { // // check if alt handlers are judging // List<AltHandler> altHList = AltHandler.GetAllAltHandlersList(us.Userid); foreach (AltHandler alt in altHList) { if (Judge.isJudgeAtShow(alt.AltHandlerID, ShowId)) { handlerType = 2; us.HandlerType = 2; } } } Dogs dog = new Dogs(); List<Dogs> dogs = Dogs.GetAllDogsForHandler(UserId, thisShow.ShowDate); String html = $"<input type='hidden' name='handlertype' id='handlertype' value='{us.HandlerType}' />"; String header = "<div class='dogRow group header'><div class='petName header'> </div>"; Boolean headerCompleted = false; String rowClass = "dogRowAlt"; foreach (Dogs d in dogs.Where(d => d.Grade > 0 ) ) { String buttons = ""; DogClasses dc = new DogClasses(d.ID); dc.getDogsClasses(ShowId); if (d.Grade != 0) { buttons = "<div class='buttons'><a href='#tick'><img title='Select All Single Classes' class='tickcross tickimg' src='/Content/Assets/tickv2.png' /></a><a href='#cross'><img title='Clear All Classes' class='tickcross crossimg' src='/Content/Assets/crossv1.png' /></a>"; buttons += "</div>"; if (lhoLabel) { buttons += @"<div class='lho'><label for='cklho_" + d.ID + "'>Lower height<input type='checkbox' value='1' id='cklho_" + d.ID + "' " + (dc.Lho == 1 ? "checked='checked'" : "") + " /></label></div>"; } if (fouthHeightLabel) { buttons += @"<div class='ext'><label for='cklho_" + d.ID + "'>4th height<input type='checkbox' value='1' id='cklho_" + d.ID + "' " + (dc.Lho == 1 ? "checked='checked'" : "") + " /></label></div>"; } buttons += "<div class='infoText'>Handler:</div>"; if (d.AltHandlerID == -1) { buttons += currentUser.Name; } else { User altHandler = new User(d.AltHandlerID); buttons += altHandler.Name; } } html += String.Format("<div class='{2} group themeBorder-t' dogid='{0}' grade='{4}'><div class='petName'><div class='lbl'>{1}<p class='grade'>{4}</p></div>{3}</div>", d.ID, d.PetName, rowClass, buttons, d.DisplayGrade); rowClass = (rowClass == "dogRowAlt" ? "dogRow" : "dogRowAlt"); String classTable = ""; String dayName = ""; String lastDay = ""; Boolean classesForDog = true; foreach (ShowClasses cls in classList) { if (dayName != cls.Showdate.ToString("dddd, dd MMM")) { if (dayName != "") { if (!classesForDog) { classTable += String.Format("<div class='clsNo' ><span class='naCls'>n/a</span></div>"); } classTable += "</div>"; } classesForDog = false; lastDay = dayName; dayName = cls.Showdate.ToString("dddd, dd MMM"); ShowDetails showDetails = new ShowDetails(cls.ShowDetailsID); classTable += String.Format("<div class='day' classlimit='{0}'>", showDetails.ClassLimit); if (!headerCompleted) { header += String.Format("<div class='day header' >{0}</div>", dayName); } } // // cls.EntryType == (int)EntryType.EntryTypes.ABC && // if (isDogInClass(cls, d)) { int otherDogs = 0; int reserves = 0; bool teamName = false; String ticked = ""; String altHandlerInfo = "<img class='handler' src='/Content/Assets/AddHandler.png' width='16' height='14' />"; int clsIndex = dc.Classlist.IndexOf(cls.ID); if (clsIndex > -1) { ticked = "tick"; if (dc.AltHandlerList[clsIndex] > 0) { User u = new User(dc.AltHandlerList[clsIndex]); altHandlerInfo = "<img class='handler changed' width='16' height='14' src='/Content/Assets/AddHandler.png' data-althandlerid='" + dc.AltHandlerList[clsIndex].ToString() + "' title='Handler:" + u.Name + "' />"; } } classesForDog = true; if (otherDogs > 0) { String iconType = "mdSet.png"; var multiDogs = ""; classTable += String.Format("<div {12} {13} {14} {15} class='clsNo " + ticked + "' classno='{15}' classcount='{11}' clsid='{0}' chargeType='{2}' classType='{3}' entryType='{4}' otherdogs='{5}' reserves='{9}' team='{10}' ><span class='chghandlemenu'>[+]</span>{6}<a class='otherdogs' title='Enter other dogs'><img src='/Content/Assets/{8}' >{7}</img></a><span class='clickable'><img class='tickHolder ' src='/Content/Assets/tickv2.png' /><span class='ah'>*</span><span class='clsname'>{1}</span></span></div>", cls.ID, ShortenName(cls), cls.ChargeType, cls.ClassType, cls.EntryType, otherDogs, altHandlerInfo, multiDogs, iconType, reserves, teamName, cls.ClassCount, cls.Anysize == 1 ? "anysize" : "", cls.Veteran == 1 ? "veteran" : "", ShowLhoModifier( cls.Lho ), cls.ClassNo, cls.AwardByHeight > 0 ? "AH" : ""); } else { if (cls.EntryType == 10) { var hasChampDogsIcon = "mdNotSet.png"; var allDetailsCheck = 0; var wins = DogHistory.GetRecordedWins(d.ID); var h = "<span class='wins'>"; foreach (var dogH in wins) { h += string.Format("<span class='champ-wins' data-upgradetype='{4}' data-winid='{3}' data-showname='{0}' data-showdate='{1:dd-MM-yy}' data-showclass='{2}'></span>", dogH.ShowName, dogH.DateOfWin, dogH.ClassWon, dogH.Id, dogH.UpgradeType); allDetailsCheck += (dogH.ShowName.Length > 0 && dogH.ClassWon.Length > 0) ? 1 : 0; } if (allDetailsCheck == 4) { hasChampDogsIcon = "mdSet.png"; } h += "</span>"; classTable += String.Format("<div class='clsNo " + ticked + "' clsid='{0}' chargeType='{2}' classType='{3}' entryType='{4}' classCount='{8}'><span class='chghandlemenu'>[+]</span>{5}<a class='champ-dogs " + (allDetailsCheck == 4 ? " all-wins-entered " : "") + "' href='' title='Enter Your Wins' ><img src='/Content/Assets/{6}' /></a><span class='clickable'><img class='tickHolder ' src='/Content/Assets/tickv2.png' /><span class='clsname'>{1}</span></span>{7}</div>", cls.ID, ShortenName(cls), cls.ChargeType, cls.ClassType, cls.EntryType, altHandlerInfo, hasChampDogsIcon, h, cls.ClassCount); } else if (cls.EntryType == 11) { var hasJuniorDetails = "mdNotSet.png"; var allDetailsCheck = false; var jnr= new Juniors(cls.ID, d.ID); var h = ""; if (jnr != null && jnr.ID > 0) { h += string.Format("<span class='junior-details' data-id='{2}' data-dob='{0:dd-MM-yyyy}' data-ykcnumber='{1}'></span>", jnr.DoB, jnr.YKCNumber, jnr.ID); hasJuniorDetails = "mdSet.png"; allDetailsCheck = true; } h += ""; classTable += String.Format("<div {9} {10} {11} {12} class='clsNo " + ticked + "' clsid='{0}' chargeType='{2}' classType='{3}' entryType='{4}' classCount='{8}' ><span class='chghandlemenu'>[+]</span>{5}<a class='ykc " + (allDetailsCheck ? " all-entered " : "") + "' href='' title='Enter YKC Details' ><img src='/Content/Assets/{6}' /></a><span class='clickable'><img class='tickHolder ' src='/Content/Assets/tickv2.png' /><span class='ah'>*</span><span class='clsname'>{1}</span></span>{7}</div>", cls.ID, ShortenName(cls), cls.ChargeType, cls.ClassType, cls.EntryType, altHandlerInfo, hasJuniorDetails, h, cls.ClassCount, cls.Anysize == 1 ? "anysize" : "", cls.Veteran == 1 ? "veteran" : "", ShowLhoModifier(cls.Lho), cls.AwardByHeight > 0 ? "AH" : ""); } else { // lhoclass = (cls.Lho == 0 && dc.Lho == 1 ? " hidecls ": ""); var lhoclass = ""; if (cls.Lho == 0 ) { lhoclass = (dc.Lho == 1 ? " hidecls " : ""); } else { if (cls.Lho < 3) { lhoclass = ""; // (dc.Lho == 1 ? "" : " hidecls "); } else { lhoclass = (dc.Lho == 0 ? " hidecls " : ""); } } classTable += String.Format("<div {7} {8} {9} {10} class='clsNo " + ticked + " " + lhoclass + "' clsid='{0}' chargeType='{2}' classType='{3}' entryType='{4}' classCount='{6}'><span class='chghandlemenu'>[+]</span>{5}<a class='nootherdogs'><img class='nootherdogs' src='/Content/Assets/infov1.png' /></a><span class='clickable'><img class='tickHolder ' src='/Content/Assets/tickv2.png' /><span class='ah'>*</span><span class='clsname'>{1}</span></span></div>", cls.ID, ShortenName(cls), cls.ChargeType, cls.ClassType, cls.EntryType, altHandlerInfo, cls.ClassCount, cls.Anysize == 1 ? "anysize" : "", cls.Veteran == 1 ? "veteran" : "", ShowLhoModifier(cls.Lho), cls.AwardByHeight > 0 ? "AH" : ""); } } } } headerCompleted = true; if (!classesForDog) { classTable += String.Format("<div class='clsNo nohover'><span class='naCls'>n/a</span></div>"); } html += classTable + "</div>"; html += "</div>"; } header += "</div>"; String showDetailsBox = ""; showDetailsBox += "<div class='showDetails themeText'>"; showDetailsBox += "<div class='title' style=' width: 375px;white-space: nowrap;overflow: hidden;text-overflow: clip;'>" + thisShow.ShowName + "</div>"; showDetailsBox += "<div class='showdate'>" + thisShow.ShowDate.ToString("dd MMM yyyy") + "</div>"; showDetailsBox += "</div >"; showDetailsBox += "<div class='helpBox themeNoticeText themeBorder'>"; showDetailsBox += "<div><span class='legend themeBackgroundColor'>Help Information</span></div>"; showDetailsBox += "<div><img src='/Content/Assets/tickv2.png' /><span class='afterImgAdj'> To select all classes</span></div>"; showDetailsBox += "<div><img src='/Content/Assets/crossv1.png' /><span class='afterImgAdj'> To unselect all classes</span></div>"; showDetailsBox += "<div><img src='/Content/Assets/mdNotSet.png' /><span class='afterImgAdj'> Missing details</span></div>"; showDetailsBox += "<div><img src='/Content/Assets/mdSet.png' /><span class='afterImgAdj'> All detail entered</span></div>"; showDetailsBox += "<div><span style='color:#fff;'>[+]</span><span ><span> To Add Handler</span></div>"; showDetailsBox += "<div><span class='ah' style='color:#fff;display:inline;margin: 0px 7px;top:4px'>*</span><span ><span>Awards By Height</span></div>"; showDetailsBox += "</div>"; String totalsBox = ""; totalsBox += "<div class='totals themeBorder' ><div class='showTotals short themeBackgroundColor themeBorder'>"; totalsBox += "<div class='clsTypeRow group fulltotal'>"; totalsBox += "<div class='clsTypePaymentInfo themeBorder-t'></div>"; totalsBox += "<div class='clsTypeTotal themeBorder-t themeBorder-l'>0.00</div>"; totalsBox += "</div >"; totalsBox += "</div>"; totalsBox += "<div class='ctrlButtons'>"; if (thisShow.Status == (int)Shows.SHOW_STATUS.PUBLISHED) { if (us.Status != (int)UserShows.UserStatus.STATUS_ENTERED_NOT_PAID && us.Status != (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID) { totalsBox += "<input type='button' id='btnSaveEntry' value='Save Details' />"; } } HttpCookie cookie = HttpContext.Current.Request.Cookies[".FPPAUTH"]; if (cookie != null) { FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value); String[] lists = ticket.UserData.Split(':'); int userid = Convert.ToInt32(lists[1]); if ((lists[0].Contains("showadmin") && thisShow.Status == (int)Shows.SHOW_STATUS.NOT_PUBLISHED) || thisShow.Status == (int)Shows.SHOW_STATUS.PUBLISHED) { totalsBox += "<input type='button' id='btnDoEntry' value='Enter Show' />"; } } totalsBox += "<input type='button' id='btnCancel' value='Close' /></div>"; totalsBox += "</div >"; status.Status = 0; status.UserID = currentUser.ID; status.Data = "<input id='ShowID' type='hidden' value='" + ShowId.ToString() + "' /><div class='enterform themeBorder' showid='" + ShowId.ToString() + "'><div class='vscroll'>" + header + "<div class='hscroll'>" + html + "</div></div></div>" + showDetailsBox + totalsBox; status.Extra = AltHandler.GetAllAltHandlers(UserId); status.TransactionSummaryData = TransactionSummary.getTransactionSummary(ShowId, currentUser.ID); status.Camping = new Camping(ShowId); status.CampingSummary = UserCamping.GetCampingSummary(ShowId, 0); if (!status.CampingSummary.Any()) { for (DateTime dt = status.Camping.Startdate; dt <= status.Camping.Enddate; dt = dt.AddDays(1)) { status.CampingSummary.Add(new Core.Dto.CampingSummary { CampingDay = dt, Count = 0 }); } } else { status.CampingFull = status.CampingSummary.Where(x => x.Count >= status.Camping.Limit).Count() == status.CampingSummary.Count(); } status.PaymentSummary = CreatePaymentSummary(us, false, status.CampingFull); if (status.Camping.ID > -1 && !status.CampingFull) { status.UserCamping = new UserCamping(us.ID); } status.UserShow = us; status.MultiDogEntries = TeamPairsManager.GetTeamPairs(ShowId, UserId, status.MultiDogClasses); status.Lho = lhoLabel; status.fouthHeight = fouthHeightLabel; return status; }
public StatusCls EnterShow(Fpp.Core.Models.UserPaymentDetails userPaymentDetails) { DogClasses dc = new DogClasses(); Shows show = new Shows(userPaymentDetails.ShowId); User currentUser = new User(userPaymentDetails.UserId); UserShows us = new UserShows(userPaymentDetails.UserId, userPaymentDetails.ShowId); if (us.HandlerType == 1) { List<String> days = new List<string>(); var tmp = ShowDetails.GetShowDaysForUser(userPaymentDetails.ShowId, userPaymentDetails.UserId); AppException.LogEvent(string.Format("Member({0}) Helpers.a:{1}", userPaymentDetails.UserId, tmp.Count)); foreach (var t in tmp) { // 24,Saturday,Scrimmer,1/2 AM, var b = string.Format("{0},{1},{2},{3},{4}", t.ID, t.ShowDate.ToString("dddd"), "Ring Party", "All Day", "-1", -1); days.Add(b); } AppException.LogEvent(string.Format("Member({0}) Helpers.b:{1}", userPaymentDetails.UserId, days.Count)); HelperManager.AddHelper(userPaymentDetails.ShowId, userPaymentDetails.UserId, currentUser.Name, days.ToArray(), ""); } String userRefNo = us.ID.ToString().PadLeft(6, '0'); AppException.LogEvent(string.Format("Entry Details:{0} {1}, {2}, {3}, {4}", userRefNo, userPaymentDetails.EntryFee, userPaymentDetails.Total, userPaymentDetails.DiscountTotal, userPaymentDetails.TransactionFee)); var showTransactions = Transaction.getTransactionForShowUser(userRefNo); var previousEntry = showTransactions.Where(x => x.TransactionType == TransactionTypes.ShowEntry).Sum(t => t.Amount); if (userPaymentDetails.EntryFee == Math.Abs(previousEntry)) { AppException.LogEvent(string.Format("****** Entry Entry fee == previousEntry ", userRefNo, userPaymentDetails.EntryFee, userPaymentDetails.Total, userPaymentDetails.DiscountTotal, userPaymentDetails.TransactionFee)); } if (userPaymentDetails.Total == 0 && userPaymentDetails.DiscountTotal >0 ) { if (userPaymentDetails.EntryFee != Math.Abs( previousEntry ) ) { userPaymentDetails.EntryFee -= Math.Abs(previousEntry); Transaction.Add(userRefNo, TransactionTypes.ShowEntry, -userPaymentDetails.EntryFee, "Entry Fee", us.ShowID, us.Userid, DateTime.Now); if (userPaymentDetails.DiscountTotal > 0) { var discounts = showTransactions.Where(x => x.TransactionType == TransactionTypes.Discount).Sum(t => t.Amount); userPaymentDetails.DiscountTotal -= discounts; if (userPaymentDetails.DiscountTotal < 0) userPaymentDetails.DiscountTotal = 0; Transaction.Add(userRefNo, TransactionTypes.Discount, userPaymentDetails.DiscountTotal, "Discount Applied", us.ShowID, us.Userid, DateTime.Now); } Transaction.Add(userRefNo, TransactionTypes.ShowEntryPayment, 0, "Entry Fee Paid", us.ShowID, us.Userid, DateTime.Now); } } else { if (userPaymentDetails.EntryFee != Math.Abs(previousEntry)) { if (userPaymentDetails.Total == 0) { userPaymentDetails.EntryFee -= Math.Abs(previousEntry); Transaction.Add(userRefNo, TransactionTypes.ShowEntry, -userPaymentDetails.EntryFee, "Entry Fee", us.ShowID, us.Userid, DateTime.Now); if (userPaymentDetails.DiscountTotal > 0) { var discounts = showTransactions.Where(x => x.TransactionType == TransactionTypes.Discount).Sum(t => t.Amount); userPaymentDetails.DiscountTotal -= discounts; if (userPaymentDetails.DiscountTotal < 0) userPaymentDetails.DiscountTotal = 0; Transaction.Add(userRefNo, TransactionTypes.Discount, userPaymentDetails.DiscountTotal, "Discount Applied", us.ShowID, us.Userid, DateTime.Now); } Transaction.Add(userRefNo, TransactionTypes.ShowEntryPayment, 0, "Entry Fee Paid", us.ShowID, us.Userid, DateTime.Now); } else if (userPaymentDetails.Total > 0) { var lastShowEntry = showTransactions.OrderByDescending(t => t.TransactionDate).Take(2).ToList(); if (lastShowEntry.Any()) { var transaction = lastShowEntry[0]; if (transaction != null && (transaction.TransactionType == TransactionTypes.TransactionCharge || transaction.TransactionType == TransactionTypes.ShowEntry)) { Transaction.Delete(transaction.ID); lastShowEntry.Remove(transaction); if (lastShowEntry.Any()) { transaction = lastShowEntry[0]; if (transaction != null && (transaction.TransactionType == TransactionTypes.ShowEntry || transaction.TransactionType == TransactionTypes.TransactionCharge)) { Transaction.Delete(transaction.ID); } } } } Transaction.Add(userRefNo, TransactionTypes.ShowEntry, -userPaymentDetails.EntryFee, "Entry Fee", us.ShowID, us.Userid, DateTime.Now); if (userPaymentDetails.TransactionFee != 0) { Transaction.Add(userRefNo, TransactionTypes.TransactionCharge, -userPaymentDetails.TransactionFee, "Transaction Fee", us.ShowID, us.Userid, DateTime.Now); } else { AppException.LogEvent(string.Format("No Transaction Fee {0}", userRefNo)); } if (userPaymentDetails.DiscountTotal > 0) { Transaction.Add(userRefNo, TransactionTypes.Discount, userPaymentDetails.DiscountTotal, "Discount Applied", us.ShowID, us.Userid, DateTime.Now); } } else { var refundRequests = showTransactions.Where(s => s.TransactionType == TransactionTypes.RefundRequest).Sum(t => t.Amount); var refundsPaidOrCancelled = showTransactions.Where(s => s.TransactionType == TransactionTypes.RefundPaid || s.TransactionType == TransactionTypes.RefundCancelled).Sum(t => t.Amount); var outstandingRefunds = refundRequests - refundsPaidOrCancelled; Transaction.Add(userRefNo, TransactionTypes.RefundRequest, userPaymentDetails.Total - outstandingRefunds, "Refund Fee Requested", us.ShowID, us.Userid, DateTime.Now); PendingRefunds.Add(us.ID, Math.Abs(userPaymentDetails.Total - outstandingRefunds), us.ShowID, us.Userid); RefundForShow(us.ShowID, us.Userid); if (userPaymentDetails.DiscountTotal > 0) { Transaction.Add(userRefNo, TransactionTypes.Discount, userPaymentDetails.DiscountTotal, "Discount Applied", us.ShowID, us.Userid, DateTime.Now); } } var comms = new EmailManager(); if (userPaymentDetails.DiscountTotal == userPaymentDetails.EntryFee) { comms.SendEntryEmail(userPaymentDetails.ShowId, userPaymentDetails.UserId, userRefNo); } else { comms.SendSavedEmail(userPaymentDetails.ShowId, userPaymentDetails.UserId, userRefNo); } } } StatusCls status = new StatusCls(); status.UserID = currentUser.ID; status.Extra = createPaymentForm(currentUser, show, us.ID, userPaymentDetails.Total); // currentUser, show, userRefNo, userPaymentDetails.Total); return status; }
public StatusCls CalcShow(Fpp.Core.Models.UserShowEntry showEntry) { DogClasses dc = new DogClasses(); Shows show = new Shows(showEntry.ShowId); User currentUser = new User(showEntry.UserId); UserShows us = new UserShows(showEntry.UserId, showEntry.ShowId); decimal discountTotal = 0; var singleEntryId = getSingleEntry(showEntry.ShowId); // Decimal amount = calcNewTotalForEntry(showEntry.ShowId, showEntry.UserId, singleEntryId, ref discountTotal, ref addNewTransaction); var showTransactions = Transaction.getTransactionForShowUser(us.ID.ToString("000000")); decimal fixedFees = 0M; var showEntries = DogClasses.calcCostOfEntry(showEntry.ShowId, showEntry.UserId); var entryCost = showEntries.Sum(x => x.Total); var noOfSingleEntries = showEntries.FirstOrDefault(x => x.ChargeTypeId == singleEntryId); var entriesDiscount = Math.Abs(ShowDiscounts.getDiscountFor(showEntry.ShowId, showEntry.UserId, "entry", (noOfSingleEntries != null ? noOfSingleEntries.Count : 0), showEntries).Amount); discountTotal = entriesDiscount; var currentEntryCost = (entryCost - entriesDiscount); if (!ShowDiscounts.discount100Percent(showEntry.ShowId, showEntry.UserId, "entry") && currentEntryCost > 0) { fixedFees = ShowDiscounts.getDiscountsByType(showEntry.ShowId, -1, (int)DiscountTypes.TransactionCharge).Sum(x => x.Amount); currentEntryCost += fixedFees; } var uc = new UserCamping(us.ID); if (uc.ID > -1) { var showCamping = new Camping(showEntry.ShowId); var campingCost = Camping.costOfEntry(showEntry.ShowId, showEntry.UserId); var campingDiscount = ShowDiscounts.getDiscountFor(showEntry.ShowId, showEntry.UserId, "camping", uc.Nights, null, campingCost); var discount = 0M; switch (campingDiscount.Type) { case (int)CHARGES_SUBTYPES.percentCamping: currentEntryCost = currentEntryCost - (campingCost - campingDiscount.Amount); discountTotal += campingDiscount.Amount; break; case (int)CHARGES_SUBTYPES.n_NightsCamping: if (campingDiscount.Amount == showCamping.Nights) { currentEntryCost = currentEntryCost + (campingCost - (showCamping.Costpershow)); discount = showCamping.Costpershow; } else { currentEntryCost = currentEntryCost + (campingCost - (campingDiscount.Amount * showCamping.Costpernight)); discount = campingDiscount.Amount * showCamping.Costpernight; } discountTotal += discount; break; default: break; } } Decimal previousEntryCost = showTransactions .Where(x => x.TransactionType == TransactionTypes.ShowEntry) .Sum(x => x.Amount); Decimal whatHasBeenPaid = showTransactions .Where(x => x.TransactionType == TransactionTypes.ShowEntryPayment) .Sum(x => x.Amount); Decimal whatHasBeenRequested = showTransactions .Where(x => x.TransactionType == TransactionTypes.RefundRequest) .Sum(x => x.Amount); Decimal whatHasBeenRefund = showTransactions .Where(x => x.TransactionType == TransactionTypes.RefundPaid || x.TransactionType == TransactionTypes.RefundCancelled) .Sum(x => x.Amount); if (whatHasBeenPaid != 0) { if (Math.Abs(previousEntryCost) != currentEntryCost) { currentEntryCost += fixedFees; } } StatusCls status = new StatusCls(); status.PaymentSummary = CreatePaymentSummary(us); return status; }
public StatusCls AdminPayForShow(ShowEntry showEntry) { StatusCls status = new StatusCls(); var currentUser = new User(showEntry.UserId); var thisShow = new Shows(showEntry.ShowId); var us = new UserShows(showEntry.UserId, showEntry.ShowId); us.Status = us.Status = (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID; us.Save(); status.Data = us.ID.ToString().PadLeft(6, '0'); var transactions = Transaction.getTransactionForShowRef(us.ID); var transID = Transaction.Add(status.Data, TransactionTypes.ShowEntryPayment, showEntry.Cheque, showEntry.PaymentType + " Payment", showEntry.ShowId, showEntry.UserId, DateTime.Now, showEntry.Cheque); Transaction.SetEnteredBy(transID, Transaction.ENTERED_BY.SHOW_ADMIN_ENTRY); if (thisShow.Status == 0) { return status; } if (currentUser.EmailAddress.Length > 0) { // if entered show, send email saying entered show String htmlContents = readTemplate("AdminEnteredShowMessage", "html", thisShow, status.Data); String plainContents = readTemplate("AdminEnteredShowMessage", "txt", thisShow, status.Data); String Classes_entered_html = "<table>"; String Classes_entered_plain = ""; List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(showEntry.ShowId); List<Dogs> dogList = Dogs.GetAllDogsForHandler(showEntry.UserId, thisShow.ShowDate); foreach (Dogs d in dogList) { DogClasses dogClasses = new DogClasses(d.ID, showEntry.ShowId); dogClasses.getDogsClasses(showEntry.ShowId); string dogClassesPlain = String.Format("{1}{0}{1}--------------------------------{1}", d.PetName, Environment.NewLine); string dogClassesHtml = String.Format("<tr style='font-weight:bold;'><td colspan='3'><b>{0}</b></td></tr>", d.PetName); bool dogEntered = false; foreach (ShowClasses cls in classList) { int clsIndex = dogClasses.Classlist.IndexOf(cls.ID); if (clsIndex > -1) { dogEntered = true; dogClassesHtml += "<tr>"; dogClassesHtml += String.Format("<td style='width:25px'></td><td>{0}</td><td>{1} {2} {3} {4}</td>", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.longCatagory, cls.getGrades); dogClassesHtml += "</tr>"; dogClassesPlain += String.Format("{0} - {1} {2} {3} {4} {5}", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.longCatagory, cls.getGrades, Environment.NewLine); } } if (dogEntered) { Classes_entered_html += dogClassesHtml; Classes_entered_plain += dogClassesPlain; } } Classes_entered_html += "</table>"; Classes_entered_plain += Environment.NewLine; htmlContents = htmlContents.Replace("[CLASSES_ENTERED]", Classes_entered_html); plainContents = plainContents.Replace("[CLASSES_ENTERED]", Classes_entered_plain); String underPayment_html = ""; String underPayment_plain = ""; if (showEntry.Cheque < showEntry.Total) { if (Math.Abs(showEntry.Total - showEntry.Cheque) >= 5) { underPayment_html = String.Format("<h2>Please note that you entry was underpaid by £{0:.00}. Please send the balance to the Show Processor ASAP.</h2>", Math.Abs(showEntry.Total - showEntry.Cheque)); underPayment_plain = String.Format("Please note that you entry was underpaid by £{0:.00}. Please send the balance to the Show Processor ASAP.", Math.Abs(showEntry.Total - showEntry.Cheque)); } else { underPayment_html = String.Format("<h2>Please note that you entry was underpaid by £{0:.00}. Please pay the outstanding balance at the show.</h2>", Math.Abs(showEntry.Total - showEntry.Cheque)); underPayment_plain = String.Format("Please note that you entry was underpaid by £{0:.00}. Please pay the outstanding balance at the show.", Math.Abs(showEntry.Total - showEntry.Cheque)); } } htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", underPayment_html); plainContents = plainContents.Replace("[PAYMENT_NOTE]", underPayment_plain); String camping_html = ""; String camping_plain = ""; UserCamping userCamping = new UserCamping(us.ID); if (userCamping.ID > -1) { String[] daysSplit = userCamping.PitchDetails[0].CampingDays.Split(','); String Days = ""; foreach (String day in daysSplit) { DateTime dt = Convert.ToDateTime(day); if (Days.Length > 1) Days += ", "; Days += dt.ToString("ddd"); } camping_html = String.Format("<h3>Camping Confirmation</h3><p>Camping Group Name: <b>{0}</b></p><p>Nights Camping: <b>{1}</b></p><p>Number Of Pitches: <b>{2}</b></p>", userCamping.PitchDetails[0].PartyName, Days, userCamping.PitchDetails.Count()); camping_plain = String.Format("Camping Confirmation{3}--------------------{3}Camping Group Name:{0}{3}Nights Camping:{1}{3}Number Of Pitches: {2}{3}", userCamping.PitchDetails[0].PartyName, Days, userCamping.PitchDetails.Count(), Environment.NewLine); } htmlContents = htmlContents.Replace("[CAMPING]", camping_html); plainContents = plainContents.Replace("[CAMPING]", camping_plain); if (currentUser.firstTime) { String prelogon = Guid.NewGuid().ToString(); prelogon = "?verify=" + prelogon.Substring(0, prelogon.Length - 4) + showEntry.UserId.ToString().PadLeft(4, '0'); htmlContents = htmlContents.Replace("[PRELOGON]", prelogon); plainContents = plainContents.Replace("[PRELOGON]", prelogon); } else { String prelogon = Guid.NewGuid().ToString(); prelogon = "?quick=" + prelogon.Substring(0, prelogon.Length - 4) + showEntry.UserId.ToString().PadLeft(4, '0'); htmlContents = htmlContents.Replace("[PRELOGON]", prelogon); plainContents = plainContents.Replace("[PRELOGON]", prelogon); } MailMessage mm = new MailMessage(); AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); LinkedResource logoImage = new LinkedResource(HttpContext.Current.Server.MapPath("/Content/Assets/logo.gif"), MediaTypeNames.Image.Gif); logoImage.ContentId = "LogoImage"; //htmlView.LinkedResources.Add(logoImage); AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.Body = plainContents; mm.AlternateViews.Add(htmlView); try { SmtpClient client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(currentUser.EmailAddress, currentUser.Name)); mm.Subject = String.Format("Show Confirmation - {0} ({1:dd MMM yyyy})", thisShow.ShowName, thisShow.ShowDate); client.Send(mm); } catch (Exception e) { AppException.LogEvent("Error Sending Email from AdminEntered Show:" + e.Message + "-" + e.StackTrace); } } return status; }
public void SendSavedEmail(int ShowId, int UserId, String userRefNo) { Shows show = new Shows(ShowId); User currentUser = new User(UserId); // // if entered show, send email saying entered show String htmlContents = readTemplate("SavedShows", "html", show, userRefNo); String plainContents = readTemplate("SavedShows", "txt", show, userRefNo); MailMessage mm = new MailMessage(); String Classes_entered_html = "<table>"; String Classes_entered_plain = ""; List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(ShowId); List<Dogs> dogList = Dogs.GetAllDogsForHandler(UserId, show.ShowDate); foreach (Dogs d in dogList) { DogClasses dogClasses = new DogClasses(d.ID, ShowId); dogClasses.getDogsClasses(ShowId); if (d.Grade != 0) { bool dogEntered = false; foreach (ShowClasses cls in classList) { int clsIndex = dogClasses.Classlist.IndexOf(cls.ID); if (clsIndex > -1) { if (!dogEntered) { Classes_entered_html += String.Format("<tr style='font-weight:bold;'><td colspan='3'><b>{0} (Grade {1}) {2}</b></td></tr>", d.PetName, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option")); Classes_entered_plain += String.Format("{1}{0}{1}--------------------------------{1} (Grade {2}) {3}", d.PetName, Environment.NewLine, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option")); } Classes_entered_html += "<tr>"; Classes_entered_html += String.Format("<td style='width:25px'></td><td>{0}</td><td>{1} {2} {3} {4} {5}</td>", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.ClassName, cls.longCatagory, cls.getGrades); Classes_entered_plain += String.Format("{0} - {1} {2} {3} {4} {5} {6}", cls.ClassNo, cls.longHeight, cls.LongClassName, cls.ClassName, cls.longCatagory, cls.getGrades, Environment.NewLine); Classes_entered_html += "</tr>"; dogEntered = true; } } } } Classes_entered_html += "</table>"; Classes_entered_plain += Environment.NewLine; htmlContents = htmlContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy")); plainContents = plainContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy")); htmlContents = htmlContents.Replace("[CLASSES_ENTERED]", Classes_entered_html); plainContents = plainContents.Replace("[CLASSES_ENTERED]", Classes_entered_plain); string campingdetails_html = ""; string campingdetails_plain = ""; var usershowid = Convert.ToInt32(userRefNo); var uc = new UserCamping(usershowid); if (uc.ID > -1) { campingdetails_html = $"<h3>Camping Details</h3><div>Party Name: <b>{uc.PitchDetails[0].PartyName}</b><br>{uc.PitchDetails[0].CampingDays}</div>"; campingdetails_plain = $"Party Name: {uc.PitchDetails[0].PartyName}\n\r{uc.PitchDetails[0].CampingDays}"; } htmlContents = htmlContents.Replace("[CAMPING_DETAILS]", campingdetails_html); plainContents = plainContents.Replace("[CAMPING_DETAILS]", campingdetails_plain); var helpingdetailsHtml = ""; var helpersList = Helpers.HelperForShow(ShowId, UserId); if (helpersList.Count > 0) { helpingdetailsHtml += "<div id='helperdetails' class='infoText'><h3>Helping Details</h3>"; foreach (Helpers helper in helpersList) { String judge = ""; if (helper.JudgeID > -1) { var j = new Judge(helper.JudgeID); judge = "Judge: " + j.Name; } String ring = ""; if (helper.RingNo > 0) { ring = "Ring No:" + helper.RingNo.ToString(); } helpingdetailsHtml += $"<div >{helper.HelpDate:ddd dd MMM} - {helper.expandJob()} {judge} {ring}</div>"; String.Format("{0:ddd dd MMM} - {1} {2} {3}", helper.HelpDate, helper.expandJob(), judge, ring); } helpingdetailsHtml += "</div>"; helpingdetailsHtml += "\n"; } htmlContents = htmlContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml); plainContents = plainContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml); Decimal totals = 0; String table = CreateTotalsSummaryEmail(ShowId, UserId, ref totals); //htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", table); AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); //htmlView.LinkedResources.Add(logoImage); AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.AlternateViews.Add(plainView); mm.AlternateViews.Add(htmlView); Business.Audit.Entry(ShowId, UserId, plainContents); try { var client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(currentUser.EmailAddress, currentUser.Name)); mm.Bcc.Add(new MailAddress("*****@*****.**", "saved show entry")); mm.Subject = $"Entry Confirmation {show.ShowName} ({show.ShowDate:dd MMM yyyy})"; client.Send(mm); } catch (Exception e) { AppException.LogEvent("Error SendSaved:" + e.Message + "-" + e.StackTrace); } }
public ActionResult ShowDocs(int Id) { ShowAdminDocs sd = new ShowAdminDocs(); DogClasses dogCls = new DogClasses(); sd.EntrySummary = dogCls.getEntryCounts(Id); sd.RingList = Rings.GetAllRingsForShow(Id); sd.ClassesList = ShowClasses.GetAllClassesForShow(Id); sd.ShowDetails = Business.ShowDetails.GetShowDetails(Id); sd.Show = new Shows(Id); sd.TandRGenerateCheck = (Business.TrophiesRosettes.getTandRForShow(Id).Any()); return View(sd); }
public void SendEntryEmail(int ShowId, int UserId, String userRefNo) { Shows show = new Shows(ShowId); User currentUser = new User(UserId); // // if entered show, send email saying entered show String htmlContents = readTemplate("EnteredShow", "html", show, userRefNo); String plainContents = readTemplate("EnteredShow", "txt", show, userRefNo); MailMessage mm = new MailMessage(); String classesEnteredHtml = "<table>"; String Classes_entered_plain = ""; List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(ShowId); List<Dogs> dogList = Dogs.GetAllDogsForHandler(UserId, show.ShowDate); var multiClasses = TeamPairsManager.GetTeamPairClasses(ShowId); var multiTeams = TeamPairsManager.GetTeamPairsForShow(ShowId, multiClasses); foreach (Dogs d in dogList) { DogClasses dogClasses = new DogClasses(d.ID, ShowId); dogClasses.getDogsClasses(ShowId); if (d.Grade != 0) { bool dogEntered = false; foreach (ShowClasses cls in classList) { int clsIndex = dogClasses.Classlist.IndexOf(cls.ID); if (clsIndex > -1) { if (!dogEntered) { classesEnteredHtml += String.Format("<tr style='font-weight:bold;'><td colspan='3'><b>{0} ({1}) {2} </b></td></tr>", d.PetName, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option")); Classes_entered_plain += String.Format("{1}{0}{1}--------------------------------{1} ({2}) {3}", d.PetName, Environment.NewLine, d.Grade, (dogClasses.Lho == 0 ? "" : "Entered lower height option")); } classesEnteredHtml += "<tr>"; classesEnteredHtml += String.Format("<td style='width:25px'></td><td>{0}</td><td>{1} {2} {3} {4} {5}</td>", cls.ClassNo, cls.NormalName(withClassNo: false)); Classes_entered_plain += String.Format("{0} - {1} {2} {3} {4} {5} {6}", cls.ClassNo, cls.NormalName(withClassNo: false), Environment.NewLine); classesEnteredHtml += "</tr>"; dogEntered = true; } } } } foreach (var team in multiTeams.Where(t => t.UserId == UserId)) { if (team.Team) { classesEnteredHtml += $@" <tr style='height:25px' ><td colspan='3'></td><tr> <td>Team Name<br>{team.TeamDetails.TeamName.Replace("'", "'")}</td> <td colspan='2'>Captain<br/>{team.TeamDetails.Captain.Replace("'", "'")}</td> </tr>"; Classes_entered_plain += $@"Team Name:{team.TeamDetails.TeamName.Replace("'", "'")} Team Captain:{team.TeamDetails .Captain.Replace("'", "'")}{Environment.NewLine}"; foreach (var member in team.Members) { classesEnteredHtml += $@" <tr> <td> {member.HandlerName.Replace("'", "'")}</td> <td colspan='2'>{member.DogName.Replace("'", "'")}</td> </tr><tr> "; Classes_entered_plain += $@" {member.HandlerName.Replace("'", "'")}, {member.DogName.Replace("'", "'")}{Environment.NewLine}"; } } } classesEnteredHtml += " </table>"; Classes_entered_plain += Environment.NewLine; htmlContents = htmlContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy")); plainContents = plainContents.Replace("[CLOSING_DATE]", show.ClosingDate.ToString("ddd, dd MMM yyyy")); htmlContents = htmlContents.Replace("[CLASSES_ENTERED]", classesEnteredHtml); plainContents = plainContents.Replace("[CLASSES_ENTERED]", Classes_entered_plain); string campingdetails_html = ""; string campingdetails_plain = ""; var usershowid = Convert.ToInt32(userRefNo); var uc = new UserCamping(usershowid); if (uc.ID > -1) { campingdetails_html = $"<h3>Camping Details</h3><div>Party Name: <b>{uc.PitchDetails[0].PartyName}</b><br>{uc.PitchDetails[0].CampingDays}</div>"; campingdetails_plain = $"Party Name: {uc.PitchDetails[0].PartyName}\n\r{uc.PitchDetails[0].CampingDays}"; } htmlContents = htmlContents.Replace("[CAMPING_DETAILS]", campingdetails_html); plainContents = plainContents.Replace("[CAMPING_DETAILS]", campingdetails_plain); var helpingdetailsHtml = ""; var helpersList = Helpers.HelperForShow(ShowId, UserId); if (helpersList.Count > 0) { helpingdetailsHtml += "<div id='helperdetails' class='infoText'><h3>Helping Details</h3>"; foreach (var helper in helpersList) { var judge = ""; if (helper.JudgeID > -1) { var j = new Judge(helper.JudgeID); judge = "Judge: " + j.Name; } var ring = ""; if (helper.RingNo > 0) { ring = "Ring No:" + helper.RingNo.ToString(); } helpingdetailsHtml += $"<div >{helper.HelpDate:ddd dd MMM} - {helper.expandJob()} {judge} {ring}</div>"; } helpingdetailsHtml += "</div>"; helpingdetailsHtml += "\n"; } htmlContents = htmlContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml); plainContents = plainContents.Replace("[HELPING_DETAILS]", helpingdetailsHtml); var totals = 0m; var table = CreateTotalsSummaryEmail(ShowId, UserId, ref totals); var htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); var plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.AlternateViews.Add(plainView); mm.AlternateViews.Add(htmlView); var client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(currentUser.EmailAddress, currentUser.Name)); mm.Subject = $"Entry Confirmation {show.ShowName} ({show.ShowDate:dd MMM yyyy})"; try { client.Send(mm); } catch (Exception e) { AppException.LogError("Error SendEntry:" + e.Message + "-" + e.StackTrace); } }
private ShowEntry GetCurrentEntry(int ShowId, int UserId, int handlerType) { var currentEntry = new ShowEntry(); var us = new UserShows(UserId, ShowId); currentEntry.HandlerType = us.HandlerType; currentEntry.OptOut = us.Optout; currentEntry.EnterData = ""; Shows thisShow = new Shows(ShowId); Dogs dog = new Dogs(); var DogDetails = Dogs.GetAllDogsForHandler(UserId, thisShow.ShowDate); var UserDetails = new User(UserId); var classList = ShowClasses.GetAllClassesForShow(ShowId); List<validClassesForDog> validDogClasses = new List<validClassesForDog>(); foreach (Dogs d in DogDetails) { if (currentEntry.EnterData.Length > 0) currentEntry.EnterData += ","; validClassesForDog vc4d = new validClassesForDog(d.ID); validDogClasses.Add(vc4d); DogClasses dc = new DogClasses(d.ID, ShowId); dc.getDogsClasses(ShowId); currentEntry.EnterData += String.Format("{0}:", d.ID); foreach (ShowClasses cls in classList) { if (dc.Classlist.IndexOf(cls.ID) > -1) { currentEntry.EnterData += cls.ID + "."; } } } var userCamping = UserCamping.GetUserShow(us.ID); if (userCamping.ID > -1) { currentEntry.CampingDays = userCamping.PitchDetails[0].CampingDays; currentEntry.CampingParty = userCamping.PitchDetails[0].PartyName; currentEntry.CampComments = userCamping.PitchDetails[0].Comments; currentEntry.Plots = userCamping.PitchDetails.Count(); } return currentEntry; }