Exemple #1
0
        public void TestMethod4()
        {
            IUserRepository iur = new UserRepository();

            var u = iur.getUserByUsername("zhu");
            IWishRepository imr = new WishRepository();

            Wish wish=new Wish(){UserId = 1,Wishcontent = "没啥",WishStateId = 1};
            var w = imr.AddOrUpdateAWish(wish);
            Assert.True(w);
        }
Exemple #2
0
 public bool AddOrUpdateAWish(Wish wish)
 {
     try
     {
         if (wish.UserId == null || wish.WishStateId ==null)
         {
             return false;
         }
         DB.Wishs.AddOrUpdate(wish);
         DB.SaveChanges();
         return true;
     }
     catch (Exception e)
     {
         Logger.Error("WishRepository-AddOrUpdateAWish:Error:" + e);
         throw;
     }
 }
Exemple #3
0
        public bool MakeAWish(int userId, string wishText,string wishTitle)
        {
            try
            {
                if (userId==null||userId==0)
                {
                    return false;
                }
                Wish wish = new Wish() { UserId = userId, Wishcontent = wishText, WishStateId = 1 ,WishTitle = wishTitle,WishTime = DateTime.Now};

                var result=wishRepository.AddOrUpdateAWish(wish);
                if (result)
                {
                    trackingRepository.AddTracking(userId, 2, "许了一个愿望:" + wishTitle);
                }
                return result;

            }
            catch (Exception e)
            {
                Logger.Error("WishServers-MakeAWish:Error:"+e);
                throw;
            }
        }