예제 #1
0
 public static List<MyBlog.Models.Blog> SelectAll()
 {
     using (MyBlogEntities entities = new MyBlogEntities())
     {
         return entities.Blogs.Select(e => new MyBlog.Models.Blog() { Title = e.Title, Description = e.Description, BlogId = e.BlogID, CreationDate = e.TStamp}).OrderByDescending(e => e.CreationDate).ToList();
     }
 }
예제 #2
0
        public ActionResult Index()
        {
            using (var c = new MyBlogEntities())
            {

            }
            return Redirect("/Login");
        }
예제 #3
0
 public static bool CheckExists(string title)
 {
    bool result = false;
     using (MyBlogEntities entities = new MyBlogEntities())
     {
         if (entities.Blogs.Where(e => e.Title.ToLower().Equals(title)).Select(e => e).Count() > 0)
         {
             result = true;
         }
     }
     return result;
 }
예제 #4
0
 public static void DeleteBlog(int blogId)
 {
     using (MyBlogEntities entities = new MyBlogEntities())
     {
         try
         {
             entities.Blogs.Remove(entities.Blogs.Where(e => e.BlogID == blogId).Select(e => e).First());
             entities.SaveChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
예제 #5
0
 public static void InsertBlog(Blog blog)
 {
     using (MyBlogEntities entities = new MyBlogEntities())
     {
         entities.Blogs.Add(blog);
         try
         {
             entities.SaveChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
예제 #6
0
 public ActionResult Index(int? id)
 {
     using (var c = new MyBlog.Data.MyBlogEntities())
     {
         id = Int32.Parse(Request.Cookies["UserId"].Value);
         User user = c.Users.Where(u => u.Id == id).Single();
         UserInfo userInfo = new UserInfo
         {
             Email = user.Email,
             City = user.City,
             Country = user.Country.Value.ToString(),
             Icq = user.Icq,
             Phone = user.Phone,
             Sex = UserInfo.GetSex(user.Sex.Value),
             Skype = user.Skype
         };
         return View("Index", userInfo);
     }
 }