コード例 #1
0
        //制作一个作者专区数据访问层的接口实例
        public static IAuthor CreateIAuthor()
        {
            string  typeName = path + ".AuthorAccess";
            IAuthor IA       = (IAuthor)Assembly.Load(path).CreateInstance(typeName);

            return(IA);
        }
コード例 #2
0
        private void btn_AddBook_Click(object sender, EventArgs e)
        {
            IList <string> categories = new List <string>();

            try
            {
                categories.Add(comboBoxCategiries.Text);
                if (authors == null || authors.Count <= 0)
                {
                    IAuthor author = (IAuthor)comboBoxAuthors.SelectedItem;
                    authors.Add(author);
                }
                if (authors.Count < 0)
                {
                    MessageBox.Show("Complete alld fields");
                }
                else if (pictureBoxISBN.Visible == true || pictureBoxBookTitle.Visible == true || pictureBoxCopies.Visible == true)
                {
                    MessageBox.Show("Complete all fields");
                }
                else
                {
                    addBookPresenter.AddBook(textBox_ISBN.Text, textBox_BookTitle.Text, textBox_Copies.Text, textBox_Publisher.Text, dateTimePicker1.Value, authors, categories);
                    addBookPresenter.AddCover(pictureBoxCover.Image, textBox_ISBN.Text);
                }
            }
            catch
            {
            }
        }
コード例 #3
0
 public BookController(IBook book, IAuthor author, IGenre genre, UserManager <ApplicationUser> userManager)
 {
     _book        = book;
     _author      = author;
     _genre       = genre;
     _userManager = userManager;
 }
コード例 #4
0
ファイル: Schema.cs プロジェクト: baskarmib/CodeCamp2019
        public GraphSchema(IAuthor authorContent)
        {
            //this._author = new AuthorDetails();
            this._author = authorContent;
            this._schema = Schema.For(@"
          type Book {
            id: ID
            name: String,
            genre: String,
            published: Date,
            Author: Author
          }

          type Author {
            id: ID,
            name: String,
            books: [Book]
          }
          
          type Query {
              books: [Book],
              author(id: ID): Author,
              authors: [Author],
              hello: String,
              messages: [MessageType]
          }
      ", _ =>
            {
                _.Types.Include <Query>();
            });
            //This is needed.
            Query        = this._schema.Query;
            Mutation     = new AuthorMutation(authorContent);
            Subscription = new AuthorSubscription(authorContent);
        }
コード例 #5
0
 //private ICollection<AppFileModel> _appFiles;
 //private ICollection<AppFileModel> _thumbnail;
 public BookModel()
 {
     _appFile   = new EFAppFile();
     _publisher = new EFPublisher();
     _author    = new EFAuthor();
     _mapper    = DIManager.Instance.Provider.GetService <IMapper>();
 }
コード例 #6
0
 public BookController(
     [FromServices] IUnitOfWork uow,
     [FromServices] IMapper mapper,
     [FromServices] ILibraryBook libraryBookMananger,
     [FromServices] IBook bookMananger,
     [FromServices] IContact contactMananger,
     [FromServices] ILibrary libraryMananger,
     [FromServices] IType typeMananger,
     [FromServices] IHttpContextAccessor httpContextAccessor,
     [FromServices] IUser userMananger,
     [FromServices] IAuthor authorMananger,
     [FromServices] ICategory categoryMananger
     )
 {
     _uow    = uow;
     _mapper = mapper;
     _libraryBookMananger = libraryBookMananger;
     _bookMananger        = bookMananger;
     _contactMananger     = contactMananger;
     _libraryMananger     = libraryMananger;
     _typeMananger        = typeMananger;
     _httpContext         = httpContextAccessor.HttpContext;
     _userMananger        = userMananger;
     _authorMananger      = authorMananger;
     _categoryMananger    = categoryMananger;
 }
コード例 #7
0
        public IBook CreateBook(string bookType, long isbn, string title, IAuthor author, string bookGenre, int yearPublished, int length)
        {
            IBook book = null;

            Assembly assembly = Assembly.GetExecutingAssembly();

            Type model = assembly
                         .GetTypes()
                         .FirstOrDefault(t => t.Name == bookType + bookTypesSuffix);

            if (model == null)
            {
                throw new ArgumentException(OutputMessages.InvalidTypeOfBook);
            }

            try
            {
                book = (IBook)Activator.CreateInstance(model, new object[] { isbn, title, author, bookGenre, yearPublished, length });
            }
            catch (TargetInvocationException tie)
            {
                throw new ArgumentException(tie.InnerException.Message);
            }

            return(book);
        }
コード例 #8
0
 public GraphQLController(GraphSchema schema, AuthorSubscription author, IAuthor authorDetails)
 {
     _schema             = schema;
     _authorsubscription = author;
     _authorDetails      = authorDetails;
     //_schema.AddSubscription(author);
 }
コード例 #9
0
 public static AuthorEntity Create(IAuthor author) => new AuthorEntity
 {
     PartitionKey = GeneratePartitionKey(),
     RowKey       = string.IsNullOrEmpty(author.Id) ? Guid.NewGuid().ToString() : author.Id,
     Name         = author.Name,
     LastName     = author.LastName
 };
コード例 #10
0
ファイル: ContentHolder.cs プロジェクト: danieldc/NForum
 public ContentHolder(String subject, String content, IAuthor author) : base()
 {
     this.Subject = subject;
     this.Content = content;
     this.Created = this.LastEdited = DateTime.UtcNow;
     //this.CreatedBy = this.LastEditedBy
     // TODO:
 }
コード例 #11
0
 internal EasySearchAttribute(IAuthor config)
     : this()
 {
     RegName     = config.Convert <IRegName>().RegName;
     Author      = config.Author;
     Description = config.Description;
     CreateDate  = config.CreateDate;
 }
コード例 #12
0
 public AuthorController(IAuthor _service)
 {
     this._service = _service;
     author        = new AuthorPagination
                     (
         () => { return(_service.ListAll().OrderBy(x => x.Id)); }
                     );
 }
コード例 #13
0
 public CategoryController(ICategory category, IMapper mapper, IMongoTagCategoryAssigment categoryAssigment, IBooks book, IAuthor author)
 {
     _category          = category;
     _mapper            = mapper;
     _categoryAssigment = categoryAssigment;
     _book   = book;
     _author = author;
 }
コード例 #14
0
 public Author(IAuthor author)
 {
     Id        = author.Id;
     FirstName = author.FirstName;
     LastName  = author.LastName;
     NickName  = author.NickName;
     Books     = author.Books.ToList();
 }
コード例 #15
0
 public void Add(IAuthor author)
 {
     if (author is Author)
     {
         _unitOfWork.Add <Author>(author as Author);
         _unitOfWork.Commit();
     }
 }
コード例 #16
0
        public AuthorType(IAuthor author)
        {
            Id     = author.Id;
            BookId = author.BookId;

            FirstName = author.FirstName;
            LastName  = author.LastName;
        }
コード例 #17
0
ファイル: Book.cs プロジェクト: danielgbodon/mybooksdemo
 public Book(IBookService bookService, MyBooksContext context, ICategory category, IAuthor author, IPublisher publisher)
 {
     _bookService = bookService;
     _context     = context;
     _category    = category;
     _author      = author;
     _publisher   = publisher;
 }
コード例 #18
0
 public void Update(IAuthor author)
 {
     if (author is Author)
     {
         _unitOfWork.Update <Author>(author as Author);
         _unitOfWork.Commit();
     }
 }
コード例 #19
0
        public void AddNewAuthor(string authorName, string id)
        {
            int     number;
            bool    idvalid = int.TryParse(id, out number);
            IAuthor author  = factory.Create(authorName, number);

            libraryPresenter.Container.authors.Add(author);
        }
コード例 #20
0
ファイル: Article.cs プロジェクト: Kazpers/ArticleApi
        /// <summary>
        /// Use this to create a new instance of the class
        /// </summary>
        /// <param name="author"></param>
        /// <param name="topic"></param>
        /// <param name="body"></param>
        /// <param name="year"></param>
        public Article(IAuthor author, string topic, string body, int year)
        {
            Id = Guid.NewGuid().ToString();

            Author      = author;
            Topic       = topic;
            ArticleBody = body;
            Year        = year;
        }
コード例 #21
0
        public void AddAuthorNullTest()
        {
            Repository sut      = new(Data.Factory.CreateObject <Data.Core.IDataContext>());
            IAuthor    returned = sut.AddAuthor(null);

            Assert.Null(returned);
            Assert.Empty(sut.GetAuthors());
            Assert.Empty(sut.GetBooks());
        }
コード例 #22
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IAuthor authorsCasted = item.As <IAuthor>();

                if ((authorsCasted != null))
                {
                    this._parent.Authors.Add(authorsCasted);
                }
            }
コード例 #23
0
        public void GetAuthorByIdTest()
        {
            int        id     = 2;
            Repository sut    = new(Data.Factory.GetExampleContext());
            IAuthor    author = sut.GetAuthorById(id);

            Assert.NotNull(author);
            Assert.Equal(id, author.Id);
        }
コード例 #24
0
 private static Dictionary <string, object> AuthorToAttributes(IAuthor author)
 {
     return(new Dictionary <string, object>()
     {
         { "Author_ID", author.ID.ToString() },
         { "Name", author.Name },
         { "Surname", author.Surname },
     });
 }
コード例 #25
0
        public Shared.Logic.WebModel.IAuthor GetAuthorById(int id)
        {
            IAuthor author = _dataContext.Authors.FirstOrDefault(a => a.Id == id);

            if (author != null)
            {
                return(Factory.MapEntityToWebModel(author) as Shared.Logic.WebModel.IAuthor);
            }
            return(default);
コード例 #26
0
        public CodeTableAttribute(IAuthor config)
            : this()
        {
            TkDebug.AssertArgumentNull(config, "config", this);

            RegName     = config.Convert <IRegName>().RegName;
            Author      = config.Author;
            Description = config.Description;
            CreateDate  = config.CreateDate;
        }
コード例 #27
0
        public void AddExistingAuthorTest()
        {
            Repository       sut    = new(Data.Factory.GetExampleContext());
            AuthorTestObject author = new() { Id = 2 };
            int     authorCount     = sut.GetAuthors().Count();
            IAuthor returned        = sut.AddAuthor(author);

            Assert.Same(author, returned);
            Assert.Equal(authorCount, sut.GetAuthors().Count());
        }
コード例 #28
0
 protected Book(string bookType, long isbn, string title, IAuthor author, string bookGenre, int yearPublished, int length)
 {
     this.BookType      = bookType;
     this.ISBN          = isbn;
     this.Title         = title;
     this.Author        = author;
     this.BookGenre     = this.validateBookGenre(bookGenre);
     this.YearPublished = yearPublished;
     this.Length        = length;
 }
コード例 #29
0
ファイル: ContentHolder.cs プロジェクト: danieldc/NForum
 public virtual void SetEditor(IAuthor editor)
 {
     if (editor == null)
     {
         throw new ArgumentNullException(nameof(editor));
     }
     this.LastEdited   = DateTime.UtcNow;
     this.LastEditedBy = editor;
     this.EditorSet    = true;
 }
コード例 #30
0
        public string GetAvatarUrl(IAuthor one)
        {
            var avatar        = one.GetAvatar();
            var generatorType = typeof(IUserAvatarUrlGenerator <>).MakeGenericType(avatar.GetType());

            var generator      = _services.GetService(generatorType);
            var generateMethod = generator.GetType().GetMethod(nameof(DefaultAvatarUrlGenerator.GetUserAvatarUrl));

            return((string)generateMethod.Invoke(generator, new object[] { one.GetAvatar() }));
        }
コード例 #31
0
ファイル: Feed.cs プロジェクト: aelveborn/njupiter
		public Feed(string title, string id, Uri uri, Uri feedUri, string description, DateTime publishDate, string language, IFeedImage image, IFeedItem[] items, IAuthor author, Dictionary<XmlQualifiedName, string> customElements) {
			if(title == null) {
				throw new ArgumentNullException("title");
			}
			if(uri == null) {
				throw new ArgumentNullException("uri");
			}
			this.title = title;
			this.uri = uri;
			this.feedUri = feedUri ?? uri; //Feed Uri is mandatory if the feed shall be 100% standard compliant. But some older implementations does not have such value and therefor we accept null at the moment, shall probably be removed and cast an exeption. Maybe changed later.
			this.description = description;
			this.publishDate = publishDate;
			this.language = language;
			this.image = image;
			this.items = items;
			this.author = author;
			this.id = !string.IsNullOrEmpty(id) ? id : uri.AbsoluteUri;
			this.customElements = customElements ?? new Dictionary<XmlQualifiedName, string>();
		}
コード例 #32
0
        private static void EnsureBlogPostGroupExists(string groupKey, IAuthor author, ICommentService cs)
        {
            GroupFilter groupFilter = new GroupFilter();
            groupFilter.GroupKey.Add(groupKey);
            var group = cs.GetGroups(groupFilter).SingleOrDefault();

            if (group == null)
            {
                var groupProxy = new GroupProxy("Group title", "blog posts in provider", author) { Key = groupKey };
                group = cs.CreateGroup(groupProxy);
            }
        }
コード例 #33
0
        private static void EnsureBlogPostThreadExists(string threadKey, IAuthor author, string threadTitle, BlogsManager manager, string language, ICommentService cs)
        {
            ThreadFilter threadFilter = new ThreadFilter();
            threadFilter.ThreadKey.Add(threadKey);
            var thread = cs.GetThreads(threadFilter).SingleOrDefault();

            if (thread == null)
            {
                var groupKey = ControlUtilities.GetUniqueProviderKey(typeof(BlogsManager).FullName, manager.Provider.Name);

                EnsureBlogPostGroupExists(groupKey, author, cs);

                var threadProxy = new ThreadProxy(threadTitle, typeof(BlogPost).FullName, groupKey, author) { Language = language, Key = threadKey };
                thread = cs.CreateThread(threadProxy);
            }
        }
コード例 #34
0
ファイル: Feed.cs プロジェクト: aelveborn/njupiter
		public Feed(string title, string id, Uri uri, Uri feedUri, string description, DateTime publishDate, string language, IFeedImage image, IFeedItem[] items, IAuthor author) : this(title, id, uri, feedUri, description, publishDate, language, image, items, author, null) { }
コード例 #35
0
ファイル: Feed.cs プロジェクト: aelveborn/njupiter
		public Feed(string title, Guid id, Uri uri, Uri feedUri, string description, DateTime publishDate, string language, IFeedImage image, IFeedItem[] items, IAuthor author, Dictionary<XmlQualifiedName, string> customElements) : this(title, "urn:uuid:" + id, uri, feedUri, description, publishDate, language, image, items, author, customElements) { }
コード例 #36
0
ファイル: BooksModule.cs プロジェクト: yuanfei05/vita
 // Static method computing FullName computed property for an Author
 public static string GetFullName(IAuthor author)
 {
     return author.FirstName + " " + author.LastName;
 }
コード例 #37
0
ファイル: GitProvider.cs プロジェクト: pdelvo/virtue-1
 public GitProvider(IAuthor author)
     : this()
 {
     Identity = author;
 }
コード例 #38
0
ファイル: GitProvider.cs プロジェクト: pdelvo/virtue-1
 public GitProvider(IAuthor author, CredentialsProvider credentials)
     : this(author)
 {
     Credentials = credentials;
 }
コード例 #39
0
ファイル: Changeset.cs プロジェクト: pdelvo/virtue-1
 public Changeset(IAuthor author, object identifier)
 {
     Author = author;
     Identifier = identifier;
 }
コード例 #40
0
        private CommentResponse SubmitCommentInternal(CommentCreateRequest commentData, IThread thread, IAuthor author)
        {
            var cs = SystemManager.GetCommentsService();
            var currentConfig = CommentsUtilitiesReflector.GetThreadConfigByType(thread.Type, thread.Key);

            if (currentConfig.RequiresAuthentication)
            {
                if (author.Key.IsNullOrWhitespace() || author.Key == Guid.Empty.ToString())
                {
                    throw new InvalidOperationException("Comment cannot be submitted at the moment. Please refresh the page and try again.");
                }
            }

            if (currentConfig.EnableRatings)
            {
                if (commentData.Rating == null)
                {
                    throw new InvalidOperationException("A message displayed when ratings are allowed and a comment is submitted without rating.");
                }

                if (CommentsUtilitiesReflector.GetCommentsByThreadForCurrentAuthorWithRating(thread.Key).Any())
                {
                    throw new InvalidOperationException("Only one comment with rating is allowed per user.");
                }
            }

            var authorIp = CommentsUtilitiesReflector.GetIpAddressFromCurrentRequest();
            var commentProxy = new CommentProxy(commentData.Message, thread.Key, author, authorIp, commentData.Rating);
            commentProxy.CustomData = commentData.CustomData;

            if (currentConfig.RequiresApproval)
                commentProxy.Status = StatusConstants.WaitingForApproval;
            else
                commentProxy.Status = StatusConstants.Published;

            IComment newComment = cs.CreateComment(commentProxy);

            var result = CommentsUtilitiesReflector.GetCommentResponse(newComment, ClaimsManager.GetCurrentIdentity().IsBackendUser);

            ServiceUtility.DisableCache();

            return result;
        }
コード例 #41
0
ファイル: Author.cs プロジェクト: Zigi34/SquirrelReaderDiary
 public Author(IAuthor aAuthor)
     : this(aAuthor.FirstName, aAuthor.LastName, aAuthor.Genre, aAuthor.Born)
 {
     Id = aAuthor.Id;
 }