public List <PakagesClass> GetAllPakageServicesById(int id)
        {
            List <PakagesClass> li = new List <PakagesClass>();

            var Ps    = obj.PakageServices.Where(x => x.PakagesId.Equals(id)).ToList();
            var count = Ps.Count();

            foreach (var details in Ps)
            {
                PakagesClass temp = new PakagesClass();
                temp.ServiceId = details.ServicesId;

                temp.Count = count;

                li.Add(temp);
            }
            return(li);
        }
        public int PostPakage(PakagesClass PC)
        {
            int check = 0;

            try
            {
                Pakage pakage = new Pakage();
                pakage.Name             = PC.Name;
                pakage.PakageType       = PC.PakageType;
                pakage.CostPerMonth     = PC.CostPerMonth;
                pakage.ServicesIncluded = PC.ServicesIncluded;
                pakage.Status           = 1;
                pakage.AddDate          = DateTime.Now.ToShortDateString();
                obj.Pakages.InsertOnSubmit(pakage);
                obj.SubmitChanges();
                check = pakage.Id;
            }
            catch (Exception e) { check = 0; }
            return(check);
        }
        public List <PakagesClass> GetAllPakages(int id)
        {
            int ShowRecords = 20;
            int skip        = id * ShowRecords;
            var DesiMasala  = "";

            var AllRecords = obj.Pakages.Count();
            int max        = (skip + ShowRecords);

            if (max > AllRecords)
            {
                max = AllRecords;
            }
            DesiMasala = (skip + 1).ToString() + "-" + max.ToString() + "/" + AllRecords.ToString();

            List <PakagesClass> li = new List <PakagesClass>();

            var AllPakages = obj.Pakages.Skip(skip).Take(ShowRecords).Where(x => x.Status != 0).ToList();
            var count      = AllPakages.Count();

            foreach (var details in AllPakages)
            {
                PakagesClass temp = new PakagesClass();
                temp.Id         = details.Id;
                temp.Name       = details.Name;
                temp.PakageType = details.PakageType;
                try
                {
                    temp.CostPerMonth = details.CostPerMonth.Value;
                }
                catch (Exception e) { temp.CostPerMonth = 0; }
                temp.ServicesIncluded = details.ServicesIncluded;
                temp.Count            = count;
                temp.NumberOfShowing  = DesiMasala;
                li.Add(temp);
            }
            return(li);
        }
        public int UpdatePakage(PakagesClass PC)
        {
            int check = 0;

            try
            {
                Pakage pakage = obj.Pakages.First(x => x.Id.Equals(PC.Id));
                pakage.Name             = PC.Name;
                pakage.PakageType       = PC.PakageType;
                pakage.CostPerMonth     = PC.CostPerMonth;
                pakage.ServicesIncluded = PC.ServicesIncluded;
                pakage.Status           = 1;
                pakage.AddDate          = DateTime.Now.ToShortDateString();

                obj.SubmitChanges();
                check = pakage.Id;
                List <PakageService> ps = obj.PakageServices.Where(x => x.PakagesId.Equals(pakage.Id)).ToList();
                obj.PakageServices.DeleteAllOnSubmit(ps);
                obj.SubmitChanges();
            }
            catch (Exception e) { check = 0; }
            return(check);
        }
        public List <PakagesClass> GetAllPakagesById(int id)
        {
            List <PakagesClass> li = new List <PakagesClass>();

            var AllPakages = obj.Pakages.Where(x => x.Status != 0 && x.Id.Equals(id)).ToList();
            var count      = AllPakages.Count();

            foreach (var details in AllPakages)
            {
                PakagesClass temp = new PakagesClass();
                temp.Id         = details.Id;
                temp.Name       = details.Name;
                temp.PakageType = details.PakageType;
                try
                {
                    temp.CostPerMonth = details.CostPerMonth.Value;
                }
                catch (Exception e) { temp.CostPerMonth = 0; }
                temp.ServicesIncluded = details.ServicesIncluded;
                temp.Count            = count;
                li.Add(temp);
            }
            return(li);
        }