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; }
public ImageService(UserContext userContext, IImageRepository imageRepository, IMoodRepository moodRepository) : base(userContext) { _imageRepository = imageRepository; _moodRepository = moodRepository; }
protected BaseService(UserContext userContext) { UserContext = userContext; }
public void Create(UserContext userContext, string ip) { Created = DateTime.Now; Ip = ip; }
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); }
public MoodService(IMoodRepository moodRepository, UserContext userContext, IImageRepository imageRepository) : base(userContext) { _moodRepository = moodRepository; _imageRepository = imageRepository; }