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 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 PdfPCell userCampingDetails(UserShows userShow) { User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); PdfPCell panelCell = new PdfPCell(); panelCell.BorderWidth = 1; panelCell.Padding = 4; PdfPTable panelTable = new PdfPTable(new float[] { 500}); panelCell.AddElement(panelTable); PdfPCell cell; var campingSummary = new UserCamping(userShow.ID); if (campingSummary != null && campingSummary.PitchDetails.Any()) { cell = new PdfPCell(new Phrase(new Chunk("Camping Details", headerFont))); cell.BorderWidth = 0; cell.PaddingBottom = 10; panelTable.AddCell(cell); var camp = campingSummary.PitchDetails[0]; if (!string.IsNullOrEmpty(camp.PartyName)) { cell = new PdfPCell(new Phrase(new Chunk(string.Format("Party Name:{0}", camp.PartyName), judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); } var para = new Paragraph() { new Phrase("Camping Pitch:", judgeFont) }; foreach (var pitch in campingSummary.PitchDetails ) { para.Add(new Phrase(pitch.PitchNo.ToString() + " ", judgeFont)); } cell = new PdfPCell(para); cell.BorderWidth = 0; panelTable.AddCell(cell); var tmp = ""; foreach(var day in camp.CampingDays.Split(',') ) { if (tmp.Length > 0) tmp += ", "; DateTime dt; DateTime.TryParseExact(day, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt); tmp += dt.ToString("ddd dd MMM"); } cell = new PdfPCell(new Phrase(new Chunk(tmp, judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); } else { panelCell = new PdfPCell(); panelCell.BorderWidth = 0; } return panelCell; }
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; }
public JsonResult SetPartyName(int CampingId, string Value) { var uc = new UserCamping(CampingId); UserCamping.SetPartyName(CampingId, Value); return Json(new { Status = 0, Extra = Value }); }
public static decimal costOfEntry(int ShowId, int UserId) { var us = new UserShows(UserId, ShowId); var userCamping = new UserCamping(us.ID); if (userCamping.ID == -1 ) return 0M; var cost = 0M; var showCamping = new Camping(ShowId); var maxShowNights = (showCamping.Enddate - showCamping.Startdate).Days + 1; var userShowNight = userCamping.PitchDetails[0].CampingDays.Split(',').Count(); switch (showCamping.ChargeType) { case 0: case 1: if (maxShowNights == userShowNight) { cost = showCamping.Costpershow ; } else { cost = showCamping.Costpernight * userShowNight ; } break; case 2: cost = showCamping.Costpershow; break; } return cost * userCamping.PitchDetails.Count; }
public PaymentSummary CreateTotalsSummary(int ShowID, int UserID, ref Decimal totals) { ShowClasses classes = new ShowClasses(); List<ShowClasses.Totals> totalsList = classes.getShowTotalsForUser(ShowID, UserID); PaymentSummary paymentSummary = new PaymentSummary(); decimal standardClassAmount = 0; foreach (ShowClasses.Totals total in totalsList) { if (total.ChargeType == 1) { standardClassAmount = total.ChargeRate; } paymentSummary.add(new ChargableItem(total.ChargeName, total.ChargeRate, total.Count, ChargableTypes.STANDARD, total.ChargeType)); } UserShows us = new UserShows(UserID, ShowID); // // check if alt handlers are judging // if (us.HandlerType == 0) { List<AltHandler> altHList = AltHandler.GetAllAltHandlersList(us.Userid); foreach (AltHandler alt in altHList) { if (Judge.isJudgeAtShow(alt.AltHandlerID, ShowID)) { us.HandlerType = 2; } } } Decimal val = 0; List<ShowDiscounts> list = ShowDiscounts.getDiscountsByType(ShowID, us.HandlerType); foreach (ShowDiscounts sd in list) { String tmp = ""; if (sd.DiscountType == (int)DiscountTypes.Fixed) { val = sd.Amount; tmp = sd.DiscountName + " " + sd.SubTypeName; } else if (sd.DiscountType == (int)DiscountTypes.Member) { tmp = sd.DiscountName + " discount " + sd.SubTypeName; tmp = tmp.Replace("'n'", sd.Amount.ToString()); val = -(sd.Amount * standardClassAmount); } paymentSummary.add(tmp, val, 1, ChargableTypes.DISCOUNT); totals += val; } if (us.ID > -1) { Camping showCamping = new Camping(us.ShowID); UserCamping userCamping = new UserCamping(us.ID); int Nights = 0; if (userCamping.ID > -1) { //ShowCharges chg = new ShowCharges(us.ShowID, 6); // Get Camping Charge for This Show Nights = userCamping.PitchDetails[0].CampingDays.Split(',').Length; } paymentSummary.add("Camping", showCamping.Costpernight, Nights, ChargableTypes.CAMPING); } if (totals > 0) { paymentSummary.add("Outstanding Payments", totals, 0, ChargableTypes.TRANSACTION); } else if (totals < 0) { paymentSummary.add("Over Payments", totals, 0, ChargableTypes.TRANSACTION); } return paymentSummary; }
public PaymentSummary GetDiscounts(int ShowId, int UserId, int HandlerType, bool fromAdmin = false, bool campingFull = false) { var paymentSummary = new PaymentSummary(); var us = new UserShows(UserId, ShowId) {HandlerType = HandlerType}; UserCamping.GetCampingSummary(ShowId, UserId); var charges = ShowCharges.getClassChargeDetails(ShowId); var discountList = ShowDiscounts.getDiscountsByType(ShowId, HandlerType, (int)DiscountTypes.TransactionCharge); var allDiscounts = ShowDiscounts.getClassChargeDetails(ShowId); var adminCharge = allDiscounts.FirstOrDefault(x => x.DiscountName == "Admin Charge"); var onlineCharge = allDiscounts.FirstOrDefault(x => x.DiscountName == "Transaction Charge"); // // Added display what has already been paid and add/subtract difference. var showTransactions = new List<Transaction>(); if (us.ID > -1) { showTransactions = Transaction.getTransactionForShowUser(us.RefCode); if (showTransactions.Any(x => x.EnteredBy == (int)Transaction.ENTERED_BY.SHOW_ADMIN_ENTRY)) { if (adminCharge != null) { paymentSummary.add("Admin Charge", adminCharge.Amount, 0, ChargableTypes.OFFLINE_CHARGE); } } if (showTransactions.Any(x => x.EnteredBy == (int)Transaction.ENTERED_BY.ONLINE_ENTRY) || us.Status != 3 ) { if (onlineCharge!= null) { if (fromAdmin) { var onlineEntryCnt = showTransactions.Count(x => x.EnteredBy == 0 && x.TransactionType == TransactionTypes.ShowEntryPayment && x.Amount > 0); if (onlineEntryCnt > 0) { paymentSummary.add("'n' Online Charges ", onlineCharge.Amount, onlineEntryCnt, ChargableTypes.TRANSACTION_CHARGE_ADMIN); } } else { paymentSummary.add("Transaction Charge", onlineCharge.Amount, 0, ChargableTypes.TRANSACTION_CHARGE); } } } } else { if (fromAdmin) { if (adminCharge != null) { paymentSummary.add("Admin Charge", adminCharge.Amount, 0, ChargableTypes.OFFLINE_CHARGE); } } else { if (onlineCharge != null) { paymentSummary.add("Transaction Charge", onlineCharge.Amount, 0, ChargableTypes.TRANSACTION_CHARGE); } } } var showCamping = new Camping(ShowId); foreach (var sd in discountList) { var tmp = sd.DiscountName + " discount " + sd.SubTypeName; tmp = tmp.Replace("'n'", sd.Amount.ToString()); if (sd.Subtype == (int)CHARGES_SUBTYPES.n_NightsCamping) { if (!campingFull) { paymentSummary.add(tmp, showCamping.Costpernight, Convert.ToInt32(sd.Amount), ChargableTypes.DISCOUNT_CAMPING); } } else if (sd.Subtype == (int)CHARGES_SUBTYPES.percentCamping) { if (!campingFull) { paymentSummary.addDiscount(tmp, sd.Amount, sd.Subtype, ChargableTypes.DISCOUNT_CAMPING, sd.ChargeType); } } else if (sd.Subtype == (int)CHARGES_SUBTYPES.n_RunsFree) { paymentSummary.addDiscount(tmp, sd.Amount, sd.Subtype, ChargableTypes.DISCOUNT, sd.ChargeType); } else if (sd.Subtype == (int)CHARGES_SUBTYPES.percentOff) { paymentSummary.addDiscount(tmp, sd.Amount, sd.Subtype, ChargableTypes.DISCOUNT, sd.ChargeType); } } int lastChargeType = -1; var usedAtShow = ShowClasses.GetChargeTypesForShow(ShowId); foreach (ShowChargeTypes item in usedAtShow) { var charge = charges.FirstOrDefault(x => x.ChargeType == item.ChargeTypeId); if (charge != null) { lastChargeType = charge.ChargeType; paymentSummary.add(charge, ChargableTypes.STANDARD); } } if (showCamping.ID > -1 && !campingFull) { UserCamping userCamping = new UserCamping(us.ID); var maxNights = (showCamping.Enddate - showCamping.Startdate).Days + 1; int Nights = 0; if (userCamping.ID > -1) { var list = userCamping.PitchDetails[0].CampingDays.Split(',').Where(x => x.Length > 0); Nights = list.Count() * userCamping.PitchDetails.Count; } if (showCamping.Costpershow > 0) { paymentSummary.add("Camping", showCamping.Costpershow, maxNights, ChargableTypes.MAXCAMPING); } if (showCamping.ChargeType == 1) { if (showCamping.Costpershow == 0) { paymentSummary.add("Camping", showCamping.Costpershow, maxNights, ChargableTypes.MAXCAMPING); } paymentSummary.add("Camping", showCamping.Costpernight, Nights, ChargableTypes.CAMPING); } if (showCamping.ChargeType == 2) { paymentSummary.add("Camping", showCamping.Costpershow, Nights, ChargableTypes.CAMPING_FIXFEE); } } Decimal val = 0M; showTransactions.ForEach(x => val += x.Amount); if (showTransactions.Any()) { decimal lastPayment = 0; decimal showEntries = 0; // if (showTransactions.LastOrDefault().TransactionType != TransactionTypes.RefundPaid) if (showTransactions.Any(x => x.TransactionType == TransactionTypes.ShowEntryPayment)) { lastPayment = showTransactions.Where(x => x.TransactionType == TransactionTypes.ShowEntryPayment).Sum(x => x.Amount); if (lastPayment != 0) { paymentSummary.add("Payments Received", lastPayment, 0, ChargableTypes.TRANSACTION); } } if (showTransactions.Any(x => x.TransactionType == TransactionTypes.ShowEntry)) { showEntries = showTransactions.Where(x => x.TransactionType == TransactionTypes.ShowEntry).Sum(x => x.Amount); paymentSummary.add("Fees", showEntries, 0, ChargableTypes.TRANSACTION); } if (showTransactions.Any(x => x.TransactionType == TransactionTypes.TransactionCharge)) { showEntries = showTransactions.Where(x => x.TransactionType == TransactionTypes.TransactionCharge).Sum(x => x.Amount); paymentSummary.add("Transaction Charges", showEntries, 0, ChargableTypes.TRANSACTION); } if (showTransactions.Any(x => x.TransactionType == TransactionTypes.RefundRequest)) { showEntries = showTransactions.Where(x => x.TransactionType == TransactionTypes.RefundRequest).Sum(x => x.Amount); paymentSummary.add("RefundRequest", showEntries, 0, ChargableTypes.TRANSACTION); } if (showTransactions.Any(x => x.TransactionType == TransactionTypes.RefundPaid)) { var refunds = showTransactions.Where(x => x.TransactionType == TransactionTypes.RefundPaid); showEntries = refunds.Sum(x => x.Amount); paymentSummary.add("RefundPaid", showEntries, 0, ChargableTypes.TRANSACTION); var RefundChargeAmount = DiscountManager.GetRefundCharge(ShowId); paymentSummary.add("RefundCharge", RefundChargeAmount, refunds.Count(), ChargableTypes.REFUND_CHARGE); } if (showTransactions.Any(x => x.TransactionType == TransactionTypes.RefundCancelled)) { var refunds = showTransactions.Where(x => x.TransactionType == TransactionTypes.RefundCancelled); showEntries = refunds.Sum(x => x.Amount); paymentSummary.add("RefundCancelled", showEntries, 0, ChargableTypes.TRANSACTION); } } return paymentSummary; }
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 static decimal calcNewTotalForEntry(UserShows userShow, Camping showCamping, int singleEntryId, ref decimal discountTotal, ref int addNewTransation) { var showTransactions = Transaction.getTransactionForShowUser(userShow.RefCode); decimal fixedFees = 0M; var showEntries = DogClasses.calcCostOfEntry(userShow.ShowID, userShow.Userid); var entryCost = showEntries.Sum(x => x.Total); var noOfSingleEntries = showEntries.FirstOrDefault(x => x.ChargeTypeId == singleEntryId); if (noOfSingleEntries == null) { AppException.LogEvent(string.Format("calcNewTotalForEntry - null no of single entries:ShowId={0}, UserId={1}, showRef={2}", userShow.ShowID, userShow.Userid, userShow.ID)); } var entriesDiscount = Math.Abs(ShowDiscounts.getDiscountFor(userShow.ShowID, userShow.Userid, "entry", (noOfSingleEntries != null ? noOfSingleEntries.Count : 0), showEntries).Amount); discountTotal = entriesDiscount; var currentEntryCost = (entryCost - entriesDiscount); if (!(ShowDiscounts.discount100Percent(userShow.ShowID, userShow.Userid, "entry") && currentEntryCost == 0)) { fixedFees = ShowDiscounts.getDiscountsByType(userShow.ShowID, -1, (int)DiscountTypes.TransactionCharge).Sum(x => x.Amount); currentEntryCost += fixedFees; } var uc = new UserCamping(userShow.ID); if (uc.ID > -1) { var campingCost = Camping.costOfEntry(userShow.ShowID, userShow.Userid); var campingDiscount = ShowDiscounts.getDiscountFor(userShow.ShowID, userShow.Userid, "camping", uc.Nights, null, campingCost); var discount = 0M; if (showCamping.ChargeType < 2) { 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: currentEntryCost += campingCost; break; } } else if (showCamping.ChargeType == 2) { currentEntryCost += campingCost; if (campingDiscount.Type != 0) { discountTotal += campingCost - campingDiscount.Amount; currentEntryCost += -campingDiscount.Amount; } } } 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.RefundPaid) .Sum(x => x.Amount); if (previousEntryCost == 0) { addNewTransation = 1; return currentEntryCost; } if (whatHasBeenPaid == 0) { if (Math.Abs(previousEntryCost) == currentEntryCost) { addNewTransation = 0; return Math.Abs(previousEntryCost); } addNewTransation = 2; return currentEntryCost; } else { if (Math.Abs(previousEntryCost) == currentEntryCost) { addNewTransation = 0; } else { currentEntryCost += fixedFees; } } return currentEntryCost - (whatHasBeenPaid - (whatHasBeenRequested - whatHasBeenRefund)); }
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; }
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; }
private static decimal existingShowEntryCost(int ShowId, int UserId) { var userShow = new UserShows(UserId, ShowId); var showTransactions = Transaction.getTransactionForShowUser(userShow.RefCode); var showEntries = DogClasses.calcCostOfEntry(ShowId, UserId); var singleEntryId = getSingleEntry(ShowId); var entryCost = showEntries.Sum(x => x.Total); var noOfSingleEntries = showEntries.First(x => x.ChargeTypeId == singleEntryId); var entriesDiscount = Math.Abs(ShowDiscounts.getDiscountFor(ShowId, UserId, "entry", noOfSingleEntries.Count, showEntries).Amount); var discountTotal = entriesDiscount; var currentEntryCost = (entryCost - entriesDiscount); var uc = new UserCamping(userShow.ID); if (uc.ID > -1) { var showCamping = new Camping(ShowId); var campingCost = Camping.costOfEntry(ShowId, UserId); var campingDiscount = ShowDiscounts.getDiscountFor(ShowId, 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 previousEntry = 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) // .Sum(x => x.Amount); return Math.Abs(previousEntry) - whatHasBeenPaid - discountTotal; }