protected override void Execute(NativeActivityContext context) { var pModel = new PackageModel(); pModel.Id = PackageId.Get(context); pModel.Description = Description.Get(context); pModel.Version = Models.PackageModel.CreateFullVersionFromMajorMinor(MajorVersion.Get(context), MinorVersion.Get(context)); pModel.Authors = Authors.Get(context); pModel.Owners = Owners.Get(context); pModel.LicenseUrl = LicenseUrl.Get(context); pModel.ProjectUrl = ProjectUrl.Get(context); pModel.IconUrl = IconUrl.Get(context); pModel.RequireLicenseAcceptance = RequireLicenseAcceptance.Get(context); pModel.ReleaseNotes = ReleaseNotes.Get(context); pModel.Copyright = Copyright.Get(context); pModel.Tags = Tags.Get(context); pModel.DirectorySet = DirectorySet.Get(context); pModel.ModelsAssemblyGuid = ModelsAssemblyGuid.Get(context) ?? Guid.NewGuid().ToString(); pModel.ActivitiesAssemblyGuid = ActivitiesAssemblyGuid.Get(context) ?? Guid.NewGuid().ToString(); this.PackageModel.Set(context, pModel); context.Properties.Add("PackageModel", pModel); context.ScheduleActivity(this.Body); }
public void GetAuthorTest() { // act var repo = new Authors(_mockContext.Object); var obj = repo.Get(0); // assert Assert.AreEqual(_authorList.ToList()[0].Name, obj.Name); }
public BookModel GetBook(long id) { var book = Books.GetById(id); var pubHouse = book.PubHouseId.HasValue ? PubHouses.GetById(book.PubHouseId.Value) : null; var authors = Authors.Get() .Join(BookAuthors.Get().Where(q => q.BookId == book.BookId), a => a.AuthorId, ba => ba.AuthorId, (a, ba) => a).ToList(); var bookModel = new BookModel(book, authors, pubHouse); return(bookModel); }
protected override PackageModel Execute(CodeActivityContext context) { var pModel = new PackageModel(); pModel.Id = PackageId.Get(context); pModel.Description = Description.Get(context); pModel.Version = Version.Get(context); pModel.Authors = Authors.Get(context); pModel.Owners = Owners.Get(context); pModel.LicenseUrl = LicenseUrl.Get(context); pModel.ProjectUrl = ProjectUrl.Get(context); pModel.IconUrl = IconUrl.Get(context); pModel.RequireLicenseAcceptance = RequireLicenseAcceptance.Get(context); pModel.ReleaseNotes = ReleaseNotes.Get(context); pModel.Copyright = Copyright.Get(context); pModel.Tags = Tags.Get(context); pModel.DirectorySet = DirectorySet.Get(context); pModel.ModelsAssemblyGuid = ModelsAssemblyGuid.Get(context); pModel.ActivitiesAssemblyGuid = ActivitiesAssemblyGuid.Get(context); return(pModel); }
public IEnumerable <Author> GetAuthors() { return(Authors.Get()); }
public IEnumerable <BookModel> GetBooks() { var books = Books.Get()?.ToList(); if (books == null || !books.Any()) { return(Enumerable.Empty <BookModel>().ToList()); } var pubHouseIds = books.Select(t => t.PubHouseId); var pubHouses = PubHouses.Get().Where(t => pubHouseIds.Contains(t.PubHouseId)); var bookIds = books.Select(t => t.BookId); var authors = BookAuthors.Get().Where(t => bookIds.Contains(t.BookId)).Join(Authors.Get(), ba => ba.AuthorId, a => a.AuthorId, (ba, a) => new { ba.BookId, author = a }); var list = new List <BookModel>(); books.ForEach(t => { var thisBookAuthors = authors.Where(a => a.BookId == t.BookId).Select(q => q.author).ToList(); var pubHouse = pubHouses.SingleOrDefault(p => p.PubHouseId == t.PubHouseId); list.Add(new BookModel(t, thisBookAuthors, pubHouse)); }); return(list); }