Ejemplo n.º 1
0
        public JsonResult GetPosts()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = (
                    from p in db.Posts
                    where
                    p.idCategory == (db.CategoryPosts.Where(cp => cp.alias == "tin-tuc").FirstOrDefault().id) &&
                    p.featured == true && p.published == true
                    orderby p.timePublished descending
                    select new AltPost()
                {
                    id = p.id,
                    title = p.title,
                    alias = p.alias,
                    description = p.description,
                    image = p.image,
                    timePublished = p.timePublished
                }
                    ).Take(4).ToList();


                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult GetPosts(string id)
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                if (id != null)
                {
                    int idCategoryPost;
                    if (int.TryParse(id, out idCategoryPost))
                    {
                        var model = (
                            from p in db.Posts
                            where
                            p.idCategory == idCategoryPost &&
                            p.published == true
                            select new AltPost()
                        {
                            id = p.id,
                            title = p.title,
                            alias = p.alias,
                            description = p.description,
                            image = p.image,
                            timePublished = p.timePublished
                        }
                            ).OrderByDescending(p => p.id).ToList();

                        return(Json(model, JsonRequestBehavior.AllowGet));
                    }
                }

                return(null);
            }
        }
Ejemplo n.º 3
0
 public JsonResult GetBacSi()
 {
     using (MinhThanhEntities db = new MinhThanhEntities())
     {
         var model = db.BacSis.Take(3).ToList();
         return(Json(model, JsonRequestBehavior.AllowGet));
     }
 }
        public JsonResult GetPost()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                AltContact model = new AltContact();
                model.CategoryPost = db.CategoryPosts.Where(p => p.alias == "lien-he").FirstOrDefault();
                model.Info         = db.InfoCompanies.FirstOrDefault();

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Show(string alias, int id)
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = db.BacSis.Where(p => p.id == id && p.alias == alias).FirstOrDefault();

                if (model == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                return(View(model));
            }
        }
        public JsonResult GetPost(string id)
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                if (id != null)
                {
                    int idPost;
                    if (int.TryParse(id, out idPost))
                    {
                        NewsShow model = new NewsShow();
                        model.Post         = db.Posts.Where(p => p.id == idPost).FirstOrDefault();
                        model.CategoryPost = (
                            from cp in db.CategoryPosts
                            where cp.id == model.Post.idCategory
                            select new AltCategoryPost()
                        {
                            id = cp.id,
                            description = cp.description,
                            title = cp.title,
                            alias = cp.alias,
                            imageBanner = cp.imageBanner
                        }
                            ).FirstOrDefault();
                        model.LastPosts = (
                            from p in db.Posts
                            where
                            p.idCategory == model.CategoryPost.id &&
                            p.id != model.Post.id &&
                            p.published == true
                            orderby p.timePublished descending
                            select new AltPost()
                        {
                            id = p.id,
                            title = p.title,
                            alias = p.alias,
                            description = p.description,
                            image = p.image,
                            timePublished = p.timePublished
                        }
                            ).ToList();

                        return(Json(model, JsonRequestBehavior.AllowGet));
                    }
                }

                return(null);
            }
        }
Ejemplo n.º 7
0
        public JsonResult GetList()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = (
                    from cp in db.CategoryPosts
                    select new ListCategoryPost()
                {
                    id = cp.id,
                    title = cp.title
                }
                    ).ToList();

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 8
0
        public JsonResult GetPost()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                AltCommitment model = new AltCommitment();
                model.CategoryPost = db.CategoryPosts.Where(p => p.alias == "cam-ket").FirstOrDefault();
                model.Post         = db.Posts.Where(
                    p => p.idCategory == (db.CategoryPosts.Where(cp => cp.alias == "cam-ket").FirstOrDefault().id) &&
                    p.featured == true &&
                    p.published == true
                    ).OrderByDescending(p => p.id).FirstOrDefault();


                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
        public int DeleteImages(int id)
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = db.Images.Where(p => p.idGallery == id);
                if (model != null)
                {
                    db.Images.RemoveRange(model);
                    db.SaveChanges();

                    return(1);
                }

                return(0);
            }
        }
        public JsonResult GetSerVices()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = (
                    from cp in db.CategoryPosts
                    where cp.published == true && cp.isService
                    select new AltCategoryPost()
                {
                    id = cp.id,
                    title = cp.title,
                    alias = cp.alias
                }
                    ).ToList();

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 11
0
        //SUPPORT API
        public JsonResult GetAll()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = (
                    from p in db.BacSis
                    select new AltBacSi()
                {
                    id = p.id,
                    hoTen = p.hoTen,
                    alias = p.alias,
                    featured = p.featured
                }
                    ).ToList();

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 12
0
        //Delelte
        public ActionResult Delete(string id)
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var user = db.AspNetUsers.Find(id);

                if (User.Identity.GetUserId() == user.Id)
                {
                    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                }

                db.AspNetUsers.Remove(user);

                db.SaveChanges();

                return(RedirectToAction("Index", "Account"));
            }
        }
Ejemplo n.º 13
0
        public JsonResult GetAll()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = (
                    from ac in db.AspNetUsers
                    select new AltAccount()
                {
                    id = ac.Id,
                    email = ac.Email,
                    emailConfirmed = ac.EmailConfirmed,
                    twoFactor = ac.TwoFactorEnabled
                }
                    ).ToList();

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
        //SUPPORT API
        public JsonResult GetAll()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = (
                    from p in db.Galleries
                    select new AltGallery()
                {
                    id = p.id,
                    title = p.title,
                    alias = p.alias,
                    published = p.published,
                    featured = p.featured,
                    note = p.note
                }
                    ).ToList();

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 15
0
        //SUPPORT API
        public JsonResult GetAll()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = (
                    from cp in db.CategoryPosts
                    select new AltCategoryPost()
                {
                    id = cp.id,
                    title = cp.title,
                    alias = cp.alias,
                    published = cp.published,
                    isService = cp.isService,
                    note = cp.note
                }
                    ).ToList();

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 16
0
        //SUPPORT API
        public JsonResult GetAll()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = (
                    from p in db.GiaDichVus
                    select new AltGiaDV()
                {
                    id = p.ID,
                    TenDV = p.TenDV,
                    MaDV = p.MaDV,
                    GiaBaoHiem = p.GiaBaoHiem,
                    GiaVienPhi = p.GiaVienPhi,
                    GiaYeuCau = p.GiaYeuCau,
                }
                    ).ToList();

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Show(string alias, int id)
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = db.Posts.Where(p => p.id == id && p.alias == alias).FirstOrDefault();

                if (model == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                //SEO
                ViewBag.Title       = model.title;
                ViewBag.Description = model.metaDescription;
                ViewBag.Keywords    = model.metaKewords;
                ViewBag.Robots      = model.robots;
                ViewBag.Image       = model.image;

                return(View(model));
            }
        }
Ejemplo n.º 18
0
        public JsonResult GetGallery(string id)
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                if (id != null)
                {
                    int idGallery;
                    if (int.TryParse(id, out idGallery))
                    {
                        AltGallery model = new AltGallery()
                        {
                            Info   = db.Galleries.Find(idGallery),
                            Images = db.Images.Where(p => p.idGallery == idGallery).ToList()
                        };

                        return(Json(model, JsonRequestBehavior.AllowGet));
                    }
                }

                return(null);
            }
        }
Ejemplo n.º 19
0
        //SearchByText
        public JsonResult SearchByText(string search)
        {
            search = search.ToLower();

            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var model = (
                    from p in db.Posts.Where(p => p.title.Contains(search) || p.description.Contains(search) || p.content.Contains(search))
                    where p.published == true
                    select new AltPost()
                {
                    id = p.id,
                    alias = p.alias,
                    title = p.title,
                    description = p.description,
                    image = p.image,
                    timePublished = p.timePublished
                }
                    ).ToList();

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 20
0
        public JsonResult GetServices()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                var categoryPosts = (
                    from cp in db.Posts
                    where
                    cp.idCategory == (db.CategoryPosts.Where(p => p.alias == "dich-vu").FirstOrDefault().id) &&
                    cp.published == true &&
                    cp.featured == true
                    select new AltPost()
                {
                    id = cp.id,
                    title = cp.title,
                    alias = cp.alias,
                    description = cp.description,
                    image = cp.image
                }
                    ).Take(4).ToList();

                return(Json(categoryPosts, JsonRequestBehavior.AllowGet));
            }
        }
        public JsonResult GetPosts()
        {
            using (MinhThanhEntities db = new MinhThanhEntities())
            {
                AllNews model = new AllNews();

                model.Posts = (
                    from p in db.Posts
                    where
                    p.idCategory == (db.CategoryPosts.Where(cp => cp.alias == "tin-tuc").FirstOrDefault().id) &&
                    p.published == true
                    select new AltPost()
                {
                    id = p.id,
                    title = p.title,
                    alias = p.alias,
                    description = p.description,
                    image = p.image,
                    timePublished = p.timePublished
                }
                    ).OrderByDescending(p => p.id).ToList();

                model.CategoryPost = (
                    from cp in db.CategoryPosts
                    where cp.alias == "tin-tuc"
                    select new AltCategoryPost()
                {
                    id = cp.id,
                    title = cp.title,
                    description = cp.description,
                    imageBanner = cp.imageBanner
                }
                    ).FirstOrDefault();

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }