public async Task <FriendModel> UpdateAsync(Guid id, FriendModel model) { try { var friend = new Friend { Id = id }; _db.Friends.Attach(friend); _db.Entry(friend).CurrentValues.SetValues(model); await _db.SaveChangesAsync(); return(model); } catch (DbUpdateConcurrencyException) { if (!FriendExists(model.Id)) { return(null); } throw; } }
public async Task <IHttpActionResult> PutFriendModel(int id, FriendModel friendModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != friendModel.Id) { return(BadRequest()); } db.Entry(friendModel).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FriendModelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ConversationView(FriendModel user) { InitializeComponent(); vm = new ConversationViewModel(Navigation, user); BindingContext = vm; }
public List <FriendModel> SearchFriend(long UserId, string query) { var ListFriend = new List <FriendModel>(); var result = (from c in context.Users where c.NickName.Contains(query) || c.SubName.Contains(query) orderby c.NickName descending select new { c }).Take(200).ToList(); foreach (var item in result) { var Friend = new FriendModel(); Friend.Avatar = item.c.Avatar; Friend.NickName = item.c.NickName; Friend.Id = item.c.ID; Friend.Type = TypeRequestFriend.USER; Friend.CreatedTime = item.c.CreatedTime; var respone = AmazonS3Uploader.GetUrl(item.c.Avatar, 0); if (!string.IsNullOrEmpty(respone)) { Friend.Avatar = respone; } ListFriend.Add(Friend); } return(ListFriend); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (model == null) { model = (FriendModel)RowData; } if (model != null) { DCWebImageMaanager.shard.downloadImageAsync(model.avatar, (imagePath, b) => { Image image = imagePath; if (image != null) { avatarPictureBox.BeginInvoke(() => { avatarPictureBox.BackgroundImage = image; }); } }); this.BeginInvoke(() => { nameLabel.Text = string.IsNullOrWhiteSpace(model.nickName) ? model.friend_self_name : model.nickName; idLabel.Text = "畅聊号:" + model.id_Card; }); } }
void Start() { FriendModel model = FitBit.getInstance().getUserModel(); PlayerManager.mainPlayer = new PlayerStats(model); DatabaseController.updatePlayer(PlayerManager.mainPlayer); }
public void IsWechatFriendExistsTestMethod_DA_True() { Thread.Sleep(new TimeSpan(0, 0, 1)); var openid = DateTime.Now.ToString("yyyyMMddHHmmss"); var friend = new FriendModel { Innerid = Guid.NewGuid().ToString(), Accountid = APPID, Nickname = "Nickname", Photo = "Photo", OPENID = openid, Country = "Country", Province = "province", City = "city", Sex = 1, Isdel = 0, SubscribeTime = DateTime.Now.Ticks, Subscribe = 1, Createdtime = DateTime.Now }; var creaeWechatFriendresult = da.CreaeWechatFriend(friend); var isWechatFriendExistsresult = da.IsWechatFriendExists(APPID, openid); Assert.IsTrue(creaeWechatFriendresult); Assert.IsTrue(isWechatFriendExistsresult); }
public async Task <ActionResult> AddFriend([FromBody] FriendModel friendModel) { string name = GetNameFromClaim(); var friend = _userManager.Users.FirstOrDefault(c => c.UserName == friendModel.Username); var user = _userManager.Users.FirstOrDefault(c => c.UserName == name); //Does friendship already exist? var friendshipTest = context.Friendship.Where(c => c.ApplicationUserId == user.Id && c.FriendUsername == friendModel.Username); if (friendshipTest.Count <Friendship>() != 0) { return(Ok(new { result = "Friend already added" })); } if (user != null && friend != null) { var friendship = new Friendship { FriendUsername = friend.UserName, FriendId = friend.Id }; user.Friendships.Add(friendship); var reversedFriendship = new Friendship { FriendUsername = user.UserName, FriendId = user.Id }; friend.Friendships.Add(reversedFriendship); await _userManager.UpdateAsync(user); return(Ok(new { result = "Friend added successfully" })); } else { return(NotFound(new { result = "Friend could not be added" })); } }
public async Task <ActionResult> DeleteFriend([FromBody] FriendModel friendModel) { string name = GetNameFromClaim(); var friend = _userManager.Users.FirstOrDefault(c => c.UserName == friendModel.Username); var user = _userManager.Users.FirstOrDefault(c => c.UserName == name); var friendshipToRemove = context.Friendship.FirstOrDefault(c => c.ApplicationUserId == user.Id && c.FriendUsername == friendModel.Username); var reciprocalFriendshipToRemove = context.Friendship.FirstOrDefault(c => c.ApplicationUserId == friend.Id && c.FriendUsername == user.UserName); if (friendshipToRemove == null) { return(Ok(new { result = "Friendship does not exist" })); } if (user != null && friendshipToRemove != null && reciprocalFriendshipToRemove != null) { user.Friendships.Remove(friendshipToRemove); friend.Friendships.Remove(reciprocalFriendshipToRemove); await _userManager.UpdateAsync(user); await _userManager.UpdateAsync(friend); context.Friendship.Remove(friendshipToRemove); context.Friendship.Remove(reciprocalFriendshipToRemove); context.SaveChanges(); return(Ok(new { result = "Friendship successfully removed" })); } else { return(NotFound(new { result = "Friendship could not be removed" })); } }
public void AddFriendTo(FriendModel friend, Transform content, GameObject item) { var newFriend = Instantiate(item, content); FriendObject friendObj = newFriend.GetComponent <FriendObject>(); friendObj.SetFriendObject(friend); }
public ActionResult EditFriend(int id) { FriendModel friendForUpdate = Friends.ElementAt(id); friendForUpdate.Id = id; return(View(Friends.ElementAt(id))); }
public ActionResult EditFriend(int id) { FriendModel m = friends.Friends.FirstOrDefault(f => f.Id == id); friendToEdit = id; return(View(m)); }
private void GetCommentInfo(CommentsRes res) { _friendModel = GetData <FriendModel>(); _friendModel.InitCommentList(res); //GetApplyRes(); MakeFriendsView.SetData(_friendModel); }
public bool EditFriend(FriendModel model) { var rsBool = false; try { if (model.Image != null) { model.ImagePath = model.Image.ConvertTo64(); } else { model.ImagePath = model.ImagePath2; } if (friendRepository.EditFriend(model) > 0) { rsBool = true; } } catch (System.Exception ex) { CoreLogger.Instance.Error(this.CreateMessageLog(ex.Message)); } return(rsBool); }
public ActionResult UpdateFriend(int id) { FriendModel model = Friends.ElementAt(id); model.change = id; return(View(model)); }
public async Task <List <MessagesModel> > GetMessages(FriendModel friendModel) { var uri = $"{baseUri}api/User/Message/GetMessages?Username={friendModel.FirstUser}&SecondUsername={friendModel.SecondUser}"; using (var httpClient = new HttpClient()) { try { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", CrossSecureStorage.Current.GetValue("Token")); var response = await httpClient.GetAsync(uri); var resultString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <List <MessagesModel> >(resultString)); } catch (JsonReaderException) { return(new List <MessagesModel>()); } catch (Exception) { Debug.WriteLine("Unknown error"); throw new Exception(); } } }
public CardViewModel(IRegionManager regionManager, IEventAggregator eventAggregator) { this.regionManager = regionManager; this.receive_Aggregator = eventAggregator; this.send_Aggregator = eventAggregator; _achieveModel = AchieveModel.CreateNewModel(); _friendModel = FriendModel.CreateNewModel(); _familyModel = FamilyModel.CreateNewModel(); _blackModel = BlackModel.CreateNewModel(); _resultModel = ResultModel.CreateNewModel(); _msgModel = MsgModel.CreateNewModel(); //获取日志记录实例 this.ilogger = ILogger.GetInstance(); //实例化 achieveList = new List <AchieveViewModel>(); //实例化 msgList = new List <MsgViewModel>(); ChangePage(1, Paging.ACH, this._pagingAchieve); ChangePage(1, Paging.MSG, this._pagingMsg); RequestEvent(); //订阅接收信息事件 }
// GET: Group public ActionResult CreateGroup() { FriendModel fm = new FriendModel(); List <Friend> friends = friendRepository.getAllFriends(); fm.Friends = friends; return(View("CreateGroup", fm)); }
// GET: FriendModels/Delete/5 public ActionResult Delete(int id) { FriendModel friendModel = db.Friends.Find(id); db.Friends.Remove(friendModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <FriendModel> CreateAsync(Guid userId, FriendModel model) { var user = await _userRepository.FindByIdAsync(userId); if (user == null) { AddNotification("User", "Usuário não encontrado"); return(default);
public async Task <IActionResult> Update(Guid id, [FromBody] FriendModel model) { var data = await _friendApplicationService.UpdateAsync(id, model); var result = MakeResult(data); return(Ok(result)); }
public FriendViewModel Map(FriendModel friend) { return(new FriendViewModel { UserId = friend.UserId, FriendUserId = friend.FriendUserId }); }
public ActionResult DeleteConfirmed(int id) { FriendModel friendModel = db.Prijateli.Find(id); db.Prijateli.Remove(friendModel); db.SaveChanges(); return(RedirectToAction("Index")); }
private void GetMainInfo(UserFriendsRes res) { LoadingOverlay.Instance.Hide(); _friendModel = GetData <FriendModel>(); _friendModel.Init(res); GetApplyRes(); FriendsMainView.SetData(_friendModel); }
public ActionResult EditFriend(FriendModel Model) { FriendModel forUpdate = Friends.ElementAt(Model.Id); forUpdate.Ime = Model.Ime; forUpdate.MestoZiveenje = Model.MestoZiveenje; return(View("ShowFriends")); }
void getFriends() { Thread oThread = new Thread(new ThreadStart(() => { Thread.Sleep(2); var authzHeader = manager.GenerateAuthzHeader(FRIENDS_URL, "GET"); var request = (HttpWebRequest)WebRequest.Create(FRIENDS_URL); setUpHeaders(request, authzHeader); HttpWebResponse response; try { response = (HttpWebResponse)request.GetResponse(); using (response) { //TODO do better error catching if (response.StatusCode != HttpStatusCode.OK) { Debug.Log("There's been a problem trying to access fitbit:" + Environment.NewLine + response.StatusDescription); } else { string line = Utilities.getStringFromResponse(response); JSONObject list = new JSONObject(line); list.GetField("friends", delegate(JSONObject hits) { foreach (JSONObject user in hits.list) { user.GetField("user", delegate(JSONObject info) { //TODO extract more info here if we want FriendModel model = new FriendModel(info); friends.Add(model.encodedId); Debug.Log("Adding friend: " + model); updateUserFriends = true; }); } }); } // Example for someone with no friends: //{ //"friends": [] //} } } catch (Exception e) { Debug.Log("Exception in getFriends(): " + e); Thread.Sleep(1000); getFriends(); return; } })); oThread.Start(); }
public void Create([FromBody] FriendModel friend) { _FriendApplicationInterface.Add(new Domain.Entities.Friend { Name = friend.Name, Latitude = friend.Latitude, Longitude = friend.Longitude }); }
public ActionResult AddNewFriend(FriendModel model) { if (!ModelState.IsValid) { return(View("AddNewFriend", model)); } friendsList.Add(model); return(View("GetAllFriends", friendsList)); }
public ActionResult AddFriend(FriendModel model) { if (!ModelState.IsValid) { return(View("AddFriend", model)); } friends.Add(model); return(RedirectToAction("AllFriends", "Friend")); }
public async Task <IActionResult> Create([FromBody] FriendModel model) { var userId = _authUserResolver.GetUserId(); var data = await _friendApplicationService.CreateAsync(userId, model); var result = MakeResult(data); return(Ok(result)); }