public bool BookAppointment(BookAppointment ba)
        {
            bool flag = false;

            try
            {
                EF_Database ctx = new EF_Database();
                Appointment a   = new Appointment();
                a.BOOKING_DATE = ba.Date;
                var res = ctx.CasePools.Where(i => i.AccepterId == ba.AccepterId).Select(i => i).FirstOrDefault();
                a.CaseId = res.CASE_ID;
                a.SLOT   = ba.Slot;
                a.STATUS = "Initiated";
                var re1 = ctx.Accepters.Where(i => i.ACEEPTER_ID == ba.AccepterId).Select(i => i).FirstOrDefault();
                res.STATUS = re1.STATUS = "Booked";
                ctx.Appointments.Add(a);
                ctx.SaveChanges();
                flag = true;
            }
            catch (Exception e)
            {
                throw new Exception("Error");
            }
            return(flag);
        }
        public bool EnterAccepterData(RegisterAccepter RA)
        {
            //Store Accepter Data To Database
            bool flag = false;

            try
            {
                EF_Database ctx = new EF_Database();
                Accepter    a   = new Accepter();
                a.NAME           = RA.AccepterName;
                a.REQUIREMENT    = RA.RequirementOrgon;
                a.AGE            = RA.AccepterAge;
                a.BLOOD_GROUP    = RA.BloodGroup;
                a.CONTACT_NUMBER = RA.Contact;
                a.DATE           = DateTime.Now;
                a.GENDER         = RA.DonorGender;
                a.LOCATION       = RA.Location;
                a.STATUS         = "Requested";

                Userinfo UI = new Userinfo();
                UI.USER_NAME = RA.Username;
                UI.PASSWORD  = RA.CPwd;
                UI.RoleId    = 4;
                a.USER_ID    = UI;
                ctx.Accepters.Add(a);
                ctx.SaveChanges();
                flag = true;
            }
            catch (Exception e)
            {
                throw new Exception("Error during Registering new Accepter");
            }
            return(flag);
        }
        public bool UpdateVerificationStatus(VerifyDonor VerDon)
        {
            bool flag = false;

            try
            {
                EF_Database ctx = new EF_Database();
                CasePool    c   = new CasePool();
                var         res = ctx.CasePools.Where(i => i.CASE_ID == VerDon.CaseId).Select(i => i).FirstOrDefault();
                var         re1 = ctx.Nominees.Where(i => i.NOMINEE_ID == res.DonorId).Select(i => i).FirstOrDefault();
                re1.STATUS = VerDon.Status;
                res.STATUS = VerDon.Status;
                if (res.STATUS == "Verified")
                {
                    res.ORGANS = VerDon.Orgon;
                }

                ctx.SaveChanges();
                flag = true;
            }
            catch (Exception e)
            {
                throw new Exception("Error");
            }
            return(flag);
        }
        public bool AssignAccepter(int cid)
        {
            bool flag = false;

            try
            {
                EF_Database ctx = new EF_Database();
                var         res = ctx.CasePools.Where(i => i.CASE_ID == cid).Select(i => i).FirstOrDefault();
                var         re1 = ctx.Accepters.OrderByDescending(i => i.DATE).Where(i => i.STATUS != "Assigned").Select(i => i).FirstOrDefault();
                var         re2 = ctx.Nominees.Where(i => i.NOMINEE_ID == res.DonorId).Select(i => i).FirstOrDefault();
                if (res.AccepterId != 0)
                {
                    res.AccepterId = re1.ACEEPTER_ID;
                    re2.STATUS     = "Accepter Assigned";
                    res.STATUS     = re1.STATUS = "Assigned";
                }
                //var re2=ctx.Accepters.Where(i=>i.ACEEPTER_ID==res.AccepterId)
                ctx.SaveChanges();
                flag = true;
            }
            catch (Exception e)
            {
                throw new Exception("Error");
            }
            return(flag);
        }
        public bool EnterNomineeData(RegisterNominee RN)
        {
            //Store Nominee data into database
            bool flag = false;

            try
            {
                EF_Database ctx = new EF_Database();
                Nominee     N   = new Nominee();
                N.NOMINEE_NAME   = RN.NomineeName;
                N.DONOR_NAME     = RN.DonorName;
                N.DONOR_AGE      = RN.DonorAge;
                N.DATE           = DateTime.Now;
                N.DONOR_GENDER   = RN.DonorGender;
                N.LOCATION       = RN.Location;
                N.BLOOD_GROUP    = RN.BloodGroup;
                N.CONTACT_NUMBER = RN.Contact;
                N.STATUS         = "Submited";

                Userinfo UI = new Userinfo();
                UI.USER_NAME = RN.Username;
                UI.PASSWORD  = RN.CPwd;
                UI.RoleId    = 3;
                N.USER_ID    = UI;
                ctx.Nominees.Add(N);

                CasePool c = new CasePool();
                c.DonorId = N.NOMINEE_ID;
                c.STATUS  = "Initiated";


                ctx.CasePools.Add(c);
                //ctx.Userinfos.Add(UI);
                ctx.SaveChanges();
                flag = true;
            }
            catch (Exception e)
            {
                // Error.Message = e.Message;
                throw new Exception("Error during Registering new Nominee");
            }

            return(flag);
        }
        public bool AssignDoctor(AssignDoctor AsDoc)
        {
            bool flag = false;

            try
            {
                EF_Database ctx = new EF_Database();
                CasePool    c   = new CasePool();
                var         res = ctx.CasePools.Where(i => i.CASE_ID == AsDoc.cid).Select(i => i).FirstOrDefault();
                res.DoctorId = AsDoc.DoctorId;
                res.STATUS   = "Assigned";
                var obj = ctx.Nominees.Where(i => i.NOMINEE_ID == res.DonorId).Select(i => i).FirstOrDefault();
                obj.STATUS = "Assigned";
                ctx.SaveChanges();
                flag = true;
            }
            catch (Exception e)
            {
                throw new Exception("Error");
            }
            return(flag);
        }
        public bool UpdateAppiontmentStatus(VerifyAppointment VA)
        {
            bool flag = false;

            try
            {
                EF_Database ctx = new EF_Database();
                var         res = ctx.Appointments.Where(m => m.CaseId == VA.CaseId).Select(i => i).FirstOrDefault();

                var res2 = ctx.CasePools.Where(m => m.CASE_ID == VA.CaseId).Select(m => m).FirstOrDefault();
                var res1 = ctx.Accepters.Where(m => m.ACEEPTER_ID == res2.AccepterId).Select(i => i).FirstOrDefault();

                res.STATUS  = VA.Status;
                res1.STATUS = VA.Status;
                ctx.SaveChanges();
                flag = true;
            }
            catch (Exception e)
            {
                throw new Exception("Error");
            }
            return(flag);
        }