示例#1
0
 public ActionResult Account(int id)
 {
     Users user = new Users();
     using (var db = new RazomContext())
     {
         user = db.Users.Find(id);
         if (user == null)
         {
             return View("Error", new HandleErrorInfo(new Exception("Користувача не знайдено!"),"Account","Account"));
         }
         NetworkAccounts fs = db.NetworkAccounts.Where(i => i.NetworkID == db.Network.FirstOrDefault(j => j.Name == "foursquare").NetworkID).FirstOrDefault(i => i.UserID == user.UserID);
         NetworkAccounts tw = db.NetworkAccounts.Where(i => i.NetworkID == db.Network.FirstOrDefault(j => j.Name == "twitter").NetworkID).FirstOrDefault(i => i.UserID == user.UserID);
         NetworkAccounts vk = db.NetworkAccounts.Where(i => i.NetworkID == db.Network.FirstOrDefault(j => j.Name == "vk").NetworkID).FirstOrDefault(i => i.UserID == user.UserID);
         AccountModel a = new AccountModel()
         {
             ID = user.UserID,
             Login = user.Login,
             FirstName = user.FirstName ?? "",
             SecondName = user.SecondName ?? "",
             EMail = user.Email ?? "",
             Phone = user.Phone ?? "",
             FoursquareAccount = fs != null ? fs.ProfileURL : "",
             TwitterAccount = tw != null ? tw.ProfileURL : "",
             VKAccount = vk != null ? vk.ProfileURL : "",
             Associations = db.UsersData.Where(d => d.UserID == user.UserID && d.DataTypeID == db.DataType.Where(dt => dt.Type == "AboutMe").FirstOrDefault().DataTypeID).Select(t => t.Data).ToList()
         };
         return View(a);
     }
 }
示例#2
0
 private List<AccountModel> getSearchList(string token)
 {
     List<KeyValuePair<int ,List<string>>> ids = PeopleSearchEngine.PeopleSearchEngine.GetSearchResultIndexes(token);
     List<AccountModel> result = new List<AccountModel>();
     using (var db = new RazomContext())
     {
         AccountModel a;
         foreach (var item in ids)
         {
             Users p = db.Users.Find(item.Key);
             int photo = db.Users.Where(ph => ph.Avatar != null).SingleOrDefault(ph => ph.UserID == p.UserID) != null ? db.Users.Where(ph => ph.Avatar != null).SingleOrDefault(ph => ph.UserID == p.UserID).UserID : 0;
             NetworkAccounts fs = db.NetworkAccounts.Where(ac => ac.NetworkID == 1).FirstOrDefault(ac => ac.UserID == p.UserID);
             NetworkAccounts tw = db.NetworkAccounts.Where(ac => ac.NetworkID == 2).FirstOrDefault(ac => ac.UserID == p.UserID);
             NetworkAccounts vk = db.NetworkAccounts.Where(ac => ac.NetworkID == 3).FirstOrDefault(ac => ac.UserID == p.UserID);
             a = new AccountModel
             {
                 ID = p.UserID,
                 FirstName = p.FirstName,
                 SecondName = p.SecondName,
                 EMail = p.Email,
                 Login = p.Login,
                 Phone = p.Phone,
                 FoursquareAccount = fs != null ? fs.ProfileURL : "",
                 TwitterAccount = tw != null ? tw.ProfileURL : "",
                 VKAccount = vk != null ? vk.ProfileURL : "",
                 Associations = item.Value
             };
             result.Add(a);
         }
     }
     return result;
 }
示例#3
0
 public ActionResult MyAccount()
 {
     Users user = new Users();
     using (var db = new RazomContext())
     {
         HttpCookie cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
         FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
         string username = ticket.Name;
         user = db.Users.SingleOrDefault(u => u.Login == username);
         if (user == null)
         {
             return RedirectToAction("LogOff");
         }
         NetworkAccounts fs = db.NetworkAccounts.Where(i => i.NetworkID == db.Network.FirstOrDefault(j => j.Name == "foursquare").NetworkID).FirstOrDefault(i => i.UserID == user.UserID);
         NetworkAccounts tw = db.NetworkAccounts.Where(i => i.NetworkID == db.Network.FirstOrDefault(j => j.Name == "twitter").NetworkID).FirstOrDefault(i => i.UserID == user.UserID);
         NetworkAccounts vk = db.NetworkAccounts.Where(i => i.NetworkID == db.Network.FirstOrDefault(j => j.Name == "vk").NetworkID).FirstOrDefault(i => i.UserID == user.UserID);
         AccountModel a = new AccountModel()
         {
          ID = user.UserID,
          Login = user.Login,
          FirstName = user.FirstName ?? "",
          SecondName = user.SecondName ?? "",
          EMail = user.Email ?? "",
          Phone = user.Phone ?? "",
          FoursquareAccount = fs != null? fs.ProfileURL: "",
          TwitterAccount = tw != null? tw.ProfileURL: "",
          VKAccount = vk != null? vk.ProfileURL: "",
          Associations = db.UsersData.Where(d => d.UserID == user.UserID && d.DataTypeID == db.DataType.Where(dt => dt.Type == "AboutMe").FirstOrDefault().DataTypeID).Select(t => t.Data).ToList()
         };
         return View(a);
     }
 }