public ActionResult CreatePractice(vwPractice objprac)
        {
            Practice pra = new Practice();
            pra.PracticeID = objprac.PracticeID;
            pra.PracticeName = objprac.PracticeName;
            pra.NPI = objprac.NPI;
            pra.PhoneNumber = objprac.PhoneNumber;
            pra.State = objprac.State;
            pra.TAXID = objprac.TAXID;
            pra.ZipeCode = objprac.ZipeCode;
            pra.Address1 = objprac.Address1;
            pra.Address2 = objprac.Address2;
            pra.City = objprac.City;
            pra.Description = objprac.Description;
            pra.StatusID = objprac.StatusID;
            pra.Email = objprac.Email;
            pra.StatusID = 1;
            objDbContext.Practices.Add(pra);
            objDbContext.SaveChanges();

            int lastPracticeId = objDbContext.Practices.Max(item => item.PracticeID);

            PracticeUser temp = new PracticeUser();
            //temp = objDbContext.PracticeUsers.Find(objprac.UserID);
            temp.UserName = objprac.UserName;
            temp.Password = objprac.Password;
            temp.PracticeUserType = "Admin";
            temp.Email = objprac.Email;
            temp.PhoneNumber = objprac.PhoneNumber;
            temp.PracticeID = lastPracticeId;
            temp.StatusID = 1;
            objDbContext.PracticeUsers.Add(temp);
            objDbContext.SaveChanges();
            return Json(new { data = "Success" });
        }
 public ActionResult DeletePractice(vwPractice objprac)
 {
     var practiceUsers = (from p in objDbContext.PracticeUsers
                          where p.PracticeID == objprac.PracticeID
                          select p).ToList();
     foreach (var n in practiceUsers)
     {
         n.StatusID = 2;
     }
     Practice pra = (from p in objDbContext.Practices
                     where p.PracticeID == objprac.PracticeID
                     select p).FirstOrDefault();
     pra.StatusID = 2;
     objDbContext.SaveChanges();
     return Json(new { data = "Success" });
 }
        public ActionResult GetPracticesData(vwPractice objpractice)
        {
            var practiceslist = (from p in objDbContext.vwPractices
                                 where p.PracticeID == objpractice.PracticeID
                                 select p).ToList();

            return Json(practiceslist);
        }
        public ActionResult EditPractice(vwPractice objprac)
        {
            Practice pra = (from p in objDbContext.Practices
                            where p.PracticeID == objprac.PracticeID
                            select p).FirstOrDefault();
            pra.PracticeID = objprac.PracticeID;
            pra.PracticeName = objprac.PracticeName;
            pra.NPI = objprac.NPI;
            pra.PhoneNumber = objprac.PhoneNumber;
            pra.State = objprac.State;
            pra.TAXID = objprac.TAXID;
            pra.ZipeCode = objprac.ZipeCode;
            pra.Address1 = objprac.Address1;
            pra.Address2 = objprac.Address2;
            pra.City = objprac.City;
            pra.Description = objprac.Description;
            pra.StatusID = 1;
            pra.Email = objprac.Email;
            PracticeUser temp = new PracticeUser();
            temp = objDbContext.PracticeUsers.Find(objprac.UserID);
            temp.UserName = objprac.UserName;
            temp.Password = objprac.Password;
            temp.PracticeUserType = "Admin";

            //if (ModelState.IsValid)
            //{
            //    objDbContext.Entry(pra).State = EntityState.Modified;
            //    objDbContext.Entry(temp).State = EntityState.Modified;
            //    objDbContext.SaveChanges();
            //    return RedirectToAction("Superadminsection");
            //}

            objDbContext.SaveChanges();
            return Json(new { data = "Success" });
        }