private string[] UserBDCheked(int User_id) { using (ContextUserInfo db = new ContextUserInfo()) { var pp = db.UserInfos .Select(p => new { user_id = p.User_Id, first_name = p.first_name, last_name = p.last_name, sex = p.sex, bdate = p.bdate, city = p.city_Id, country = p.country_Id, photo_200 = p.photo_200 }) .Where(p => p.user_id == User_id); //IQueryable tt = db.UserInfos.Where(p => p.User_Id == User_id); if (pp.Count() != 0) { string[] query = new string[8]; query[0] = Convert.ToString(pp.First().user_id); query[1] = pp.First().first_name; query[2] = pp.First().last_name; query[3] = Convert.ToString(pp.First().sex); query[4] = Convert.ToString(pp.First().bdate); query[5] = Convert.ToString(pp.First().city); query[6] = Convert.ToString(pp.First().country); query[7] = pp.First().photo_200; return(query); } else { string[] query = new string[] { "null" }; return(query); } } }
private void AddBDParametrUserInfo(string[] ParametrUserInfo) { using (ContextUserInfo db = new ContextUserInfo()) { int User_id = Convert.ToInt32(ParametrUserInfo[0]); string[] tt = UserBDCheked(User_id); if (tt[0] == "null" || tt[1] == null || tt[2] == null || tt[3] == null) { UserInfo UI = new UserInfo { User_Id = Convert.ToInt32(ParametrUserInfo[0]), first_name = ParametrUserInfo[1], last_name = ParametrUserInfo[2], sex = Convert.ToInt32(ParametrUserInfo[3]), bdate = ParametrUserInfo[4], city_Id = Convert.ToInt32(ParametrUserInfo[5]), country_Id = Convert.ToInt32(ParametrUserInfo[6]), photo_200 = ParametrUserInfo[7] }; db.UserInfos.Add(UI); db.SaveChanges(); } else { } } }
private void AddBdUserId(string[] ProfileInformation) { if (UserAndGroupAddBd(Convert.ToInt32(ProfileInformation[0]), Convert.ToInt32(ProfileInformation[5]))) { using (ContextUserInfo db = new ContextUserInfo()) { string[] tt = UserBDCheked(Convert.ToInt32(ProfileInformation[0])); if (tt[0] == "null") { UserInfo UI = new UserInfo { User_Id = Convert.ToInt32(ProfileInformation[0]), first_name = ProfileInformation[1], last_name = ProfileInformation[2], sex = Convert.ToInt32(ProfileInformation[3]), }; db.UserInfos.Add(UI); db.SaveChanges(); } } } }