示例#1
0
        public PartialViewResult Add(string MediaID)
        {
            FacebookUser me = (FacebookUser)Session["me"];

            Media item = (Media)TempData[MediaID];

            if (db.Ownerships.Any(o => o.MediaID == item.id & o.UserID == me.Id) == false)
            {
                Ownership ownership = new Ownership();
                ownership.MediaID = item.id;
                ownership.TypeID = item.type;
                ownership.UserID = me.Id;
                ownership.Season = item.Season;
                db.Ownerships.Add(ownership);

                db.SaveChanges();
            }

            return PartialView("~/Views/Shared/_RenderMedia.cshtml", item);
        }
示例#2
0
        public void AddFromSearch(string MediaId, string MediaType)
        {
            FacebookUser me = (FacebookUser)Session["me"];

            Ownership ownership = new Ownership();
            ownership.MediaID = MediaId;
            ownership.Order = db.Ownerships.Where(x => x.UserID == me.Id).Max(y => y.Order) + 1;
            ownership.UserID = me.Id;

            if (MediaType == "movie")
            {
                ownership.TypeID = 1;
            }
            else if (MediaType == "tv")
            {
                ownership.TypeID = 2;
            }

            db.Ownerships.Add(ownership);

            db.SaveChanges();
        }