// TODO what if target null? public virtual IViewModel <T, long> Update(BaseInputModel <T, long> input) { Auth.AuthorizeUpdate(); Logger.Information($"Updating {typeof(T).FullName} Id:{input.Id}."); Validator.Validate(input); var existingObj = Repo.FindOne(Specs.ById <T>(input.Id).And(Auth.GenerateFilterUpdate()), track: true); Mapper.Map(input, existingObj); Repo.Save(); Logger.Information($"Update of {typeof(T).FullName} Id:{input.Id} complete."); return(Mapper.Map <IViewModel <T> >(existingObj)); }
public virtual IViewModel <T, long> Get(long id) => Get(Specs.ById <T>(id));
/// <summary> /// Deletes the item with the given id and returns it. /// If null is returned, no item was found. /// </summary> /// <param name="id">The id of the item to delete.</param> /// <returns>The item deleted, or null, if not found.</returns> public virtual IViewModel <T, long> Delete(long id) => Delete(Specs.ById <T>(id));