Пример #1
0
 public ActionResult Select(SearchUser model)
 {
     UserContext UserContext = new UserContext();
     int UserTypeId = (from usertype in UserContext.UserTypes
                   where usertype.Name == "Dokter Umum"
                   select usertype.Id).FirstOrDefault();
     model.UserTypeId = UserTypeId;
     model = SearchUser(model);
     return View(model);
 }
Пример #2
0
 public ActionResult Select(int PatientID)
 {
     SearchUser model = new SearchUser();
     model.PatientID = PatientID;
     return View(model);
 }
Пример #3
0
 public ActionResult Index()
 {
     SearchUser model = new SearchUser();
     return View(model);
 }
Пример #4
0
        public ActionResult Index(SearchUser model)
        {
            model = SearchUser(model);

            return View(model);
        }
Пример #5
0
        private SearchUser SearchUser(SearchUser model)
        {
            List<User> Users = new List<User>();
            UserContext UserContext = new UserContext();
            if (model.Email != null)
            {
                IEnumerable<User> us = from user in UserContext.Users
                                       where user.Email == model.Email
                                       && (user.UsertypeId == model.UserTypeId || model.UserTypeId == null)
                                       select user;

                model.Users = us.ToList();
            }
            else
            {
                IEnumerable<User> us = from user in UserContext.Users
                                       where (user.FirstName == model.FirstName || model.FirstName == null)
                                        && (user.LastName == model.LastName || model.LastName == null)
                                        && (user.DOB == Convert.ToDateTime(model.DOB) || model.DOB == null)
                                        && (user.UsertypeId == model.UserTypeId || model.UserTypeId == null)
                                       select user;

                model.Users = us.ToList();
            }

            

            //var client = new Connection().ConnectAmazonDynamoDB(new AmazonDBHelper().AmazonDBConnectionString());
            //List<int> userids = new List<int>();
            //List<UserProfile> UserProfileList = new List<UserProfile>();

            //if (model.Email != null)
            //{
            //    var result = new CRUD().getItem(new AmazonDBHelper().AmazonDBConnectionString(), "login", model.Email, ":v_email", "email");
            //    //Get all matching user Ids
            //    foreach (Dictionary<string, AttributeValue> item in result)
            //    {
            //        foreach (KeyValuePair<string, AttributeValue> kvp in item)
            //        {
            //            string attributeName = kvp.Key;
            //            AttributeValue value = kvp.Value;
            //            if (attributeName == "userid")
            //            {
            //                userids.Add(Convert.ToInt32(value.S));
            //            }
            //        }
            //    }

            //    if (userids != null && userids.Count() > 0)
            //    {


            //        foreach (var u in userids)
            //        {
            //            var PatientResult = new CRUD().getItem(new AmazonDBHelper().AmazonDBConnectionString(), "user", u.ToString(), ":v_id", "id");
            //            foreach (Dictionary<string, AttributeValue> itemP in PatientResult)
            //            {
            //                UserProfile UserProfile = new UserProfile();
            //                UserProfile.Email = model.Email;
            //                foreach (KeyValuePair<string, AttributeValue> kvpP in itemP)
            //                {
            //                    string attributeName = kvpP.Key;
            //                    AttributeValue value = kvpP.Value;
            //                    if (attributeName == "id")
            //                    {
            //                        UserProfile.Id = Convert.ToInt32(value.S);
            //                    }
            //                    if (attributeName == "firstname")
            //                    {
            //                        UserProfile.FirstName = value.S;
            //                    }
            //                    if (attributeName == "lastname")
            //                    {
            //                        UserProfile.LastName = value.S;
            //                    }
            //                    if (attributeName == "dob")
            //                    {
            //                        UserProfile.DOB = value.S;
            //                    }
            //                    if (attributeName == "usertypeid")
            //                    {
            //                        UserProfile.UserTypeID = Convert.ToInt32(value.N);
            //                    }
            //                }
            //                UserProfileList.Add(UserProfile);
            //            }
            //        }
            //    }
            //    model.Users = UserProfileList;
            //}
            //else
            //{
            //    List<string> inputparam = new List<string>();
            //    List<string> expressionText = new List<string>();
            //    List<string> columnName = new List<string>();
            //    if (model.FirstName != null)
            //    {
            //        inputparam.Add(model.FirstName);
            //        expressionText.Add(":v_firstname");
            //        columnName.Add("firstname");
            //    }
            //    if (model.LastName != null)
            //    {
            //        inputparam.Add(model.LastName);
            //        expressionText.Add(":v_lastname");
            //        columnName.Add("lastname");
            //    }
            //    if (model.DOB != null)
            //    {
            //        inputparam.Add(model.DOB);
            //        expressionText.Add(":v_dob");
            //        columnName.Add("dob");
            //    }

            //    var result = new CRUD().getItemWithFilters(new AmazonDBHelper().AmazonDBConnectionString(), "user", inputparam, expressionText, columnName);

            //    //Get all matching user Ids
            //    foreach (Dictionary<string, AttributeValue> itemP in result)
            //    {
            //        UserProfile UserProfile = new UserProfile();
            //        UserProfile.Email = model.Email;
            //        foreach (KeyValuePair<string, AttributeValue> kvpP in itemP)
            //        {
            //            string attributeName = kvpP.Key;
            //            AttributeValue value = kvpP.Value;
            //            if (attributeName == "id")
            //            {
            //                UserProfile.Id = Convert.ToInt32(value.S);
            //                userids.Add(Convert.ToInt32(value.S));
            //            }
            //            if (attributeName == "firstname")
            //            {
            //                UserProfile.FirstName = value.S;
            //            }
            //            if (attributeName == "lastname")
            //            {
            //                UserProfile.LastName = value.S;
            //            }
            //            if (attributeName == "dob")
            //            {
            //                UserProfile.DOB = value.S;
            //            }
            //            if (attributeName == "usertypeid")
            //            {
            //                UserProfile.UserTypeID = Convert.ToInt32(value.N);
            //            }
            //        }
            //        UserProfileList.Add(UserProfile);
            //    }

            //    foreach (var u in UserProfileList)
            //    {
            //        var EmailResult = new CRUD().getItem(new AmazonDBHelper().AmazonDBConnectionString(), "login", u.Id.ToString(), ":v_userid", "userid");
            //        //Get all matching Emails
            //        foreach (Dictionary<string, AttributeValue> item in EmailResult)
            //        {
            //            foreach (KeyValuePair<string, AttributeValue> kvp in item)
            //            {
            //                string attributeName = kvp.Key;
            //                AttributeValue value = kvp.Value;
            //                if (attributeName == "email")
            //                {
            //                    u.Email = value.S;
            //                }
            //            }
            //        }
            //    }
            //    model.Users = UserProfileList;
            //}
            return model;
        }