Beispiel #1
0
        public List <MOVIE> SearchPreferMovies(int newUserID)
        {
            //根据用户偏好 选择相关影片推荐按点击数排列 以列表的形式返回
            //select *
            //from schedule
            //where movie_id in (select id from movie where kind like @kind ) and cinema_id in (select id from cinema where addr like @addr)
            WATCHMOVIEEntities w     = new WATCHMOVIEEntities();
            List <MOVIE>       movie = new List <MOVIE>();
            string             kind  = null;


            var result1 = from u in w.RUSER
                          where u.id == newUserID
                          select u;

            RUSER user = new RUSER();

            if (result1.Count() > 0)
            {
                user = result1.First();
                kind = user.like_kind;
            }
            if (kind != null)
            {
                string[] singleKinds = kind.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string singleKind in singleKinds)
                {
                    var result2 = from m in w.MOVIE
                                  //where kind.Equals(m.kind)
                                  where m.kind.Contains(singleKind)
                                  orderby m.click_number descending
                                  select m;

                    foreach (var r in result2)
                    {
                        movie.Add(r);
                    }
                }
            }

            return(movie);
        }
Beispiel #2
0
        public bool AddUser(string newName, string newEmail, string newePassword)
        {
            Search searchEmail = new Search();//用来检查newEmai是不是已经注册过

            if (!(searchEmail.SearchEmail(newEmail)))
            {
                //创建新用户

                WATCHMOVIEEntities entity = new WATCHMOVIEEntities();
                RUSER newUser             = new RUSER();

                //为新用户添加基本信息
                newUser.name     = newName;
                newUser.password = newePassword;
                newUser.email    = newEmail;

                entity.RUSER.AddObject(newUser);
                try
                {
                    int i = entity.SaveChanges();
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.ToString());
                    entity.Dispose();
                    return(false);
                }
                entity.Dispose();

                return(true);
            }
            else
            {
                return(false);
            }
        }