예제 #1
0
        public ActionResult Index(string title)
        {
            if (title == null)
            {
                title = "This is my first title";
            }

            using (var ctx = new EFContext())
            {
                var post         = ctx.Posts.Where(p => p.Title == title).FirstOrDefault();
                var postModel    = new PostModel(post.Title, post.Body, post.DateCreated);
                var commentModel = new Collection <string>();
                if (post.Comments != null && post.Comments.Any())
                {
                    foreach (var item in post.Comments)
                    {
                        commentModel.Add(item.Body);
                    }
                }

                var dao   = new MongoDAO();
                var mPost = dao.LoadPost(title);

                return(View(new ArticleModel(postModel, commentModel)));
            }

            //var readers = new NewDataReaders();
            //return View(readers.GetArticleModel(title));
        }
예제 #2
0
        public static IDataAccess ResolveDataAccess()
        {
            var isMongo = bool.Parse(ConfigurationManager.AppSettings["isMongo"]);

            if (isMongo)
            {
                dataAccess = new MongoDAO();
            }
            else
            {
                dataAccess = new DataAccess.DataAccess();
            }
            return(dataAccess);
        }
예제 #3
0
 public BebidaService(IConfiguration config)
 {
     bebidaDAO = new MongoDAO <Bebida>(config, "CatalogoDb", "Bebidas");
 }