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

            return(IA);
        }
        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
            {
            }
        }
Exemple #3
0
 public BookController(IBook book, IAuthor author, IGenre genre, UserManager <ApplicationUser> userManager)
 {
     _book        = book;
     _author      = author;
     _genre       = genre;
     _userManager = userManager;
 }
Exemple #4
0
        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);
        }
Exemple #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>();
 }
Exemple #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;
 }
Exemple #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);
        }
 public GraphQLController(GraphSchema schema, AuthorSubscription author, IAuthor authorDetails)
 {
     _schema             = schema;
     _authorsubscription = author;
     _authorDetails      = authorDetails;
     //_schema.AddSubscription(author);
 }
Exemple #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
 };
Exemple #10
0
 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:
 }
Exemple #11
0
 internal EasySearchAttribute(IAuthor config)
     : this()
 {
     RegName     = config.Convert <IRegName>().RegName;
     Author      = config.Author;
     Description = config.Description;
     CreateDate  = config.CreateDate;
 }
Exemple #12
0
 public AuthorController(IAuthor _service)
 {
     this._service = _service;
     author        = new AuthorPagination
                     (
         () => { return(_service.ListAll().OrderBy(x => x.Id)); }
                     );
 }
 public CategoryController(ICategory category, IMapper mapper, IMongoTagCategoryAssigment categoryAssigment, IBooks book, IAuthor author)
 {
     _category          = category;
     _mapper            = mapper;
     _categoryAssigment = categoryAssigment;
     _book   = book;
     _author = author;
 }
Exemple #14
0
 public Author(IAuthor author)
 {
     Id        = author.Id;
     FirstName = author.FirstName;
     LastName  = author.LastName;
     NickName  = author.NickName;
     Books     = author.Books.ToList();
 }
Exemple #15
0
 public void Add(IAuthor author)
 {
     if (author is Author)
     {
         _unitOfWork.Add <Author>(author as Author);
         _unitOfWork.Commit();
     }
 }
Exemple #16
0
        public AuthorType(IAuthor author)
        {
            Id     = author.Id;
            BookId = author.BookId;

            FirstName = author.FirstName;
            LastName  = author.LastName;
        }
Exemple #17
0
 public Book(IBookService bookService, MyBooksContext context, ICategory category, IAuthor author, IPublisher publisher)
 {
     _bookService = bookService;
     _context     = context;
     _category    = category;
     _author      = author;
     _publisher   = publisher;
 }
Exemple #18
0
 public void Update(IAuthor author)
 {
     if (author is Author)
     {
         _unitOfWork.Update <Author>(author as Author);
         _unitOfWork.Commit();
     }
 }
        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);
        }
Exemple #20
0
        /// <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;
        }
Exemple #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());
        }
Exemple #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);
                }
            }
Exemple #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);
        }
Exemple #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 },
     });
 }
Exemple #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);
Exemple #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;
        }
Exemple #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());
        }
 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;
 }
Exemple #29
0
 public virtual void SetEditor(IAuthor editor)
 {
     if (editor == null)
     {
         throw new ArgumentNullException(nameof(editor));
     }
     this.LastEdited   = DateTime.UtcNow;
     this.LastEditedBy = editor;
     this.EditorSet    = true;
 }
        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() }));
        }
Exemple #31
0
		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>();
		}
        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);
            }
        }
        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);
            }
        }
Exemple #34
0
		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) { }
Exemple #35
0
		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) { }
Exemple #36
0
 // Static method computing FullName computed property for an Author
 public static string GetFullName(IAuthor author)
 {
     return author.FirstName + " " + author.LastName;
 }
Exemple #37
0
 public GitProvider(IAuthor author)
     : this()
 {
     Identity = author;
 }
Exemple #38
0
 public GitProvider(IAuthor author, CredentialsProvider credentials)
     : this(author)
 {
     Credentials = credentials;
 }
Exemple #39
0
 public Changeset(IAuthor author, object identifier)
 {
     Author = author;
     Identifier = identifier;
 }
        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;
        }
Exemple #41
0
 public Author(IAuthor aAuthor)
     : this(aAuthor.FirstName, aAuthor.LastName, aAuthor.Genre, aAuthor.Born)
 {
     Id = aAuthor.Id;
 }