public ActionResult DeleteConfirmed(int id) { FriendTable friendTable = db.FriendTables.Find(id); db.FriendTables.Remove(friendTable); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "FriendId,FriendName,Place")] FriendTable friendTable) { if (ModelState.IsValid) { db.Entry(friendTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(friendTable)); }
public ActionResult Create([Bind(Include = "FriendId,FriendName,Place")] FriendTable friendTable) { if (ModelState.IsValid) { db.FriendTables.Add(friendTable); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(friendTable)); }
// GET: Friend/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FriendTable friendTable = db.FriendTables.Find(id); if (friendTable == null) { return(HttpNotFound()); } return(View(friendTable)); }
void insertFriends (object obj) { lock (singletonLock) { try { deleteAllFriends(); Hashtable hash = (Hashtable)obj; List<FriendEntity> friends = (List<FriendEntity>) hash[DatabaseManager.FRIEND_INFO]; for (int i = 0; i < friends.Count; i++) { var p = new FriendTable{ UserId = friends[i].UserId, DisplayName = friends[i].Name, Avatar = friends[i].Avatar, Gender = friends[i].Gender, Level = friends[i].Level, Score = friends[i].Score, FbId = friends[i].FBId }; int isSuccess = connection.Update(p); if (isSuccess == 0 ) { connection.Insert(p); } } } catch(Exception ex) { Debug.LogWarning (ex.Message); } } }
public string Register(RegisterUser user) { Console.WriteLine(user.UserName + "Register"); if (user.UserType == 0) { UserTable userTable = new UserTable() { UserName = user.UserName, Address = user.Address, City = getCity(user.Address), Latitude = user.Latitude, Longitude = user.Longitude, Password = user.Passwrod, Point = 10, Avatar = user.ImageFileData, LastRank = 200, CityLastRank = 100, NowRank = 200, NowCityRank = 100, UserRank = 100, CityRank = 100 }; db.UserTables.AddObject(userTable); db.SaveChanges(); UserTable userTable1 = db.UserTables.SingleOrDefault(c => c.UserName == userTable.UserName && c.Password == userTable.Password); foreach (UserTable item in db.UserTables.Where(c => c.City == userTable1.City)) { FriendTable Friend = new FriendTable() { UserId = userTable1.Id, FriendId = item.Id }; if (Friend.UserId != Friend.FriendId) { db.FriendTables.AddObject(Friend); // db.SaveChanges(); } FriendTable Friend1 = new FriendTable() { UserId = item.Id, FriendId = userTable1.Id }; if (Friend1.UserId != Friend1.FriendId) { db.FriendTables.AddObject(Friend1); // db.SaveChanges(); } } } if (user.UserType == 1) { AcquirerTable acquirer = new AcquirerTable() { UserName = user.UserName, Address = user.Address, City = getCity(user.Address), Latitude = user.Latitude, Longitude = user.Longitude, PassWord = user.Passwrod, Phone = user.Phone, BinName = user.StoreBinName, Avatar = user.ImageFileData, }; db.AcquirerTables.AddObject(acquirer); } if (user.UserType == 2) { MerChantTable merchant = new MerChantTable() { UserName = user.UserName, Address = user.Address, Latitude = user.Latitude, Longitude = user.Longitude, PassWord = user.Passwrod, Phone = user.Phone, StoreName = user.StoreBinName, Avatar = user.ImageFileData, }; db.MerChantTables.AddObject(merchant); } if (!db.CityTables.Select(c => c.Name).Contains(getCity(user.Address))) { CityTable city = new CityTable() { Name = user.City, LastRank = 100, Point = 10 }; db.CityTables.AddObject(city); } db.SaveChanges(); return("Register Success"); }