예제 #1
0
        public static UserContext GetContext()
        {
            var context = (UserContext)HttpContext.Current.Session[UserString];
            if (context == null)
            {
                var cookie = HttpContext.Current.Request.Cookies[UserString];
                bool needSet = cookie == null;
                context = new UserContext(needSet ? "" : cookie.Value);
                if (needSet)
                {
                    var newCookie = new HttpCookie(UserString, context.UserGuid.ToString())
                                        {
                                            Expires = DateTime.Now.AddYears(100),

                                        };

                    HttpContext.Current.Response.Cookies.Add(newCookie);
                }
                HttpContext.Current.Session.Add(UserString, context);
            }
            return context;
        }
예제 #2
0
 public ImageService(UserContext userContext, IImageRepository imageRepository, IMoodRepository moodRepository)
     : base(userContext)
 {
     _imageRepository = imageRepository;
     _moodRepository = moodRepository;
 }
예제 #3
0
 protected BaseService(UserContext userContext)
 {
     UserContext = userContext;
 }
예제 #4
0
 public void Create(UserContext userContext, string ip)
 {
     Created = DateTime.Now;
     Ip = ip;
 }
예제 #5
0
 public void AddMood(Mood mood, UserContext userContext)
 {
     if (mood.Id == 0)
     {
         mood.Create();
     }
     var moodToImage = new MoodToImage {Mood = mood};
     moodToImage.Vote(userContext.UserGuid);
     ImageMoods.Add(moodToImage);
 }
예제 #6
0
 public MoodService(IMoodRepository moodRepository, UserContext userContext, IImageRepository imageRepository)
     : base(userContext)
 {
     _moodRepository = moodRepository;
     _imageRepository = imageRepository;
 }