// GET:
        public ActionResult Index(string searchString, string Filter_Value, int?Page_No)
        {
            List <ViewUserDetail> model = new List <ViewUserDetail>();

            if (searchString != null)
            {
                Page_No = 1;
            }
            else
            {
                searchString = Filter_Value;
            }

            ViewBag.FilterValue = searchString;

            var userInfo = db.UserProfileInfo.ToList();

            var userInfos = from u in db.UserProfileInfo
                            select u;

            if (!String.IsNullOrEmpty(searchString))
            {
                userInfos = userInfos.Where(s => s.FirstName.Contains(searchString));
            }


            foreach (var item in userInfo)
            {
                var viewmodelx = new ViewUserDetail();
                viewmodelx.userInfo = item;
                var userAddress = db.UserAddress.Find(item.addressId);
                viewmodelx.userAddress = userAddress;
                //var userGlycemi = db.UserGlycemics.Find(item.userGlycemicId);
                //viewmodelx.userGlycemic = userGlycemi;
                //var userMedicine = db.Medicines.Find(item.userMedicineId);
                model.Add(viewmodelx);
            }

            int Size_Of_Page = 2;
            int No_Of_Page   = (Page_No ?? 1);

            //var view = from a in db.UserProfileInfo
            //           join b in db.UserGlycemics on a.id equals b.UserId
            //           where a.id.Equals(b.UserId)
            //           select new ViewUserDetail { userInfo = a, userGlycemic = b };
            return(View(model.ToPagedList(No_Of_Page, Size_Of_Page)));
        }
        public IHttpActionResult GetUsers(string id)
        {
            string         sqlquery       = @"SELECT          U.Id, U.Email, U.Username, U.Password, U.Name, U.PhoneNumber, U.EditTime, R.RoleName, S.StatusName
                                FROM            dbo.Users AS U INNER JOIN
                                                dbo.Roles AS R ON R.Id = U.Roles_Id INNER JOIN
                                                dbo.Status AS S ON S.Id = U.Status_Id
                                WHERE           Id = {0}";
            ViewUserDetail viewUserDetail = db.Database.SqlQuery <ViewUserDetail>(sqlquery, id).First();

            //ViewUserDetail viewUserDetail = db.ViewUserDetail.FirstOrDefault(x => x.Id == id);

            if (viewUserDetail == null)
            {
                return(NotFound());
            }

            return(Ok(viewUserDetail));
        }