コード例 #1
0
 public void UpdateLog(Guid id, string userInput)
 {
     using (PersonalWebsiteContext context = new PersonalWebsiteContext())
     {
         Log error = context.LoggedMessages.Find(id);
         error.UserInput = userInput;
         context.SaveChanges();
     }
 }
コード例 #2
0
        /// <summary>
        /// Saves a new blog to the db.  Post cannot be null.
        /// </summary>
        /// <param name="post">The post to save, cannot be null.</param>
        public void Log(Log log)
        {
            if (log == null)
                throw new ArgumentNullException("error");

            using (PersonalWebsiteContext context = new PersonalWebsiteContext())
            {
                context.LoggedMessages.Add(log);
                context.SaveChanges();
            }
        }
コード例 #3
0
        protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
        {
            if (controllerType == typeof(BlogController))
            {
                PersonalWebsiteContext context = new PersonalWebsiteContext();
                _provider = _provider ?? new CachingProvider();
                BlogRepository repo = new BlogRepository(context, _provider);
                return new BlogController(repo);
            }
            else if (controllerType == typeof(ErrorController))
            {
                return new ErrorController(new SqlLoggingRepository());
            }

            else
                return base.GetControllerInstance(requestContext, controllerType);
        }
コード例 #4
0
 ///<Summary>
 /// Either use a Unit of Work, or manually ensure all Repos share the same context.
 ///</Summary>
 public BlogRepository(PersonalWebsiteContext context, ICachingProvider cache)
 {
     _context = context;
     _cache = cache;
 }