예제 #1
0
        private DTResult <T> getResult <T>(DTParameters param) where T : Dictionary <string, object>, new()
        {
            var dtsource = new List <T>();
            var users    = db.Users;

            foreach (var user in users)
            {
                var details = user.DetailsToDictionary();

                var name = string.Empty;
                if (details.ContainsKey("last_name"))
                {
                    name = details["last_name"];
                }
                if (details.ContainsKey("first_name"))
                {
                    name += " " + details["first_name"];
                }
                DateTime?lockout = UserManager.GetLockoutEndDate(user.Id).DateTime.ToLocalTime();

                var obj = new T {
                    { "id", user.Id },
                    { "name", name },
                    { "username", user.UserName },
                    { "email", user.Email },
                    { "lockout", lockout <= DateTime.Now || lockout <= DateTime.MinValue.ToLocalTime() ? null : lockout }
                };
                dtsource.Add(obj);
            }
            return(JDatatables <T> .GetDTResult(param, dtsource));
        }
예제 #2
0
        private DTResult <T> GetDtResult <T>(DTParameters param, Dictionary <string, string> args) where T : Dictionary <string, object>, new()
        {
            var dtsource = new List <T>();
            var dbSource = FilterDbSource(args);

            var entityNodes = new List <EntityNode <Category> >();

            foreach (var source in dbSource)
            {
                entityNodes.AddRange(source.GetNodes(0));
            }

            foreach (var item in entityNodes)
            {
                dtsource.Add(new T
                {
                    { ID, item.Entity.Id },
                    { NAME, item.Entity.Name },
                    { DESCRIPTION, item.Entity.Description },
                    { LEVEL, item.Depth }
                });
            }

            return(JDatatables <T> .GetDTResult(param, dtsource));
        }
예제 #3
0
        private DTResult <T> GetDtResult <T>(DTParameters param, Dictionary <string, string> args) where T : Dictionary <string, object>, new()
        {
            var dtsource = new List <T>();
            var dbSource = FilterDbSource(args);

            foreach (var item in dbSource)
            {
                dtsource.Add(new T
                {
                    { ConstantKeys.ID, item.Id },
                    { ConstantKeys.NAME, item.Name },
                });
            }
            return(JDatatables <T> .GetDTResult(param, dtsource));
        }
예제 #4
0
        private DTResult <T> getResult <T>(DTParameters param) where T : Dictionary <string, object>, new()
        {
            var dtsource = new List <T>();
            var roles    = db.Roles;

            foreach (var role in roles)
            {
                var obj = new T {
                    { "id", role.Id },
                    { "name", role.Name },
                    { "users", role.Users.Count }
                };
                dtsource.Add(obj);
            }
            return(JDatatables <T> .GetDTResult(param, dtsource));
        }
예제 #5
0
        private DTResult <T> GetDtResult <T>(DTParameters param, Dictionary <string, string> args) where T : Dictionary <string, object>, new()
        {
            var dtsource = new List <T>();
            var dbSource = FilterDbSource(args);

            foreach (var source in dbSource)
            {
                dtsource.Add(new T
                {
                    { "name", source.Name },
                    { "label", source.Label },
                    { "type", source.FieldType.ToString() },
                    { "pHolder", source.PlaceHolder },
                    { "status", source.Status }
                });
            }

            return(JDatatables <T> .GetDTResult(param, dtsource));
        }
예제 #6
0
        private DTResult <T> GetDtResult <T>(DTParameters param, Dictionary <string, string> args) where T : Dictionary <string, object>, new()
        {
            var dtsource = new List <T>();
            var dbSource = FilterDbSource(args);
            var o        = new object();

            foreach (var item in dbSource)
            {
                dtsource.Add(new T
                {
                    { ID, item.Id },
                    { TITLE, item.Title },
                    { EXCERPT, item.Excerpt },
                    { AUTHOR, item.CreateUser?.UserName },
                    { CATEGORIES, item.Categories.Select(c => new { id = c.Id, name = c.Name }) },
                    { STATUS, item.Status },
                    { TIME, item.CreateTime }
                });
            }
            return(JDatatables <T> .GetDTResult(param, dtsource));
        }
예제 #7
0
        private DTResult <T> GetDtResult <T>(DTParameters param, Dictionary <string, string> args) where T : Dictionary <string, object>, new()
        {
            var dtsource = new List <T>();
            var dbSource = FilterDbSource(args);

            foreach (var item in dbSource)
            {
                var options = item.Product_Options.Select(o => new Dictionary <string, object>()
                {
                    { ConstantKeys.ID, o.Id },
                    { ConstantKeys.NAME, o.Name },
                    { ConstantKeys.QUANTITY, o.Product_Options_Details.FirstOrDefault(d => d.Name == "so_luong").Value ?? "Stocking" }
                });

                var categories = item.Categories.Select(o => new Dictionary <string, object>()
                {
                    { ConstantKeys.ID, o.Id },
                    { ConstantKeys.NAME, o.Name },
                });

                dtsource.Add(new T
                {
                    { ConstantKeys.ID, item.Id },
                    { ConstantKeys.NAME, item.Name },
                    { ConstantKeys.PREVIEW_IMAGE, item.Image?.FullFileName },
                    { ConstantKeys.EXCERPT, item.Excerpt },
                    { ConstantKeys.PRODUCT_TYPE, item.ProductType?.Name },
                    { ConstantKeys.PRODUCT_OPTIONS, options },
                    { ConstantKeys.CATEGORIES, categories },
                    { ConstantKeys.FEATURE, item.Featured },
                    { ConstantKeys.STATUS, item.Status },
                    { ConstantKeys.AUTHOR, item.CreateUser?.UserName },
                    { ConstantKeys.TIME, item.CreateTime }
                });
            }
            return(JDatatables <T> .GetDTResult(param, dtsource));
        }