Пример #1
0
        public ActionResult AddFrends(int id)
        {
            UsersContext    db       = new UsersContext();
            List <UserData> TempList = new List <UserData>();

            TempList = db.UsersData.ToList();
            FrendsModel frend = new FrendsModel();

            frend.IsConfirm = false;
            frend.Time      = DateTime.Now;

            for (int i = 0; i < TempList.Count; i++)
            {
                if (TempList[i].UserProfile.UserId == WebSecurity.CurrentUserId)
                {
                    frend.UserA = TempList[i];
                }
                if (TempList[i].UserProfile.UserId == id)
                {
                    frend.UserB = TempList[i];
                }
            }


            db.Frends.Add(frend);
            db.SaveChanges();
            int CurrentId = id;

            // Url.Action
            return(RedirectToAction("Index", "Users", new { id = CurrentId }));
            //return View();
        }
Пример #2
0
        public ActionResult Renouncement(int id)
        {
            UsersContext db = new UsersContext();
            //IQueryable<FrendsModel> ods = from o in db.Frends
            //                               where o.Id == id
            //                               select o;
            //db.DeleteObject(ods.First());
            FrendsModel RemoveFrendModel = db.Frends.Find(id);

            db.Frends.Remove(RemoveFrendModel);
            db.SaveChanges();
            return(RedirectToAction("RequestFrends"));
        }