Exemplo n.º 1
0
        public static T ConvertModelToViewModel <T>(this IInt64Key input) where T : BaseViewModel, new()
        {
            var result = new T();

            result.SetViewModel(input);
            return(result);
        }
Exemplo n.º 2
0
 public Task UpdateAsync(Type type, IInt64Key input)
 {
     return(Task.Run(() =>
     {
         UpdateAsync(type, input);
     }));
 }
Exemplo n.º 3
0
 public Task CreateAsync(IInt64Key model, ISave repo)
 {
     return(Task.Run(() =>
     {
         Create(model, repo);
     }));
 }
Exemplo n.º 4
0
 public virtual void SetViewModel(IInt64Key model = null)
 {
     if (model != null)
     {
         var type = model.GetType().GetRealType();
         FullType     = type.FullName;
         ThisAssembly = type.Assembly.FullName;
         model.SetObjectByObject(this);
     }
 }
Exemplo n.º 5
0
        public static void Create(this IInt64Key model, ISave repo)
        {
            var type      = model.GetType().GetRealType();
            var repoType  = repo.GetType();
            var addMethod = repo.GetMethod(type, "Add", out object p);

            if (addMethod != null)
            {
                try
                {
                    addMethod.Invoke(p, new object[1] {
                        model
                    });
                    repo.SaveChanges();
                }
                catch
                {
                }
            }
        }
Exemplo n.º 6
0
 public virtual object ConvertToModel(IInt64Key model = null)
 {
     if (model == null)
     {
         var type = Type.GetType($"{FullType},{ThisAssembly}");
         if (type == null)
         {
             return(null);
         }
         model = Activator.CreateInstance(type) as IInt64Key;
     }
     else
     {
         if (model.Id != this.Id)
         {
             return(null);
         }
     }
     this.SetObjectByObject(model);
     return(model);
 }
Exemplo n.º 7
0
        public virtual void Create(IInt64Key model, ISave repo)
        {
            if (model == null || repo == null)
            {
                return;
            }
            var type      = model.GetType().GetRealType();
            var repoType  = repo.GetType();
            var addMethod = repo.GetMethod(type, "Add", out object p);

            if (addMethod != null)
            {
                try
                {
                    addMethod.Invoke(p, new object[1] {
                        model
                    });
                    repo.SaveChanges();
                }
                catch
                {
                }
            }
        }
Exemplo n.º 8
0
        public void Update(Type type, IInt64Key input)
        {
            var model = Find(type, input.Id, out ISave db);

            setUpdate(db, type, model, input);
        }