public async Task <Guid> Community(string name, KeysPair keys) { var exist = communities.SingleOrDefault(o => o.Name == name); if (exist != null) { return(exist.Id); } var community = new Community { Id = Guid.NewGuid(), Name = name, CreateAt = DateTimeOffset.Now, Address = keys.PublicKey }; var signer = new Signer(service); signer.Sign(community, keys); await publisher.Add(community); communities.Add(community); return(community.Id); }
public async Task <BookModel> Add(BookModel book) { if (book == null) { return(null); } if (book.Id > 0) { return(book); } try { if (book.Categories != null) { foreach (BookCategoryModel category in book.Categories) { await _category.Add(category); } } if (book.Authors != null) { foreach (AuthorModel author in book.Authors) { await _author.Add(author); } } if (book.Publisher != null) { await _publisher.Add(book.Publisher); } _context.Add(book); await _context.SaveChangesAsync(); return(book); } catch (Exception ex) { string message = ex.Message; return(null); } }
/// <summary> /// Adds the assembly. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pipeline">The pipeline.</param> /// <param name="assembly">The assembly.</param> /// <param name="predicate">The predicate.</param> /// <returns>IPublisher<T>.</returns> public static IPublisher <T> AddAssembly <T>( this IPublisher <T> pipeline, Assembly assembly, Func <Type, bool> predicate) { var filterTypes = _publisherTypes.GetOrAdd(Tuple.Create(assembly.FullName, typeof(T).FullName), q => assembly .GetTypes() .Where(t => typeof(IActionFilter <T>).IsAssignableFrom(t)) .Where(predicate) .OrderBy(t => (((FilterOrderAttribute)Attribute.GetCustomAttribute(t, typeof(FilterOrderAttribute)))?.Order).GetValueOrDefault()) .ToList()); foreach (var filterType in filterTypes) { pipeline = pipeline.Add(filterType); } return(pipeline); }
/// <summary> /// Finallies the specified action. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pipeline">The pipeline.</param> /// <param name="action">The action.</param> /// <returns>IPublisher<T>.</returns> public static IPublisher <T> Finally <T>(this IPublisher <T> pipeline, Action <T> action) { return(pipeline.Add(new ActionShortCircuit <T>(action))); }
public void Post([FromBody] Publisher publisher) { _publisher.Add(publisher); }
public void Post([FromBody] Publisher p) { _pub.Add(p); }
public void Subscribe(IPublisher publiser) { publiser.Add(this); }