Exemplo n.º 1
0
 public ActionResult NextPage(DateTime currentTopic)
 {
     using (var db = new Blog.Models.BlogContext())
     {
         var post = db.Entries.First(e => e.Date > currentTopic);
         if (post == null)
         {
             return(RedirectToAction("DisplayEntry", new { topic = currentTopic }));
         }
         return(RedirectToAction("DisplayEntry", new { topic = post.Topic }));
     }
 }
 public ArticleController()
 {
     var emojiRootDir = new DirectoryInfo(System.Web.Hosting.HostingEnvironment.MapPath("/Content/img/emoji/"));
     var emojiPacks = emojiRootDir.GetDirectories();
     _emojis = new List<string>[emojiPacks.Length];
     for (int i = 0; i < emojiPacks.Length; i++)
     {
         if (_emojis[i] == null)
             _emojis[i] = new List<string>();
         foreach (var fileName in emojiPacks[i].GetFiles())
         {
             _emojis[i].Add(fileName.FullName.Replace(System.Web.HttpContext.Current.Request.PhysicalApplicationPath, string.Empty));
         }
     }
     _db = new BlogContext(ConfigurationManager.ConnectionStrings["BlogContext"].ConnectionString);
 }
Exemplo n.º 3
0
 public ActionResult UploadImage(HttpPostedFileBase file)
 {
     if (file != null)
     {
         using (var db = new Blog.Models.BlogContext())
         {
             var    stream = file.InputStream;
             byte[] bytes  = new byte[stream.Length];
             stream.Read(bytes, 0, (int)stream.Length);
             db.Entries.Single().Image = bytes;
         }
     }
     else
     {
         throw new Exception("f...");
     }
     return(RedirectToAction("StartView"));
 }
 public HomeController(string connectionString)
 {
     Db = new BlogContext(connectionString);
 }
 public HomeController()
 {
     Db = new BlogContext(ConfigurationManager.ConnectionStrings["BlogContext"].ConnectionString);
 }
 public ActionResult Login(Member member)
 {
     if (ModelState.IsValid)
     {
         using (BlogContext db = new BlogContext(ConfigurationManager.ConnectionStrings["BlogContext"].ConnectionString))
         {
             string hashPass=EncryptString(member.Password,_passPhrase);
             var v = db.Members.FirstOrDefault(a => a.UserName.Equals(member.UserName) && a.Password.Equals(hashPass));
             if (v == null) return View(member);
             Session["LoggedUserID"] = v.UserId.ToString();
             Session["LoggedUserName"] = String.IsNullOrEmpty(v.NickName) ? v.UserName : v.NickName;
             return RedirectToAction("Index", "Dashboard");
         }
     }
     return View(member);
 }
 public ActionResult Signup( Member member)
 {
     if (ModelState.IsValid)
     {
         using (BlogContext db = new BlogContext(ConfigurationManager.ConnectionStrings["BlogContext"].ConnectionString))
         {
             member.UserId = null;
             member.IsActive = 1;
             member.Password=EncryptString(member.Password, _passPhrase);
             db.Members.Add(member);
             db.SaveChanges();
         }
         return Content("Congratulation ! New Member "+(String.IsNullOrEmpty(member.NickName) ? member.UserName : member.NickName)+". Please <b><a href='/Admin/Login'>Click Here to Login</a></b>");
     }
     else
     return View();
 }
 public GalleryController(BlogContext db)
 {
     _db = db;
 }
 public GalleryController()
 {
     _db = new BlogContext(ConfigurationManager.ConnectionStrings["BlogContext"].ConnectionString);
 }
 public DashBoardController(BlogContext db)
 {
     _db = db;
 }
 /*Test Userage*/
 public ArticleController(string connectionString)
 {
     _db = new BlogContext(connectionString);
 }