public Pagination <EntityTransaltion> FindOutOfDate(CultureInfo culture, Type entityType, int pageInex, int pageSize)
        {
            using (var db = new MultilingualDbContext(InstanceName))
            {
                return(db.Translations
                       .Where(t => t.Culture == culture.Name && t.EntityType == entityType.Name && t.IsOutOfDate)
                       .OrderBy(t => t.EntityKey)
                       .Paginate(pageInex, pageSize)
                       .Transform(entry =>
                {
                    var keyType = EntityKey.GetKeyProperty(entityType).PropertyType;
                    var translation = new EntityTransaltion(culture.Name, new EntityKey(entityType, Convert.ChangeType(entry.EntityKey, keyType)))
                    {
                        IsOutOfDate = true,
                        PropertyTranslations = JsonConvert.DeserializeObject <List <PropertyTranslation> >(entry.Properties)
                    };

                    return translation;
                }));
            }
        }
Beispiel #2
0
        public ActionResult ExecuteCommand(string commandName, string itemType, CommandDataItem[] model, [ModelBinder(typeof(BindingTypeAwareModelBinder))] object config = null)
        {
            var command    = TopbarCommands.GetCommand(commandName);
            var entityType = Type.GetType(itemType, true);
            var repository = CurrentInstance.Database.Repository(entityType);
            var idProperty = EntityKey.GetKeyProperty(entityType);
            var items      = new List <object>();

            foreach (var each in model)
            {
                var id   = Convert.ChangeType(each.Id, idProperty.PropertyType);
                var item = repository.Find(id);
                items.Add(item);
            }

            var result = command.Execute(items, config, CurrentInstance);

            if (result == null)
            {
                result = AjaxForm().ReloadPage();
            }

            return(result);
        }
Beispiel #3
0
 private string GetKeyFieldName()
 {
     return(EntityKey.GetKeyProperty(ModelType).Name);
 }