public ActionResult Caller(int showId, int showDetailsId, int ringId, int showClassId)
        {
            var tmp = new CallingListModel
            {
                CallingList = new List<DogClassDetails>(),
                QueueList = new List<DogClassDetails>(),
                CourseDetails = new Domain.Managers.ClassManager().GetCourseDetails(showClassId)
            };
            var callingList = new ShowClasses().GetCallingList(showId, showClassId);

            foreach (var item in callingList)
            {
                var us = new UserShows(item.UserId, showId);
                tmp.CallingList.Add(new DogClassDetails
                {
                    ClassId = showClassId,
                    DogId = item.DogId,
                    HandlerType = us.HandlerType,
                    RO = item.Ro,
                    Status = item.Status,
                    HandlerName = Utils.TitleCaseString(item.Name),
                    DogName = Utils.TitleCaseString(item.KcName),
                    Lho = item.Lho,
                    Grade = item.Grade,
                    Veteran = item.Veteran
                });
            }

            var queued = new Fpp.Domain.Managers.QueueManager().GetQueued(showClassId);
            foreach(var item in queued )
            {
                var details = tmp.CallingList.First(x => x.DogId == item.DogId);

                tmp.QueueList.Add(new DogClassDetails {
                    ClassId= showClassId,
                    DogId = item.DogId,
                    RO = details.RO,
                    DogName = details.DogName,
                    HandlerName = details.HandlerName,
                    HandlerType = details.HandlerType,
                    Position = item.Position,
                    Grade = details.Grade,
                    Lho = details.Lho,
                    Veteran = details.Veteran
                });
            }

            var show = new Shows(showId);
            var showDetails = new ShowDetails(showDetailsId);
            var showClass = new ShowClasses(showClassId);
            ViewBag.ShowName = show.ShowName;
            ViewBag.Day = showDetails.ShowDate.ToString("ddd, dd MMM");
            ViewBag.ClassName = showClass.NormalName();
            ViewBag.ClassId = showClassId;
            ViewBag.RingId = ringId;
            ViewBag.ShowId = showId;

            return View(tmp);
        }
        public void ProcessRequest(HttpContext context)
        {
            var showId = Convert.ToInt32(context.Request["showid"]);
            var doctype = context.Request["doctype"];
            var show = new Shows(showId);
            var path = context.Server.MapPath(@"..\schedules\");
            path += show.ShowDate.ToString("yyyy");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            var fileCollection = context.Request.Files;
            for (var i = 0; i < fileCollection.Count; i++)
            {
                var upload = fileCollection[i];
                var ext = Path.GetExtension(upload.FileName);
                var filename =
                    $"{show.ShowName.Trim().Replace("&", "-")}_{show.ShowDate:ddMMyyyy}_{doctype}{ext}";
                var showDocuments = Business.ShowDocuments.Find(filename);
                showDocuments.Name = doctype;
                showDocuments.Url = filename;
                showDocuments.ShowId = showId;
                showDocuments.Save();
                upload.SaveAs(path + @"\" + filename);
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write("OK");
        }
 public ActionResult Camping(int id)
 {
     var show = new Shows(id);
     var showCampingList = ShowCampingList.getShowCampingList(id, "Name", 0);
     var cmp = new Camping(id);
     List<DateTime> cmpDays = new List<DateTime>();
     var start = cmp.Startdate;
     var end = cmp.Enddate;
     do
     {
         cmpDays.Add(start);
         start = start.AddDays(1);
     } while (start <= end);
     return View(new CampingModel
     {
         Show = show,
         ShowName = show.ShowName,
         ShowDetails = Business.ShowDetails.GetShowDetails(id),
         ShowCamping = cmp,
         CampingDays = cmpDays,
         CampingTotals = Business.Camping.getCampingTotals(id),
         PaidUsers = showCampingList.Count(x => x.UserShowStatus == 3 && x.HandlerType == 0),
         Members = showCampingList.Count(x => x.HandlerType == 1),
         Judges = showCampingList.Count(x => x.HandlerType == 2),
         NotPaidMembers = showCampingList.Count(x => x.HandlerType == 1 && x.UserShowStatus != 3),
         NotPaidJudges = showCampingList.Count(x => x.HandlerType == 2 && x.UserShowStatus != 3),
         WaitingList = Business.WaitingList.getWaitList(id),
         ShowCampingList = showCampingList,
         CampingSummary = UserCamping.GetCampingSummary(id, 0)
     });
 }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);
            StringBuilder builder = new StringBuilder();

            builder.Append("Discounts\n\r");
            builder.AppendFormat("{0} Show Date:{1}\n\r", show.ShowName, show.ShowDate.ToString("dd MMM yyyy"));
            builder.Append("Payment Date,Show Ref,Account Name,Amount\n\r");
            var masterList = Transaction.getDiscountsForShow(ShowID);
            decimal total = 0;
            foreach (var row in masterList)
            {

                var u = new User(row.Userid);
                builder.Append(string.Format("{0:dd MMM yyyy},{1},{2},{3:0.00}\n\r",
                    row.TransactionDate,
                    row.RefCode,
                    u.Name,
                    row.Cheque));

                total += row.Cheque;
                total += row.Amount;
            }

            builder.AppendFormat("\n\r,,,,Total {0:0.00}\n\r\n\r", total); context.Response.ClearContent();
            context.Response.ContentType = "application/csv";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=ChequeList-{0:ddMMMyyyy}.csv", show.ShowDate));
            context.Response.Write(builder);
        }
        public static void DeleteFile(int showId, string Path, string name)
        {
            if (Path == null) throw new ArgumentNullException(nameof(Path));
            var show = new Shows(showId);
            var path = Path;
            path += show.ShowDate.ToString("yyyy");

            var showDocs = ShowDocuments.getShowDocumentsFor(showId).Where(x => x.Name == name && x.ShowId == showId);
            foreach (var item in showDocs )
            {
                var file = path + @"\" + item.Url;
                FileInfo fi = new FileInfo(file);
                if (fi.Exists)
                {
                    try
                    {
                        fi.Delete();
                        ShowDocuments.Delete(showId, name);
                    }
                    catch (Exception e)
                    {
                        AppException.LogEvent($"problem deleting file:{name} ({showId}) - {e.Message}");
                    }
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);
            StringBuilder builder = new StringBuilder();
            builder.Append("Money Report\n\r");
            builder.Append(string.Format("{0} Show Date:{1}\n\r", show.ShowName, show.ShowDate.ToString("dd MMM yyyy")));

            builder.Append("Money Outstanding\n\r");
            builder.AppendFormat("Show Reference,Name,Amount");

            List<UserShows> userShowsList = UserShows.getAllPaidUsersForShow(ShowID);
            builder.Append(PrintReport(ShowID, userShowsList,true, true));

            builder.AppendLine();

            builder.Append("Overpayments\n\r");
            builder.AppendFormat("Show Reference,Name,Amount");

            builder.Append(PrintReport(ShowID, userShowsList, false,false));

            context.Response.ClearContent();
            context.Response.ContentType = "application/vnd.ms-excel";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=OutstandingPayments-{0:ddMMMyyyy}.csv", show.ShowDate));
            context.Response.Write(builder);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int showid = Convert.ToInt32(Request["showid"]);
            ShowID.Value = showid.ToString();
            show = new Shows(showid);
            DataSet ds = UserShows.getAllUserShowDetailsDS(showid);
            String html = "";
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                int contactStatus = Convert.ToInt32(row["ContactStatus"]);
                String dtstr = "";
                if (row["ContactDate"] != DBNull.Value)
                {
                    DateTime dt = Convert.ToDateTime(row["ContactDate"]);
                    if (dt.Year != 1970)
                    {
                        dtstr = dt.ToString("dd-MMM hh:mm:ss");
                    }
                }
                String contactStatusStr = "Not Sent";

                if (contactStatus == 1)
                {
                    contactStatusStr = "Sent";
                }

                html += String.Format("<div usershowid='{3}' contactstatus='{4}' class='bulkitem'><div class='cb'><input type='checkbox' /></div><div class='userShowName' >{0}</div><div class='contactStatus'>{1}</div><div class='contactDate'>{2}</div></div>",
                            row["Name"], contactStatusStr, dtstr, row["UserShowsID"], contactStatus
                    );
            }

            userShowList.InnerHtml = html;
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);

            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     String cmd = Request["cmd"];
     iShowID = Convert.ToInt32(Request["showid"]);
     Shows show = new Shows(iShowID);
     ShowID.Value = iShowID.ToString();
     showName = show.ShowName;
 }
 public ActionResult BlankRunningPlan(int Id)
 {
     var pdf = new Fpp.UI.Web.PDFs.RunningPlans(false).ProcessRequest(Id, new int[] { -1 });
     var showName = new Shows(Id).ShowName;
     showName = Regex.Replace(showName, @"[ ]", "_");
     Response.AppendHeader("Content-Disposition", "inline; filename=" + "RunningPlan_" + showName + ".pdf");
     return File(pdf, "application/pdf");
 }
 public ShowDetailsDto(int Id)
 {
     Show = new Shows(Id);
     ShowDetailsList = ShowDetails.GetShowDetails(Id);
     ShowClosed = DateTime.Now > Show.ClosingDate;
     ClassTypes =  Business.ClassTypes.GetClassTypesForShow(Id);
     Judges = Judge.GetAllJudgesForShow(Id);
     FileDetails = FileManager.GetSchedule(Id, System.Web.HttpContext.Current.Server.MapPath(@"~\schedules\"));
 }
        public void ProcessRequest(HttpContext context)
        {
            int id = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(id);
            var sw = new StringWriter();
            sw.WriteLine($"Class Sizes for {show.ShowName} ");

            context.Response.ClearContent();
            context.Response.ContentType = "text/csv";
            context.Response.AddHeader("content-disposition", $"inline;filename=Helpers-{show.ShowDate:ddMMMyyyy}.csv");

            var hl = new HelperModel
            {
                ShowId = id,
                SortType = "Name",
                Direction = 0
            };
            var data = Business.Helpers.GetAllHelpersForShow(id, hl.SortType, hl.Direction);
            hl.ShowDays = ShowDetails.GetShowDetails(id);

            hl.Unallocated = data.Where(x => x.RingNo < 1).OrderBy(z => (int)z.TimePeriod).ToList();
            hl.Allocated = data.Where(x => x.RingNo >= 1).OrderBy(y => y.RingNo).ToList();

            hl.Rings = Rings.GetAllRingsForShow(id);
            hl.Show = new Shows(id);

            sw.WriteLine("Unallocated Helpers");
            sw.WriteLine("Show Date, Helper Name, Time, Job Name, Judge Name, Comments");
            foreach (var showDay in hl.ShowDays)
            {
                foreach (var item in hl.Unallocated.Where(x => x.ShowDetailsID == showDay.ID).ToList())
                {
                    sw.WriteLine(string.Format("{0:ddd, dd MMM},{6},{1},{2},{3},{4},{5}",
                        showDay.ShowDate,
                        item.Name, item.TimePeriod, item.JobName, item.JudgeName, item.Comments, (item.HandlerType == 1 ? "M" : "")
                    ));
                }
            }
            sw.WriteLine("");
            sw.WriteLine("Allocated Helpers");
            sw.WriteLine("Show Date, Ring No, Helper Name, Time Allocated, Time Period, Job Name, Judge Name, Comments");
            foreach (var showDay in hl.ShowDays)
            {
                foreach (var item in hl.Allocated.Where( x=> x.ShowDetailsID == showDay.ID).ToList())
                {
                    sw.WriteLine(string.Format("{0:ddd, dd MMM},{1},{2},{3},{4},{5},{6},{7},{8}",
                        showDay.ShowDate,
                        (item.HandlerType == 1 ? "M" : ""),
                        item.RingNo,
                        item.Name, item.TimeAllocated, item.TimePeriod, item.JobName, item.JudgeName, item.Comments
                    ));
                }
            }

            context.Response.Write(sw);
            context.Response.End();
        }
        public override void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);

            DateTime fromDate,
                toDate;
            if (string.IsNullOrEmpty(context.Request["FromDate"]))
            {
                fromDate = DateTime.MinValue;
            }
            else
            {
                fromDate = DateTime.Parse(context.Request["FromDate"].ToString());
            }
            if (string.IsNullOrEmpty(context.Request["ToDate"]))
            {
                toDate = DateTime.MaxValue;
            }
            else
            {
                toDate = DateTime.Parse(context.Request["ToDate"].ToString()).AddDays(1).AddMinutes(-1);
            }

            StringBuilder builder = new StringBuilder();
            builder.Append("FPP Online Payments\n\r");
            builder.Append(string.Format("{0} Show Date:{1}\n\r", show.ShowName, show.ShowDate.ToString("dd MMM yyyy")));
            var masterList = Transaction.getOnlineUserTransactions(ShowID).Where(x => x.TransactionDate >= fromDate && x.TransactionDate <= toDate).ToList();
            List<Transaction> onlineTransations = masterList.Where(x => Regex.IsMatch(x.Comment, @"^\d+$") && x.TransactionType == TransactionTypes.ShowEntryPayment).ToList();

            var fixedFees = ShowDiscounts.getDiscountsByType(ShowID, -1, (int)DiscountTypes.TransactionCharge).Sum(x => x.Amount);
            onlineTransations = (from trans in masterList
                                 where trans.TransactionType == TransactionTypes.ShowEntryPayment
                                select new Transaction() {
                                     ID = trans.ID,
                                     Amount = trans.Amount ,
                                     Comment = trans.Comment,
                                     RefCode = trans.RefCode,
                                     Status = trans.Status,
                                     Cheque = trans.Cheque,
                                     TransactionDate = trans.TransactionDate,
                                     Userid = trans.Userid,
                                }).OrderByDescending(t => t.TransactionDate).ToList();

            //PrintReport("", masterList);
            builder.Append(PrintReport("Online", onlineTransations));
            builder.Append(PrintReport("Online Cheques", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("Cheque")).ToList()));
            builder.Append(PrintReport("Online BACS", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("BACS")).ToList()));
            builder.Append(PrintReport("Online Voucher", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("Voucher")).ToList()));
            builder.Append(PrintReport("Online Cash", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("Cash")).ToList()));

            context.Response.ClearContent();
            context.Response.ContentType = "application/vnd.ms-excel";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=FppOnlinePayments-{0:ddMMMyyyy}.csv", show.ShowDate));
            context.Response.Write(builder);
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);
            var sw = new StringWriter();
            var exportlist = DogClasses.ExportShowEntry(ShowID);
            sw.WriteLine("Ring No,KC Name, KC Number, Grade, Height, Class No, Part, RO, Handler, Breed, DoB, Sex, Email, Jnr Dob, Age, YkcNumber, Lho, HandlerType, Award By Height,Pet");

            foreach (EntryInfoDto  item in exportlist)
            {
                var HandlerName = item.Handler;
                if (!string.IsNullOrEmpty(item.ClsHandlerName))
                {
                    HandlerName = item.ClsHandlerName;
                }
                else if (!string.IsNullOrEmpty(item.DogHandlerName))
                {
                    HandlerName = item.DogHandlerName;
                }

                int age = 0;
                if (item.JnrDoB != DateTime.MinValue)
                {
                    age = show.ShowDate.Year - item.JnrDoB.Year - (show.ShowDate.DayOfYear < item.JnrDoB.DayOfYear ? 1 : 0);
                }
                String tmpname = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13:dd-MM-yyyy},{14},{15},{16},{17},{18},{19}",
                    item.RingNumber,
                    item.KCName,
                    item.KCNumber,
                    item.Grade,
                    ShowClasses.expandHeight(item.Height),
                    item.ClassNo,
                    item.Part,
                    item.RO,
                    HandlerName,
                    item.Breed,
                    item.DoB,
                    item.Sex,
                    item.EMail,
                    item.JnrDoB,
                    age,
                    item.YkcNumber,
                    (item.ClassLho > 0 ? ( item.DogLho == 1 ? "LHO" : "" ) : ""),
                    item.HandlerType,
                    item.AwardByHeight,
                    item.PetName);

                sw.WriteLine(tmpname);
            }

            context.Response.ClearContent();
            context.Response.ContentType = "text/csv";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=EntryInfo-{0:ddMMMyyyy}.csv", show.ShowDate));
            context.Response.Write(sw);
            context.Response.End();
        }
        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);

            var writer = PdfWriter.GetInstance(doc, output);
            var pageEvent = new Fpp.Core.PdfDocuments.ITextEvents();
            pageEvent.Header = "Refund Report";
            pageEvent.SubHeader = string.Format("{0} {1}", show.ShowName, show.ShowDate.ToString("dd MMM yyyy"));
            writer.PageEvent = pageEvent;
            StyleSheet sheet = new StyleSheet();

            doc.Open();
            PdfPCell cell;

            PdfPTable ptable = new PdfPTable(colWidths);
            cell = new PdfPCell(new Phrase(new Chunk("Show Reference", headerFont)));
            cell.BorderWidth = 0;
            ptable.AddCell(cell);

            ptable = new PdfPTable(colWidths);
            cell = new PdfPCell(new Phrase(new Chunk("Date", headerFont)));
            cell.BorderWidth = 0;
            ptable.AddCell(cell);

            ptable = new PdfPTable(colWidths);
            cell = new PdfPCell(new Phrase(new Chunk("Name", headerFont)));
            cell.BorderWidth = 0;
            ptable.AddCell(cell);

            ptable = new PdfPTable(colWidths);
            cell = new PdfPCell(new Phrase(new Chunk("Description", headerFont)));
            cell.BorderWidth = 0;
            ptable.AddCell(cell);
            doc.Add(ptable);

            ptable = new PdfPTable(colWidths);
            cell = new PdfPCell(new Phrase(new Chunk("Amount", headerFont)));
            cell.BorderWidth = 0;
            ptable.AddCell(cell);
            doc.Add(ptable);

            var refunds = Transaction.GetShowRefunds(ShowID);
            PrintReport(ShowID, refunds, doc);
            doc.NewPage();

            doc.Close();

            context.Response.ClearContent();
            context.Response.ContentType = "application/pdf";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=Refund-{0:ddMMMyyyy}.pdf", show.ShowDate));
            context.Response.BinaryWrite((output as MemoryStream).ToArray());
        }
 public void ProcessRequest(HttpContext context)
 {
     int ShowID = Convert.ToInt32(context.Request["showid"]);
     show = new Shows(ShowID);
     string cmd = context.Request["cmd"];
     List<int>ids=  context.Request["ids"].Split(',').Select(s=>int.Parse(s)).ToList();
     if (cmd == "download")
     {
         download(context,ids);
     }
 }
        public ActionResult BulkEmail(int showId)
        {
            var show = new Shows(showId);
            var bulkEmail = new BulkEmail
            {
                ShowEntry = UserShows.getAllUserShowDetails(showId),
                ShowId = showId,
                ShowName = show.ShowName,
            };

            return View(bulkEmail);
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            String cmd = context.Request["doc"].ToString();
            Shows show = new Shows(ShowID);

            String pdfPath = context.Server.MapPath(cmd + ".pdf");
            Boolean publish = false;
            if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true;

            Document doc = new Document(PageSize.A4, -50, -50, 2, 2);
            Stream output;
            if (publish)
            {
                String path = context.Server.MapPath(@"..\schedules\");
                path += DateTime.Today.ToString("yyyy");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName);
                output = new FileStream(path, FileMode.Create);
            }
            else
            {
                output = new MemoryStream();
            }
            var writer = PdfWriter.GetInstance(doc, output);
            StyleSheet sheet = new StyleSheet();

            doc.Open();
            var dm = new DocumentManager();

            var rings = Rings.GetAllRingsForShow(ShowID);

            foreach (var ring in rings)
            {
                dm.PrintAllForRing(doc, ShowID, ring.ID, writer);
            }
            doc.Close();

            if (publish)
            {

            }
            else
            {
                context.Response.ClearContent();
                context.Response.ContentType = "application/pdf";
                context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf"));
                context.Response.BinaryWrite((output as MemoryStream).ToArray());
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);
            var sw = new StringWriter();

            var classTotals = ClassTotals.GradedClassTotals(ShowID);
            var exportlist = ShowClasses.GetClassSizes(ShowID);
            sw.WriteLine("Class No,Class Name,Dogs In Class,Graded 1 Totals,Graded 2 Totals,Graded 3 Totals,Graded 4 Totals,Graded 5 Totals,Graded 6 Totals,Graded 7 Totals,Judge Name, Ring No, Class Order, FH, LH");

            foreach (ExportClassSizes ecs in exportlist)
            {
                String tmpname = String.Format("{0} {1} {4} {2} {3}",
                        ShowClasses.expandHeight(ecs.Height),
                        ShowClasses.expandCategory(ecs.Category),
                        ecs.LongName,
                        ecs.ClassName,
                        ShowClasses.getCompressedGrades(ecs.Grades));

                sw.Write(string.Format("{0},{1},{2},", ecs.ClassNo, tmpname, ecs.DogsInClass));
                var tmp = classTotals.Where(x=> x.ClsNo == ecs.ClassNo).OrderBy(x => x.Grade);
                if (tmp.Any())
                {
                    for (var s = 1; s <= 7; s++)
                    {
                        if (tmp.Any(x => x.Grade == s))
                        {
                            sw.Write(string.Format("{0},", tmp.Single(x => x.Grade == s).Count));
                        }
                        else
                        {
                            sw.Write("0,");
                        }
                    }
                }
                else
                {
                    for (var s = 1; s <= 7 ; s++)
                    {
                        sw.Write("0,");
                    }
                }

                sw.WriteLine(string.Format("{0},{1},{2},{3},{4}", ecs.JudgeName, ecs.RingNo, ecs.ClassOrder,ecs.Fh, ecs.Lh));
            }

            context.Response.ClearContent();
            context.Response.ContentType = "text/csv";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=ClassSizes-{0:ddMMMyyyy}.csv", show.ShowDate));
            context.Response.Write(sw);
            context.Response.End();
        }
        public ActionResult Scoreboard(int showId, int showDetailsId, int showClassId)
        {
            var scoreboard = Fpp.Domain.Managers.ResultsManager.GetResults(showClassId);

            var show = new Shows(showId);
            var showDetails = new ShowDetails(showDetailsId);
            var showClass = new ShowClasses(showClassId);
            ViewBag.ShowName = show.ShowName;
            ViewBag.Day = showDetails.ShowDate.ToString("ddd, dd MMM");
            ViewBag.ClassName = showClass.NormalName();
            ViewBag.ClassId = showClassId;
            ViewBag.ShowId = showId;
            return View(scoreboard);
        }
        public void DeleteEntry(int ShowId, int UserId)
        {
            Shows thisShow = new Shows(ShowId);
            User thisUser = new User(UserId);
            Transaction trans = new Transaction(UserId, ShowId);

            if (trans.EnteredBy == (int)Transaction.ENTERED_BY.ONLINE_ENTRY)
            {
                CancelEntry.Cancel(thisUser, thisShow);
            }
            else
            {
                CancelEntry.Cancel(thisUser, thisShow);
            }
        }
        public override void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);

            DateTime fromDate,
                toDate;
            if (string.IsNullOrEmpty( context.Request["FromDate"]))
            {
                fromDate = DateTime.MinValue;
            }
            else
            {
                fromDate = DateTime.Parse(context.Request["FromDate"].ToString());
            }
            if (string.IsNullOrEmpty( context.Request["ToDate"] ))
            {
                toDate = DateTime.MaxValue;
            }
            else
            {
                toDate = DateTime.Parse(context.Request["ToDate"].ToString());
            }

            doc = new Document(PageSize.A4, -10, -50, 100, 50);
            Stream output = new MemoryStream();
            var writer = PdfWriter.GetInstance(doc, output);
            var pageEvent = new Fpp.Core.PdfDocuments.ITextEvents( );
            pageEvent.Header = "Cheque Payments";
            pageEvent.SubHeader = string.Format("{0} Show Date:{1}", show.ShowName, show.ShowDate.ToString("dd MMM yyyy"));
            writer.PageEvent = pageEvent;

            doc.Open();
            ptable = new PdfPTable(headerWidths);

            var masterList = Transaction.getOfflineList(ShowID, fromDate, toDate);
            PrintReport("Cheque", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("Cheque")).ToList());
            PrintReport("BACS", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("BACS")).ToList());
            PrintReport("Voucher", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("Voucher")).ToList());
            PrintReport("Cash", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("Cash")).ToList());
            doc.Close();

            context.Response.ClearContent();
            context.Response.ContentType = "application/pdf";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=ChequeList-{0:ddMMMyyyy}.pdf", show.ShowDate));
            context.Response.BinaryWrite((output as MemoryStream).ToArray());
        }
        public ShowSummary(int ShowId)
        {
            int dummy = 0;

            Show = new Shows(ShowId);
            Entries = UserShows.getAllPaidUsersForShow(ShowId).Count;
            Campers = Business.Camping.getCampingTotals(ShowId);
            RunsPerDay = DogClasses.GetRunsPerDay(ShowId);
            DogsInShow = DogClasses.DogsInShow(ShowId);
            TotalForShow = RunsPerDay.Sum(x => x.Count);

            var onlineTransactions = Transaction.getOnlineUserTransactions(ShowId);
            var allDiscounts = ShowDiscounts.getClassChargeDetails(ShowId);
            var adminCharge = allDiscounts.FirstOrDefault(x => x.DiscountName == "Admin Charge").Amount;

            var offLineTransactions = Transaction.getOfflineList(ShowId, DateTime.MinValue, DateTime.Now);
            var onlinePayments = onlineTransactions.Where(t => t.TransactionType == TransactionTypes.ShowEntryPayment && int.TryParse(t.Comment, out dummy)).ToList();

            var fixedFees = ShowDiscounts.getDiscountsByType(ShowId, -1, (int)DiscountTypes.TransactionCharge).Sum(x => x.Amount);
            Online = onlinePayments.Sum(a => Math.Abs(a.Amount)) - (onlinePayments.Count() * fixedFees);
            TransactionFee = onlineTransactions.Where(t => t.TransactionType == TransactionTypes.TransactionCharge).Sum(a => Math.Abs(a.Amount));
            var entries = UserShows.getAdminEntryUserShow(ShowId);
            var OfflineCnt = entries.Count(y => y.EnteredBy.HasValue && y.EnteredBy == 1);

            Cheque = onlineTransactions.Where(t => t.TransactionType == TransactionTypes.ShowEntryPayment && t.Comment.Contains("Cheque")).Sum(x => x.Cheque);
            Bacs = onlineTransactions.Where(t => t.TransactionType == TransactionTypes.ShowEntryPayment && t.Comment.Contains("BACS")).Sum(x => x.Cheque);
            Vouchers = onlineTransactions.Where(t => t.TransactionType == TransactionTypes.ShowEntryPayment && t.Comment.Contains("Voucher")).Sum(x => x.Cheque);
            Cash = onlineTransactions.Where(t => t.TransactionType == TransactionTypes.ShowEntryPayment && t.Comment.Contains("Cash")).Sum(x => x.Cheque);

            Cheque += offLineTransactions.Where(t => t.Comment.Contains("Cheque")).Sum(x => x.Cheque);
            Bacs += offLineTransactions.Where(t => t.Comment.Contains("BACS")).Sum(x => x.Cheque);
            Vouchers += offLineTransactions.Where(t => t.Comment.Contains("Voucher")).Sum(x => x.Cheque);
            Cash += offLineTransactions.Where(t => t.Comment.Contains("Cash")).Sum(x => x.Cheque);

            AdminFee += OfflineCnt * adminCharge ;

            Discounts = onlineTransactions.Where(t => t.TransactionType == TransactionTypes.Discount).Sum(a => a.Amount)
                            + offLineTransactions.Where(t => t.TransactionType == TransactionTypes.Discount).Sum(a => a.Amount);
            TotalDiscounts = Discounts + Vouchers;

            ShowIncome = Online + Cheque + Bacs + Cash;
            Fees = TransactionFee + AdminFee;

            Camping = calcCampingCost(ShowId);
        }
        public static List<FileDetails> GetSchedule(int showId, string Path)
        {
            var showDocs = ShowDocuments.getShowDocumentsFor(showId);
            var show = new Shows(showId);
            var files = new List<FileDetails>();
            var path = Path + show.ShowDate.ToString("yyyy");

            if (!Directory.Exists(path)) return files;
            files.AddRange(from doc in showDocs
                let file = path + @"\" + doc.Url
                let fi = new FileInfo(file)
                select new FileDetails
                {
                    FileName = doc.Name, FileDate = fi.CreationTime
                });

            return files;
        }
        public override void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);

            DateTime fromDate,
                toDate;
            if (string.IsNullOrEmpty(context.Request["FromDate"]))
            {
                fromDate = DateTime.MinValue;
            }
            else
            {
                fromDate = DateTime.Parse(context.Request["FromDate"].ToString());
            }
            if (string.IsNullOrEmpty(context.Request["ToDate"]))
            {
                toDate = DateTime.MaxValue;
            }
            else
            {
                toDate = DateTime.Parse(context.Request["ToDate"].ToString()).AddDays(1).AddMinutes(-1);
            }

            StringBuilder bld = new StringBuilder();

            bld.AppendFormat("Club Transactions\n\r{0}\n\r{1}\n\r", show.ShowName, show.ShowDate.ToString("dd MMM yyyy"));
            var masterList = Transaction.getOnlineUserTransactions(ShowID)
                                .Where(x => x.TransactionDate >= fromDate && x.TransactionDate <= toDate).OrderByDescending(x => x.TransactionDate).ToList();

            var fixedFees = ShowDiscounts.getDiscountsByType(ShowID, -1, (int)DiscountTypes.TransactionCharge).Sum(x => x.Amount);

            bld.Append(PrintReport("Club Transaction List", masterList
                                    .Where(x => x.TransactionType == TransactionTypes.ShowEntryPayment &&
                                               Regex.IsMatch(x.Comment, @"^\d+$") &&
                                               x.Amount > 0)
                                    .OrderByDescending( x=> x.TransactionDate)
                                    .ToList(), fixedFees, true));

            context.Response.ClearContent();
            context.Response.ContentType = "application/vnd.ms-excel";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=ClubTransactions-{0:ddMMMyyyy}.csv", show.ShowDate));
            context.Response.Write(bld);
        }
        public void ProcessRequest(HttpContext context)
        {
            var id = Convert.ToInt32(context.Request["showid"]);
            var show = new Shows(id);
            var sw = new StringWriter();
            sw.WriteLine($"Class Sizes for {show.ShowName} ");

            context.Response.ClearContent();
            context.Response.ContentType = "text/csv";
            context.Response.AddHeader("content-disposition",
                $"inline;filename=PairsTeamsTrio-{show.ShowDate:ddMMMyyyy}.csv");

            var hl = new HelperModel();
            hl.ShowId = id;
            hl.SortType = "Name";
            hl.Direction = 0;
            List<Business.MultiDogClasses> MultiDogClasses = TeamPairsManager.GetTeamPairClasses(id);
            var MultiDogEntries =  TeamPairsManager.GetTeamPairsForShow(id, MultiDogClasses);

            sw.WriteLine("Class No, RO, Team Name, Team Captain, Dog 1, Handler 1, Dog 2, Handler 2, Dog 3, Handler 3, Dog 4, Handler 4, Dog 5, Handler 5, Dog 6, Handler 6");
            foreach (var item in MultiDogEntries.OrderBy(x => x.ClassNo).ThenBy(x => x.RO))
            {
                //foreach (var ii in item)
                //{
            //                    var tp = MultiDog.GetPairTeamsDetails(id, ii.HandlerId);

                    var p1 = string.Format("{0},{1},", item.ClassNo, item.RO);
                    var p4 = string.Format("{0},{1},", item.TeamDetails.TeamName.Replace("&#39;","'"), item.TeamDetails.Captain );
            //                    var p2 = string.Format("{0},{1},{2},", ii.DogName, ii.HandlerName, Dogs.GetDogHeight( ii.Height));
                    var p3 = "";
                    foreach (var tpt in item.Members)
                    {
                        p3 += string.Format("{0},{1},", tpt.DogName, tpt.HandlerName);
                    }
                    sw.WriteLine(p1+p4+p3);
                //}

            }

            sw.WriteLine("");

            context.Response.Write(sw);
            context.Response.End();
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);
            var sw = new StringWriter();
            sw.WriteLine(string.Format("Camping List for {0} ", show.ShowName));
            sw.WriteLine("Show Ref,Handler Type,Name,Group Name,Comments,Code,Pitch No,Days Camping,Unit Size");

            var showDetails = ShowDetails.GetShowDetails(ShowID);
            var showCamping = new Camping(ShowID);
            var campingTotals = Camping.getCampingTotals(ShowID);
            var unpaidUsers = Camping.getUnpaidCampingUsers(ShowID);
            var waitingList = WaitingList.getWaitList(ShowID);
            var showCampingList = ShowCampingList.getShowCampingList(ShowID, "Name", 0);

            foreach (var campingList in showCampingList)
            {
                var handlerType = "";
                var handlerTypeName = "";
                if (campingList.HandlerType != 0)
                {
                    handlerType = (campingList.HandlerType == 1 ? "M" : "J");
                    handlerTypeName = (campingList.HandlerType == 1 ? "Member" : "Judge");
                }

                sw.WriteLine(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}",
                        campingList.UserShowid,
                        handlerTypeName,
                        campingList.Name,
                        campingList.PartyName.Replace(",", " "),
                        campingList.Comments.Replace(",", "").Replace("\r", string.Empty).Replace("\n", " "),
                        campingList.CampingCode,
                        campingList.PitchNo,
                        campingList.CampingDaysFormatted.Replace("<b>", "").Replace("</b>",". "),
                        campingList.PitchSize ));
            }

            context.Response.ClearContent();
            context.Response.ContentType = "text/csv";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=Camping-{0:ddMMMyyyy}.csv", show.ShowDate));
            context.Response.Write(sw);
            context.Response.End();
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);
            var sw = new StringWriter();

            var classTotals = ClassTotals.GradedClassTotals(ShowID);
            var exportlist = ShowClasses.GetClassSizes(ShowID);
            sw.WriteLine("Class No,Class Name,Grade 1,Grade 2,Grade 3,Grade 4,Grade 5,Grade 6,Grade 7,Cmb/Grd,Height,Judge,Ring No, Ring Order, Lho, Award By Height");

            foreach (ExportClassSizes ecs in exportlist)
            {
                String tmpname = String.Format("{0} {1} {4} {2} {3}",
                        ShowClasses.expandHeight(ecs.Height),
                        ShowClasses.expandCategory(ecs.Category),
                        ecs.LongName,
                        ecs.ClassName,
                        ShowClasses.getCompressedGrades(ecs.Grades));

                sw.Write(string.Format("{0},{1},", ecs.ClassNo, tmpname));
                for (var s = 1; s <= 7; s++)
                {
                    if (ecs.Grades.Contains(s.ToString()))
                    {
                        sw.Write("TRUE,");
                    }
                    else
                    {
                        sw.Write("FALSE,");
                    }
                }
                sw.Write((ecs.Category == 0 ? "TRUE" : "FALSE") + ",");
                sw.Write(ShowClasses.expandHeight(ecs.Height) + ",");
                sw.WriteLine(string.Format("{0},{1},{2},{3},{4}", ecs.JudgeName,ecs.RingNo, ecs.ClassOrder, ecs.ClassLho, ecs.ClassAbh));
            }

            context.Response.ClearContent();
            context.Response.ContentType = "text/csv";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=ClassInfo-{0:ddMMMyyyy}.csv", show.ShowDate));
            context.Response.Write(sw);
            context.Response.End();
        }
        public override void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);

            DateTime fromDate,
                toDate;
            if (string.IsNullOrEmpty(context.Request["FromDate"]))
            {
                fromDate = DateTime.MinValue;
            }
            else
            {
                fromDate = DateTime.Parse(context.Request["FromDate"].ToString());
            }
            if (string.IsNullOrEmpty(context.Request["ToDate"]))
            {
                toDate = DateTime.MaxValue;
            }
            else
            {
                toDate = DateTime.Parse(context.Request["ToDate"].ToString());
            }
            StringBuilder builder = new StringBuilder();
            List<string> columnNames = new List<string>();
            List<string> rows = new List<string>();

            builder.Append("Cheque Payments\n\r");
            builder.Append(string.Format("{0} Show Date:{1}\n\r", show.ShowName, show.ShowDate.ToString("dd MMM yyyy")));

            var masterList = Transaction.getOfflineList(ShowID, fromDate, toDate);
            builder.Append(PrintReport("Cheque", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("Cheque")).ToList()));
            builder.Append(PrintReport("BACS", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("BACS")).ToList()));
            builder.Append(PrintReport("Voucher", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("Voucher")).ToList()));
            builder.Append(PrintReport("Cash", masterList.Where(x => x.Cheque != 0 && x.Comment.Contains("Cash")).ToList()));

            context.Response.ClearContent();
            context.Response.ContentType = "application/vnd.ms-excel";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=ChequeList-{0:ddMMMyyyy}.csv", show.ShowDate));
            context.Response.Write(builder);
        }
        public override void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            Shows show = new Shows(ShowID);

            DateTime fromDate,
                toDate;
            if (string.IsNullOrEmpty(context.Request["FromDate"]))
            {
                fromDate = DateTime.MinValue;
            }
            else
            {
                fromDate = DateTime.Parse(context.Request["FromDate"].ToString());
            }
            if (string.IsNullOrEmpty(context.Request["ToDate"]))
            {
                toDate = DateTime.MaxValue;
            }
            else
            {
                toDate = DateTime.Parse(context.Request["ToDate"].ToString()).AddDays(1).AddMinutes(-1);
            }

            doc = new Document(PageSize.A4, -10, -50, 100, 50);
            Stream output = new MemoryStream();
            var writer = PdfWriter.GetInstance(doc, output);
            var pageEvent = new Fpp.Core.PdfDocuments.ITextEvents();
            pageEvent.Header = "Online Payments";
            pageEvent.SubHeader = string.Format("{0} {1}", show.ShowName, show.ShowDate.ToString("dd MMM yyyy"));
            writer.PageEvent = pageEvent;
            StyleSheet sheet = new StyleSheet();

            doc.Open();
            ptable = new PdfPTable(headerWidths);
            var masterList = Transaction.getOnlineUserTransactions(ShowID)
                                .Where(x => x.TransactionDate >= fromDate && x.TransactionDate <= toDate).OrderByDescending(x => x.TransactionDate).ToList();

            //PrintReport("", masterList);
            var fixedFees = ShowDiscounts.getDiscountsByType(ShowID, -1, (int)DiscountTypes.TransactionCharge).Sum(x => x.Amount);

            PrintReport("Club Transaction List", masterList
                                    .Where(x => x.TransactionType == TransactionTypes.ShowEntryPayment &&
                                               Regex.IsMatch(x.Comment, @"^\d+$") &&
                                               x.Amount > 0)
                                    .OrderByDescending( x=> x.TransactionDate)
                                    .ToList(), fixedFees, true);
            doc.Close();

            context.Response.ClearContent();
            context.Response.ContentType = "application/pdf";
            context.Response.AddHeader("content-disposition", String.Format("inline;filename=ClubTransactions-{0:ddMMMyyyy}.pdf", show.ShowDate));
            context.Response.BinaryWrite((output as MemoryStream).ToArray());
        }