// 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 JsonResult GetDetails(int? id)
        {
            int userId = (id.HasValue ? id.Value : CurrentUser.ID);

            try
            {
                TrackUser("GetDetails", "");
            }
            catch
            {
            }

            UserDogDetails userDetails = new UserDogDetails();
            Dogs dog = new Dogs();

            userDetails.DogDetails = Dogs.GetAllDogsForHandler(userId, DateTime.Now);
            userDetails.UserDetails = new User(userId);
            userDetails.ShowTransList = ShowTransaction.getTransactionForUser(userId);
            userDetails.AltHandlers = AltHandler.GetAllAltHandlers(userId);

            return Json(new
            {
                Status = 0,
                UserDetails = userDetails
            });
        }
        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;
        }