public static T ConvertModelToViewModel <T>(this IInt64Key input) where T : BaseViewModel, new() { var result = new T(); result.SetViewModel(input); return(result); }
public Task UpdateAsync(Type type, IInt64Key input) { return(Task.Run(() => { UpdateAsync(type, input); })); }
public Task CreateAsync(IInt64Key model, ISave repo) { return(Task.Run(() => { Create(model, repo); })); }
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); } }
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 { } } }
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); }
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 { } } }
public void Update(Type type, IInt64Key input) { var model = Find(type, input.Id, out ISave db); setUpdate(db, type, model, input); }