public IncidentExcelData(Incident baseIncident)
        {
            stranddContext context = new stranddContext();

            // Pull Incident data
            this.TimeStamp = (baseIncident.CreatedAt != null) ? (DateTimeOffset) baseIncident.CreatedAt : DateTimeOffset.MinValue;
            this.IncidentGUID = baseIncident.Id;
            this.JobCode = baseIncident.JobCode;
            this.ArrivalTime = System.Convert.ToString(baseIncident.ProviderArrivalTime);
            this.ConcertoCaseID = baseIncident.ConcertoCaseID;
            this.StaffNotes = baseIncident.StaffNotes;
            this.ServiceFee = System.Convert.ToString(baseIncident.ServiceFee);
            this.CustomerComments = baseIncident.CustomerComments;
            this.CustomerRating = baseIncident.Rating.ToString();
            this.IncidentStatus = baseIncident.StatusCode;

            //pull customer Data
            AccountInfo lookupCustomer = new AccountInfo(baseIncident.ProviderUserID);
            this.CustomerName = lookupCustomer.Name;
            this.CustomerPhone = lookupCustomer.Phone;

            //pull Vehicle data
            VehicleInfo lookupVehicle = new VehicleInfo(baseIncident.VehicleGUID);
            this.VehicleDescription = lookupVehicle.Year + " " + lookupVehicle.Color + " " + lookupVehicle.Make + " " + lookupVehicle.Model;
            this.VehicleRegistration = lookupVehicle.RegistrationNumber;

            //Pull Payment data

            Payment lookupPayment = context.Payments
            .Where(u => u.IncidentGUID == baseIncident.Id)
            .FirstOrDefault();
            this.PaymentStatus = (lookupPayment != null) ? lookupPayment.Status : null;
            this.PaymentAmount = (lookupPayment != null) ? lookupPayment.Amount : 0;
            this.PaymentPlatform = (lookupPayment != null) ? lookupPayment.PaymentPlatform : null;

            //Pull Admin from History Event

            HistoryEvent lookupAdminEvent = context.HistoryLog
              .Where(u => u.ReferenceID == baseIncident.Id)
              .Where(v => v.Code == "INCIDENT_STATUS_ADMIN")
              .Where(x => x.Attribute == "CONFIRMED")
              .FirstOrDefault();

            AccountInfo lookupAdmin;
            if (lookupAdminEvent != null) { lookupAdmin = new AccountInfo(lookupAdminEvent.AdminID); }
            else { lookupAdmin = new AccountInfo(null); }
            this.ConfirmedAdminName = lookupAdmin.Name;
        }
        public IncidentInfo(Incident baseIncident)
        {
            //Create UserInfo Object based upon Passed in ProviderUserID [Call to DB Made in Constructor]
            AccountInfo lookupUser = new AccountInfo(baseIncident.ProviderUserID);

            //Create VehicleInfo Object based upon Passed in VehicleGUID [Call to DB Made in Constructor]
            VehicleInfo lookupVehicle = new VehicleInfo(baseIncident.VehicleGUID);

            stranddContext context = new stranddContext();

            IncidentCosting lookupIncidentCosting = context.IncidentCostings
              .Where(u => u.IncidentGUID == baseIncident.Id)
              .Where(v => v.Type == "CUSTOMER")
              .FirstOrDefault();

            //Payment Information
            List<Payment> lookupPaymentList = context.Payments
                .Where(u => u.IncidentGUID == baseIncident.Id)
                .ToList<Payment>();

            string paymentMethodString = null;

            if (lookupPaymentList.Count != 0)
            {
                if (lookupPaymentList.Count > 1) { paymentMethodString = "Multiple Payments [" + lookupPaymentList.Count.ToString() + "]"; }
                else { paymentMethodString = lookupPaymentList[0].PaymentPlatform; }
            }

            decimal sumPaymentTotal = lookupPaymentList.Sum(a => a.Amount);

            //Confirmed Admin Information
            HistoryEvent lookupAdminEvent = context.HistoryLog
                .Where(u => u.ReferenceID == baseIncident.Id)
                .OrderByDescending(d => d.CreatedAt)
                .Where(v => v.Code == "INCIDENT_STATUS_ADMIN")
                .Where(x => x.Attribute == "CONFIRMED" || x.Attribute == "OPERATOR-ASSIGNED")
                .FirstOrDefault();

            AccountInfo lookupAdmin;

            if (lookupAdminEvent != null) { lookupAdmin = new AccountInfo(lookupAdminEvent.AdminID); }
            else { lookupAdmin = new AccountInfo(null); }

            this.IncidentGUID = baseIncident.Id;
            this.IncidentUserInfo = lookupUser;
            this.IncidentVehicleInfo = lookupVehicle;
            this.ConfirmedAdminAccount = lookupAdmin;
            this.JobCode = baseIncident.JobCode;
            this.LocationObj = (baseIncident.LocationObj != null) ? JsonConvert.DeserializeObject<IncidentLocation>(baseIncident.LocationObj) : null;
            this.ConcertoCaseID = baseIncident.ConcertoCaseID;
            this.StatusCode = baseIncident.StatusCode;
            this.Rating = baseIncident.Rating;
            this.ServiceFee = baseIncident.ServiceFee;
            this.CoordinateX = baseIncident.CoordinateX;
            this.CoordinateY = baseIncident.CoordinateY;
            this.ProviderArrivalTime = baseIncident.ProviderArrivalTime;
            this.CreatedAt = baseIncident.CreatedAt;
            this.UpdatedAt = baseIncident.UpdatedAt;
            this.CustomerComments = baseIncident.CustomerComments;
            this.StaffNotes = baseIncident.StaffNotes;
            this.PaymentAmount = sumPaymentTotal; //(lookupPayment != null) ? lookupPayment.Amount : 0;
            this.PaymentMethod = paymentMethodString; //(lookupPayment != null) ? lookupPayment.PaymentPlatform : null;
            this.AdditionalDetails = baseIncident.AdditionalDetails;

            //retrive data IncidentCostings
            this.ServiceType = (lookupIncidentCosting != null) ? lookupIncidentCosting.ServiceType   : null;
            this.ServiceKilometers = (lookupIncidentCosting != null) ? lookupIncidentCosting.ServiceKilometers : 0;
            this.CalculatedBaseServiceCost = (lookupIncidentCosting != null) ? lookupIncidentCosting.CalculatedBaseServiceCost : 0;
            this.ParkingCosts = (lookupIncidentCosting != null) ? lookupIncidentCosting.ParkingCosts : 0;
            this.TollCosts = (lookupIncidentCosting != null) ? lookupIncidentCosting.TollCosts : 0;
            this.OtherCosts = (lookupIncidentCosting != null) ? lookupIncidentCosting.OtherCosts : 0;
            this.OffsetDiscount = (lookupIncidentCosting != null) ? lookupIncidentCosting.OffsetDiscount : 0;
            this.CalculatedSubtotal = (lookupIncidentCosting != null) ? lookupIncidentCosting.CalculatedSubtotal : 0;
            this.TaxZoneRate = (lookupIncidentCosting != null) ? lookupIncidentCosting.TaxZoneRate : 0;
            this.CalculatedTaxes = (lookupIncidentCosting != null) ? lookupIncidentCosting.CalculatedTaxes : 0;
            this.CalculatedTotalCost = (lookupIncidentCosting != null) ? lookupIncidentCosting.CalculatedTotalCost : 0;
        }