Ejemplo n.º 1
0
        public JsonResult Detail(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(Json(new { Ok = true, Data = new { }, Message = "Input to add new" }, JsonRequestBehavior.AllowGet));
            }

            using (var db = new DomainDrivenDesign.CoreCms.Ef.CoreCmsDbContext())
            {
                var data = db.Categories.Where(i => i.Id == id)
                           .Select(c => new FeCategory()
                {
                    Id               = c.Id,
                    IsSinglePage     = c.IsSinglePage,
                    ShowInFrontEnd   = c.ShowInFrontEnd,
                    CategoryViewName = c.CategoryViewName,
                    Type             = (Enums.CategoryType)c.Type
                }).FirstOrDefault();

                data.Title          = db.ContentLanguages.GetValue(id, LanguageId, "Title", "Category");
                data.SeoUrlFriendly = db.ContentLanguages.GetValue(id, LanguageId, "SeoUrlFriendly", "Category");
                data.SeoDescription = db.ContentLanguages.GetValue(id, LanguageId, "SeoDescription", "Category");
                data.SeoKeywords    = db.ContentLanguages.GetValue(id, LanguageId, "SeoKeywords", "Category");

                return(Json(new { Ok = true, Data = data, Message = "Input to edit" }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Index(Guid?id)
        {
            var model = new ProductListAdminPage();

            if (null != id)
            {
                var xid = id.Value;
                using (var db = new DomainDrivenDesign.CoreCms.Ef.CoreCmsDbContext())
                {
                    model.CategoryId    = xid;
                    model.CategoryTitle = db.ContentLanguages.GetValue(xid, LanguageId, "Title", "Category");
                }
            }

            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult Detail(string urlsegment)
        {
            if (string.IsNullOrEmpty(urlsegment))
            {
                return(Content("404 not found news"));
            }

            var model = new FeNews();

            using (var db = new DomainDrivenDesign.CoreCms.Ef.CoreCmsDbContext())
            {
                var temp = db.UrlFriendlys.FirstOrDefault(
                    i => i.UrlSegment.Equals(urlsegment, StringComparison.OrdinalIgnoreCase) &&
                    i.TableName.Equals("News", StringComparison.OrdinalIgnoreCase));
                if (temp == null)
                {
                    return(Content("Not found. 404"));
                }
                var id   = temp.Id;
                var news = db.News.SingleOrDefault(i => i.Id == id);

                model.Id           = id;
                model.AllowComment = news.AllowComment;

                model.Title = db.ContentLanguages.GetValue(id, LanguageId, "Title");

                model.ShortDescription = db.ContentLanguages.GetValue(id, LanguageId, "ShortDescription");

                model.Description = db.ContentLanguages.GetValue(id, LanguageId, "Description");

                model.SeoKeywords = db.ContentLanguages.GetValue(id, LanguageId, "SeoKeywords");
                model.UrlImage    = db.ContentLanguages.GetValue(id, LanguageId, "UrlImage");

                model.SeoDescription = db.ContentLanguages.GetValue(id, LanguageId, "SeoDescription");
            }
            return(View(model));
        }
Ejemplo n.º 4
0
        public JsonResult List(Guid?roleId, string keywords,
                               int?skip, int?take, string sortField, string orderBy)
        {
            var  xtake = 10;
            var  xskip = 0;
            long total = 0;

            if (skip != null)
            {
                xskip = skip.Value;
            }
            if (take != null)
            {
                xtake = take.Value;
            }
            if (string.IsNullOrEmpty(sortField))
            {
                sortField = nameof(DomainDrivenDesign.Core.Implements.Models.User.Username);
            }
            if (string.IsNullOrEmpty(orderBy))
            {
                orderBy = "desc";
            }

            Expression <Func <User, bool> > predicate = u => true;

            if (!string.IsNullOrEmpty(keywords))
            {
                predicate = predicate.And(i => i.Username.Contains(keywords) ||
                                          i.Email.Contains(keywords) ||
                                          i.Phone.Contains(keywords));
            }


            List <User> rows = null;

            using (var db = new DomainDrivenDesign.CoreCms.Ef.CoreCmsDbContext())
            {
                if (roleId.HasValue)
                {
                    var xroleId   = roleId.Value;
                    var queryable = db.Users.Join(db.RelationShips, u => u.Id, rs => rs.FromId, (u, rs) => new { U = u, Rs = rs })
                                    .Where(i => i.Rs.ToId == xroleId).Select(m => m.U)
                                    .Where(predicate);
                    total = queryable.LongCount();

                    rows = queryable
                           .OrderBy(i => i.Username)
                           .Skip(xskip).Take(xtake).ToList();
                }
                else
                {
                    var queryable = db.Users.Where(predicate);
                    total = queryable.LongCount();

                    rows = queryable
                           .OrderBy(i => i.Username)
                           .Skip(xskip).Take(xtake).ToList();
                }
            }

            return(Json(new { total, rows, success = true }, JsonRequestBehavior.AllowGet));
        }