コード例 #1
0
        // GET: Authors/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Authors authors = db.Authors.Find(id);

            if (authors == null)
            {
                return(HttpNotFound());
            }
            return(View(authors));
        }
コード例 #2
0
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         Authors authors = db.Authors.Find(id);
         db.Authors.Remove(authors);
         db.SaveChanges();
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Unable to save changes.");
     }
     return(RedirectToAction("Index"));
 }
コード例 #3
0
        private Authors FindAuthor(string selected)
        {
            Authors found = Authors.NoOverride;

            foreach (Authors author in Enum.GetValues(typeof(Authors)))
            {
                if (author.ToString() == selected)
                {
                    found = author;
                    break;
                }
            }
            return(found);
        }
コード例 #4
0
        // GET: Authors/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Authors authors = await db.Authors.FindAsync(id);

            if (authors == null)
            {
                return(HttpNotFound());
            }
            return(View(authors));
        }
コード例 #5
0
        public IHttpActionResult DeleteAuthors(int id)
        {
            Authors authors = db.Authors.Find(id);

            if (authors == null)
            {
                return(NotFound());
            }

            db.Authors.Remove(authors);
            db.SaveChanges();

            return(Ok(authors));
        }
コード例 #6
0
        public async Task <IActionResult> DeleteAuthor(int id)
        {
            Authors author = await _db.Authors.FindAsync(id);

            if (author == null)
            {
                return(NotFound());
            }

            _db.Authors.Remove(author);
            await _db.SaveChangesAsync();

            return(Ok(author));
        }
コード例 #7
0
        /// <summary>
        ///     Defines what happens when the page is navigated on.
        /// </summary>
        /// <param name="parameter">parameter.</param>
        /// <param name="mode">navigation mode.</param>
        /// <param name="state">state.</param>
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            //Deciding if the book is searched by id or name.
            int intParam = 0;

            if (int.TryParse(parameter.ToString(), out intParam))
            {
                var bookId  = (int)parameter;
                var service = new BookService();
                Book = await service.GetBookAsync(bookId);
            }
            else
            {
                var bookName = (string)parameter;
                var service  = new BookService();

                var booksList = await service.GetBookAsync(bookName);

                foreach (var item in booksList)
                {
                    Book = item;
                }
            }

            //If no such book is found, navigate the user to the not found page.
            if (Book == null)
            {
                NavigateToNotFoundPage();
                return;
            }

            //Fill the lists on the UI, transforming uris if needed.
            foreach (string authorName in Book.authors)
            {
                Authors.Add(new Author(authorName));
            }

            foreach (string characterUri in Book.characters)
            {
                TransformUriToCharacter(characterUri, Characters);
            }

            foreach (string characterUri in Book.povCharacters)
            {
                TransformUriToCharacter(characterUri, PoVCharacters);
            }

            await base.OnNavigatedToAsync(parameter, mode, state);
        }
コード例 #8
0
        private Manifest CreateManifest()
        {
            Manifest         manifest;
            ManifestMetadata manifestMetadata;

            if (!string.IsNullOrEmpty(InputFileName))
            {
                using (var stream = File.OpenRead(InputFileName))
                {
                    manifest = Manifest.ReadFrom(stream);
                }
                if (manifest.Metadata == null)
                {
                    manifest = new Manifest(new ManifestMetadata(), manifest.Files);
                }
            }
            else
            {
                manifest = new Manifest(new ManifestMetadata());
            }


            manifestMetadata = manifest.Metadata;

            manifestMetadata.UpdateMember(x => x.Authors, Authors?.Split(';'));
            manifestMetadata.UpdateMember(x => x.Copyright, Copyright);
            manifestMetadata.UpdateMember(x => x.DependencySets, GetDependencySets());
            manifestMetadata.UpdateMember(x => x.Description, Description);
            manifestMetadata.DevelopmentDependency |= DevelopmentDependency;
            manifestMetadata.UpdateMember(x => x.FrameworkAssemblies, GetFrameworkAssemblies());
            manifestMetadata.UpdateMember(x => x.IconUrl, IconUrl != null ? new Uri(IconUrl) : null);
            manifestMetadata.UpdateMember(x => x.Id, Id);
            manifestMetadata.UpdateMember(x => x.Language, Language);
            manifestMetadata.UpdateMember(x => x.LicenseUrl, new Uri(LicenseUrl));
            manifestMetadata.UpdateMember(x => x.MinClientVersionString, MinClientVersion);
            manifestMetadata.UpdateMember(x => x.Owners, Owners?.Split(';'));
            manifestMetadata.UpdateMember(x => x.ProjectUrl, ProjectUrl != null ? new Uri(ProjectUrl) : null);
            manifestMetadata.AddRangeToMember(x => x.PackageAssemblyReferences, GetReferenceSets());
            manifestMetadata.UpdateMember(x => x.ReleaseNotes, ReleaseNotes);
            manifestMetadata.RequireLicenseAcceptance |= RequireLicenseAcceptance;
            manifestMetadata.UpdateMember(x => x.Summary, Summary);
            manifestMetadata.UpdateMember(x => x.Tags, Tags);
            manifestMetadata.UpdateMember(x => x.Title, Title);
            manifestMetadata.UpdateMember(x => x.Version, Version != null ? new NuGetVersion(Version) : null);

            manifest.AddRangeToMember(x => x.Files, GetManifestFiles());

            return(manifest);
        }
コード例 #9
0
ファイル: AuthorsDAL.cs プロジェクト: IgleOA/WebSite_IgleOA
        public List <Authors> AuthorList()
        {
            List <Authors> List = new List <Authors>();

            try
            {
                using (var SqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["DB_MDA_CR_OA_Connection"].ToString()))
                {
                    SqlCon.Open();
                    var SqlCmd = new SqlCommand("[music].[uspReadAuthors]", SqlCon)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    using (var dr = SqlCmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            var author = new Authors
                            {
                                AuthorID    = Convert.ToInt32(dr["AuthorID"]),
                                AuthorName  = dr["AuthorName"].ToString(),
                                ProfileLink = "\"" + dr["ProfileLink"].ToString() + "\""
                            };

                            if (author.ProfileLink.Length > 2)
                            {
                                author.ActiveLink = true;
                            }
                            else
                            {
                                author.ActiveLink = false;
                            }

                            List.Add(author);
                        }
                    }
                    if (SqlCon.State == ConnectionState.Open)
                    {
                        SqlCon.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(List);
        }
コード例 #10
0
        public Authors Add(Authors author)
        {
            if (author.FirstName.Length < 2 || author.FirstName.Length > 16 || author.LastName.Length < 2 || author.LastName.Length > 16)
            {
                throw new FormatException("The values for some or all of the entity fields do not meet the minimum or maximum length requirements");
            }

            else
            {
                bool isUnique = true;
                foreach (var a in booksAuthorsContext.Authors.Local)
                {
                    if (author.FirstName == a.FirstName && author.LastName == a.LastName && a.Id != author.Id)
                    {
                        isUnique = false;
                        break;
                    }
                }

                if (isUnique)
                {
                    foreach (var a in booksAuthorsContext.Authors)
                    {
                        if (author.FirstName == a.FirstName && author.LastName == a.LastName && a.Id != author.Id)
                        {
                            isUnique = false;
                            break;
                        }
                    }
                }

                else
                {
                    throw new InvalidOperationException("There are duplicate entries");
                }

                if (isUnique)
                {
                    author.Id = booksAuthorsContext.Authors.Local.Last().Id + 1;
                    booksAuthorsContext.Authors.Add(author);
                    return(author);
                }

                else
                {
                    throw new InvalidOperationException("There are duplicate entries");
                }
            }
        }
コード例 #11
0
        public ActionResult Edit([Bind(Include = "AuthorID,FirstName,LastName,Description,Image,Created,Modified")] Authors authors)
        {
            if (ModelState.IsValid)
            {
                var ticks = DateTime.Now.Ticks;
                //authors.Modified = ticks;
                DateTime date         = new DateTime(ticks, DateTimeKind.Local);
                var      AuthorFromDb = db.Authors.Find(authors.AuthorID);
                AuthorFromDb.Modified = ticks;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(authors));
        }
コード例 #12
0
        public IActionResult InsertAuthors([FromBody] Authors authors)
        {
            try
            {
                AuthorsService authorsservice = new AuthorsService();

                authorsservice.AddAuthors(authors);

                return(Ok());
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #13
0
ファイル: Book.cs プロジェクト: munrad/epamtrain
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Isbn != null ? Isbn.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Authors != null ? Authors.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PubCity != null ? PubCity.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PubName != null ? PubName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ PubYear.GetHashCode();
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Note != null ? Note.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CountPages;
         return(hashCode);
     }
 }
コード例 #14
0
 private void bLoad_Click(object sender, RoutedEventArgs e)
 {
     EfContext context = new EfContext();
     var       music   = context.Musics.AsQueryable();
     Genre     g       = new Genre()
     {
     };
     Authors a    = new Authors();
     var     list = music.Select(t => new MusicModel()
     {
         Name  = t.Name,
         Price = t.Price,
         Genre =
             //Authors=a.Name
     }).ToList();
コード例 #15
0
    static void Main()
    {
        Authors authors = new Authors();

        authors.Add(new Person("James"));
        authors.Add(new Person("Roger"));
        authors.Add(new Person("Ben"));
        authors.Add(new Person("Richard"));
        authors.Add(new Person("Teun"));

        for (int i = 0; i < authors.Count; i++)
        {
            Console.WriteLine(authors[i].Name);
        }
    }
コード例 #16
0
ファイル: AuthorManager.cs プロジェクト: war-man/DATN-DAT
        public async Task <Authors> Create(Authors inputModel)
        {
            try
            {
                var result = await _unitOfWork.AuthorsRepository.Add(inputModel);

                await _unitOfWork.SaveChange();

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public IActionResult Post([FromBody] Authors author)
        {
            if (author is null)
            {
                return(BadRequest("Author is null."));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            _dataRepository.Add(author);
            return(CreatedAtRoute("GetById", new { Id = author.IdAuthor }, null));
        }
コード例 #18
0
        public async Task <IActionResult> Edit(int id, Authors authors)
        {
            if (id != authors.ID)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                _db.Update(authors);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(authors));
        }
コード例 #19
0
        public async Task <Author> getbyid(int id)
        {
            Author author = null;

            try
            {
                _objauthor = new Authors();
                author     = await _objauthor.getbyid(id);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(author);
        }
コード例 #20
0
        public async Task <List <Author> > getall()
        {
            List <Author> authors = null;

            try
            {
                _objauthor = new Authors();
                authors    = await _objauthor.getall();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(authors);
        }
コード例 #21
0
ファイル: Book.cs プロジェクト: Sistely/SWII
        public string getAuthorNames()
        {
            string aux = "";

            foreach (Author a in Authors)
            {
                aux += a.Name;

                if (a != Authors.Last())
                {
                    aux += ",";
                }
            }
            return(aux);
        }
コード例 #22
0
ファイル: AuthorManager.cs プロジェクト: war-man/DATN-DAT
        public async Task Update(Authors inputModel)
        {
            try
            {
                await _unitOfWork.AuthorsRepository.Update(inputModel);

                await _unitOfWork.SaveChange();
            }
            catch (Exception ex)
            {
                await _unitOfWork.Rollback();

                throw ex;
            }
        }
コード例 #23
0
        public void AddBooks()
        {
            var author = Authors.First();

            Books.AddRange(Enumerable.Range(0, 1000).Select(x => new Book
            {
                Title       = $"Book {x}",
                PageCount   = x,
                Author      = author,
                IsAvailable = true,
                Description = "Auto generated Book"
            }));

            SaveChanges();
        }
コード例 #24
0
        public IActionResult Create([FromBody] CreateAuthorVm model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var author = new Authors()
            {
                AuthorName       = model.AuthorName,
                BriefDescription = model.BriefDescription
            };

            _authoRepo.CreateAuthor(author);
            return(CreatedAtAction(nameof(GetAuthor), new { authorId = author.Id }, model));
        }
コード例 #25
0
 public AuthorsMaster(ISubject <object> interaction)
 {
     interaction.OfType <AuthorChanged>()
     .Subscribe(x => {
         var author       = Authors.First(y => y.Id == x.Author.Id);
         author.Name      = x.Author.Name;
         author.Birthday  = x.Author.Birthday;
         author.Gender    = x.Author.Gender;
         author.IsChecked = x.Author.IsChecked;
         author.Books     = x.Author.Books;
     });
     this.Authors         = new ObservableCollection <Author>();
     this.Genders         = (GenderType[])Enum.GetValues(typeof(GenderType));
     this.IsCheckedHeader = false;
 }
コード例 #26
0
 IEnumerable <ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
 {
     if (!CheckISBN())
     {
         yield return(new ValidationResult(
                          "Задан не корректный ISBN",
                          new[] { nameof(ISBN) }));
     }
     if (Authors == null || !Authors.Any())
     {
         yield return(new ValidationResult(
                          "У книги должен быть как минимум один автор",
                          new[] { nameof(Authors) }));
     }
 }
コード例 #27
0
        /// <summary>
        /// This method seach author in the library by name.
        /// If there is not entered name in library method adds new author to the library with entered name.
        /// </summary>
        /// <param name="authorName">author name</param>
        /// <returns>returns author</returns>
        private Author GetAuthor(string authorName)
        {
            foreach (Author a in Authors)
            {
                if (a.Name == authorName)
                {
                    return(a);
                }
            }
            Author author = new Author(authorName);

            Authors.Add(author);
            authorsDao.Save(Authors);
            return(author);
        }
コード例 #28
0
        public static ICollection <Model.Author> GetAuthors(Authors author)
        {
            var result = new List <Model.Author>();

            if (author != null)
            {
                author.Author.ForEach(a =>
                {
                    var dbAuthor = GetAuthor(a.Name);
                    result.Add(dbAuthor);
                });
            }

            return(result);
        }
コード例 #29
0
ファイル: Details.cshtml.cs プロジェクト: Robin093/BooksApp
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Authors = await _context.Authors.FirstOrDefaultAsync(m => m.AuthorId == id);

            if (Authors == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AuthorAddLink.NavigateUrl = AddAuthorUrl;
            if (!IsPostBack)
            {
                DataTable dt = DatabaseHelper.Retrieve(@"
                    select Id, FirstName, LastName
                    from Author
                    order by LastName, FirstName
                ");

                Authors.DataSource = dt.Rows;
                Authors.DataBind();
            }
        }
コード例 #31
0
        private static void GenerateWorksheetCommentsPartContent(WorksheetCommentsPart worksheetCommentsPart,
            XLWorksheet xlWorksheet)
        {
            var comments = new Comments();
            var commentList = new CommentList();
            var authorsDict = new Dictionary<String, Int32>();
            foreach (var c in xlWorksheet.Internals.CellsCollection.GetCells(c => c.HasComment))
            {
                var comment = new Comment {Reference = c.Address.ToStringRelative()};
                var authorName = c.Comment.Author;

                Int32 authorId;
                if (!authorsDict.TryGetValue(authorName, out authorId))
                {
                    authorId = authorsDict.Count;
                    authorsDict.Add(authorName, authorId);
                }
                comment.AuthorId = (UInt32)authorId;

                var commentText = new CommentText();
                foreach (var rt in c.Comment)
                {
                    commentText.Append(GetRun(rt));
                }

                comment.Append(commentText);
                commentList.Append(comment);
            }

            var authors = new Authors();
            foreach (var author in authorsDict.Select(a => new Author {Text = a.Key}))
            {
                authors.Append(author);
            }
            comments.Append(authors);
            comments.Append(commentList);

            worksheetCommentsPart.Comments = comments;
        }
コード例 #32
0
        // Generates content of worksheetCommentsPart1.
        private void GenerateWorksheetCommentsPart1Content(WorksheetCommentsPart worksheetCommentsPart1)
        {
            Comments comments1 = new Comments();

            Authors authors1 = new Authors();
            Author author1 = new Author();
            author1.Text = "Author";

            authors1.Append(author1);

            CommentList commentList1 = new CommentList();

            Comment comment1 = new Comment() { Reference = "V10", AuthorId = (UInt32Value)0U, ShapeId = (UInt32Value)0U };

            CommentText commentText1 = new CommentText();

            Run run14 = new Run();

            RunProperties runProperties14 = new RunProperties();
            Bold bold1 = new Bold();
            FontSize fontSize1 = new FontSize() { Val = 9D };
            Color color1 = new Color() { Indexed = (UInt32Value)81U };
            RunFont runFont1 = new RunFont() { Val = "Tahoma" };
            RunPropertyCharSet runPropertyCharSet1 = new RunPropertyCharSet() { Val = 1 };

            runProperties14.Append(bold1);
            runProperties14.Append(fontSize1);
            runProperties14.Append(color1);
            runProperties14.Append(runFont1);
            runProperties14.Append(runPropertyCharSet1);
            Text text14 = new Text();
            text14.Text = "Author:";

            run14.Append(runProperties14);
            run14.Append(text14);

            Run run15 = new Run();

            RunProperties runProperties15 = new RunProperties();
            FontSize fontSize2 = new FontSize() { Val = 9D };
            Color color2 = new Color() { Indexed = (UInt32Value)81U };
            RunFont runFont2 = new RunFont() { Val = "Tahoma" };
            RunPropertyCharSet runPropertyCharSet2 = new RunPropertyCharSet() { Val = 1 };

            runProperties15.Append(fontSize2);
            runProperties15.Append(color2);
            runProperties15.Append(runFont2);
            runProperties15.Append(runPropertyCharSet2);
            Text text15 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text15.Text = "\nThis is a comment";

            run15.Append(runProperties15);
            run15.Append(text15);

            commentText1.Append(run14);
            commentText1.Append(run15);

            comment1.Append(commentText1);

            commentList1.Append(comment1);

            comments1.Append(authors1);
            comments1.Append(commentList1);

            worksheetCommentsPart1.Comments = comments1;
        }