コード例 #1
0
        public ActionResult EditAuthor(int id, AuthorModel model)
        {
            SessionModelCollector sessionModel = this.GetFromSession <SessionModelCollector>("ProjectInfo");

            sessionModel.Authors[id] = model;
            this.AddToSession("ProjectInfo", sessionModel); //save in session
            return(RedirectToAction("AuthorList"));
        }
コード例 #2
0
        public ViewResult CreateAuthor()
        {
            ViewBag.Title   = "Library :: Авторы";
            ViewBag.Caption = "Создать автора";
            AuthorModel author = new AuthorModel();

            return(View("AuthorForm", author));
        }
コード例 #3
0
        public ActionResult IndexO()
        {
            var list = new AuthorModel();

            list.AllCampus = GetCampus();
            list.AllAuthor = GetA();
            return(View(list));
        }
コード例 #4
0
        public AuthorModelTests()
        {
            _repositoryMock    = new Mock <IAuthorRepository>();
            _dateValidatorMock = new Mock <IDateValidator>();
            _pageValidatorMock = new Mock <IPageValidator>();

            _model = new AuthorModel(_repositoryMock.Object, _dateValidatorMock.Object, _pageValidatorMock.Object);
        }
コード例 #5
0
        public ActionResult CreateAuthor()
        {
            var record = new AuthorModel();

            record.AllLocations  = GetLocation();
            record.EventHandlers = GetHandler();
            return(View(record));
        }
コード例 #6
0
 private void AuthorSelectorLB_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     SelectedAuthor = _authorTable.ConvertDataRowToAuthor(_authors[AuthorSelectorLB.SelectedIndex]);
     TB_SelectAuthorFirstName.Text  = SelectedAuthor.FirstName;
     TB_SelectAuthorLastName.Text   = SelectedAuthor.LastName;
     TB_SelectAuthorMiddleName.Text = SelectedAuthor.MiddleName;
     Close();
 }
コード例 #7
0
        public CreateBlog()
        {
            Model.AuthorModel FristAuthor = new AuthorModel()
            {
                Given_name  = "Richard",
                Last_name   = "Flow",
                Birth_date  = new DateTime(1990, 06, 27),
                Email       = "*****@*****.**",
                Website     = "www.abc.com",
                Phone       = "8888554455",
                Country     = "Canada",
                Province    = "Ontario",
                Postal_code = "1424115"
            };

            Model.AuthorModel SecondAuthor = new AuthorModel()
            {
                Given_name  = "Richard",
                Last_name   = "Jhnonson",
                Birth_date  = new DateTime(1992, 06, 27),
                Email       = "*****@*****.**",
                Website     = "www.abc1.com",
                Phone       = "8888554465",
                Country     = "US",
                Province    = "ANY",
                Postal_code = "1524115"
            };
            Model.AuthorModel ThirdAuthor = new AuthorModel()
            {
                Given_name  = "Michael",
                Last_name   = "Jhnonson",
                Birth_date  = new DateTime(1980, 06, 27),
                Email       = "*****@*****.**",
                Website     = "www.abc12.com",
                Phone       = "88885544652",
                Country     = "India",
                Province    = "ANY1",
                Postal_code = "15241152"
            };

            Model.AuthorModel FourthAuthor = new AuthorModel()
            {
                Given_name  = "Stephen",
                Last_name   = "Jhnonson",
                Birth_date  = new DateTime(1982, 06, 27),
                Email       = "*****@*****.**",
                Website     = "www.abc121.com",
                Phone       = "888855446521",
                Country     = "Pakistan",
                Province    = "Baluchistan",
                Postal_code = "152141152"
            };

            Authors.Add(FristAuthor);
            Authors.Add(SecondAuthor);
            Authors.Add(ThirdAuthor);
            Authors.Add(FourthAuthor);
        }
コード例 #8
0
        public ActionResult AddBook(BOOK book, List <int> Authors, List <int> Categories,
                                    List <HttpPostedFileBase> bookImages, List <HttpPostedFileBase> bookSoftCopy)
        {
            try
            {
                book.CREATED_DATE = DateTime.Now;
                book = BookModel.AddBook(book);

                foreach (int aID in Authors)
                {
                    BOOK_AUTHOR bookAuthor = new BOOK_AUTHOR();
                    bookAuthor.BOOKID   = book.BOOKID;
                    bookAuthor.AUTHORID = aID;
                    AuthorModel.AddBookAuthor(bookAuthor);
                }

                foreach (int bCID in Categories)
                {
                    BOOK_CATEGORY bookCat = new BOOK_CATEGORY();
                    bookCat.BOOKID     = book.BOOKID;
                    bookCat.CATEGORYID = bCID;
                    CategoryModel.AddBookCategory(bookCat);
                }

                foreach (HttpPostedFileBase image in bookImages)
                {
                    String     fname     = Generator.RandomString(10) + "." + image.FileName.Split('.')[image.FileName.Split('.').Length - 1];
                    string     path      = Server.MapPath("~/UserImages/") + fname;
                    BOOK_IMAGE bookImage = new BOOK_IMAGE();
                    bookImage.BOOKID    = book.BOOKID;
                    bookImage.IMAGEPATH = "/UserImages/" + fname;
                    image.SaveAs(path);
                    BookModel.AddBookImage(bookImage);
                }
                if (bookSoftCopy != null)
                {
                    foreach (HttpPostedFileBase bookSC in bookSoftCopy)
                    {
                        String        fname = Generator.RandomString(10) + "." + bookSC.FileName.Split('.')[bookSC.FileName.Split('.').Length - 1];
                        string        path  = Server.MapPath("~/UserImages/") + fname;
                        BOOK_SOFTCOPY bSC   = new BOOK_SOFTCOPY();
                        bSC.BOOKID   = book.BOOKID;
                        bSC.FILEPATH = "/UserImages/" + fname;
                        bSC.FILESIZE = bookSC.ContentLength;
                        bookSC.SaveAs(path);
                        BookModel.AddBookSoftCopy(bSC);
                    }
                }
                ViewBag.Message = SuccessMessage.BOOK_ADDED;
            }
            catch (Exception e)
            {
                ViewBag.Message = e.Message;
            }

            initialiseViewBag();
            return(View(book));
        }
コード例 #9
0
 // PUT api/values/id
 public void Put(int id, [FromBody] AuthorModel author)
 {
     client.UpdateAuthor(new Author
     {
         Id            = id,
         AuthorName    = author.AuthorName,
         AuthorSurname = author.AuthorSurname
     });
 }
コード例 #10
0
ファイル: AuthorType.cs プロジェクト: Casgen/LibraryApp
            public async Task <IReadOnlyList <BookModel> > GetBooks(AuthorModel authorModel, BookByIdDataLoader dataLoader, [ScopedService] LibraryDbContext context, CancellationToken cancellationToken)
            {
                int[] bookIds = await context.Books
                                .Where(x => x.AuthorId == authorModel.Id)
                                .Select(x => x.Id)
                                .ToArrayAsync();

                return(await dataLoader.LoadAsync(bookIds, cancellationToken));
            }
コード例 #11
0
        public JsonResult ChangeStatus(int ID)
        {
            var res = new AuthorModel().ChangeStatusAtID(ID);

            return(Json(new
            {
                status = res
            }));
        }
コード例 #12
0
        public int AddNewAuthor(AuthorModel model)
        {
            var authorEntity = Mapper.Map <AuthorModel, Author>(model);
            var addedEntity  = _bookContext.Authors.Add(authorEntity);

            _bookContext.SaveChanges();

            return(addedEntity.Id);
        }
コード例 #13
0
        // GET: AuthorModels/Create
        public ActionResult Create(AuthorModel authorModel)
        {
            AuthorViewModel vm = new AuthorViewModel();

            //vm.Name = "111";
            return(View());
            //return new RedirectResult(Url.Action("PartialView", "Home", vm.Name));
            // return RedirectToAction("PartialView", "Home", new { selectedRegionName= vm.Name });
        }
コード例 #14
0
ファイル: AuthorRepository.cs プロジェクト: inshapardaz/api
 public async Task UpdateAuthor(int libraryId, AuthorModel author, CancellationToken cancellationToken)
 {
     using (var connection = _connectionProvider.GetConnection())
     {
         var sql     = @"Update Author Set Name = @Name, Description = @Description, ImageId = @ImageId, AuthorType = @AuthorType Where Id = @Id AND LibraryId = @LibraryId";
         var command = new CommandDefinition(sql, new { Id = author.Id, LibraryId = libraryId, Name = author.Name, Description = author.Description, ImageId = author.ImageId, AuthorType = (int)author.AuthorType }, cancellationToken: cancellationToken);
         await connection.ExecuteScalarAsync <int>(command);
     }
 }
コード例 #15
0
ファイル: AuthorMutations.cs プロジェクト: Casgen/LibraryApp
        public async Task <AuthorModel> DeleteAuthor(int id, [ScopedService] LibraryDbContext context)
        {
            AuthorModel authorModel = await context.Authors.FindAsync(id);

            context.Authors.Remove(authorModel);
            await context.SaveChangesAsync();

            return(authorModel);
        }
コード例 #16
0
 // GET: Author/Delete/5
 public ActionResult Delete(int id)
 {
     if (AuthorModel.Filter(id) == null)
     {
         return(HttpNotFound());
     }
     AuthorModel.Delete(id);
     return(null);
 }
コード例 #17
0
 public static AuthorView Map(this AuthorModel source)
 => source == null ? null : new AuthorView
 {
     Id          = source.Id,
     Name        = source.Name,
     Description = source.Description,
     BookCount   = source.BookCount,
     AuthorType  = source.AuthorType.ToDescription()
 };
コード例 #18
0
ファイル: AuthorsDA.cs プロジェクト: kserbez/Library
        public void InsertUser(AuthorModel model)
        {
            string query      = "INSERT INTO Authors VALUES(@FullName)";
            var    parameters = new Dictionary <string, object> {
                { "@FullName", model.FullName },
            };

            ExecuteNonQuery(query, parameters);
        }
        public void AddAuthor(AuthorModel author)
        {
            Author new_author = new Author();

            new_author.Name       = author.Name;
            new_author.Birth_year = author.Birth_year;
            new_author.Deceased   = author.Deceased;
            repositoryWrapper.AuthorRepository.Create(new_author);
        }
コード例 #20
0
        private void LB_SeriesSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            AuthorModel selectedAuthor = newBook.AuthorInfo as AuthorModel;

            if (selectedAuthor != null && selectedAuthor.IsValid)
            {
                newBook.SeriesInfo = new SeriesModel(selectedAuthor, LB_SeriesSelector.SelectedValue.ToString());
            }
        }
コード例 #21
0
        private void SetAuthorNameValues()
        {
            AuthorModel selectedAuthor = ThisBook.AuthorInfo;

            TB_SelectAuthorFirstName.Text  = selectedAuthor.FirstName;
            TB_SelectAuthorLastName.Text   = selectedAuthor.LastName;
            TB_SelectAuthorMiddleName.Text = selectedAuthor.MiddleName;
            PopulateSeriesSelector();
        }
コード例 #22
0
        public ActionResult UpdateAuthor(AuthorModel model, int AuthorID)
        {
            AuthorModelVM list = new AuthorModelVM(authBusLay.GetAuthorPassThru());

            ViewBag.Author = new SelectList(list.ListOfAuthorModel, "AuthorID");
            model.AuthorID = AuthorID;


            return(View(model));
        }
コード例 #23
0
        public IActionResult Put([FromBody] AuthorModel updatedAuthor)
        {
            var author = _authorService.Update(updatedAuthor.ToDomainModel());

            if (author == null)
            {
                return(BadRequest());
            }
            return(Ok(author));
        }
コード例 #24
0
ファイル: AuthorHelper.cs プロジェクト: goncasilik/kutuphanem
        public static Author MapAuthorModel(AuthorModel author)
        {
            Author authorEntity = new Author
            {
                AuthorID = author.AuthorID,
                Name     = author.Name,
            };

            return(authorEntity);
        }
コード例 #25
0
 public StorySent(long storyId, AuthorModel author, string title, IEnumerable <string> tags, DateTime createdAt,
                  VisibilityModel visibility)
 {
     StoryId    = storyId;
     Author     = author;
     Title      = title;
     Tags       = tags;
     CreatedAt  = createdAt;
     Visibility = visibility;
 }
コード例 #26
0
ファイル: CatalogueController.cs プロジェクト: avgx/knigoskop
        public ActionResult Author(Guid id)
        {
            AuthorModel model = DataService.GetAuthor(id, User.UserId);

            if (model == null)
            {
                return(new HttpNotFoundResult());
            }
            return(View(model));
        }
コード例 #27
0
ファイル: AuthorMapper.cs プロジェクト: khilchuk-ol/Librarian
 public void Map(AuthorModel from, Author to)
 {
     if (to.Id != from.Id)
     {
         throw new ArgumentException("Cannot map. Object are not related");
     }
     to.Name       = from.Name;
     to.Surname    = from.Surname;
     to.Parentname = from.Parentname;
 }
コード例 #28
0
        public AuthorModel GetModel()
        {
            var author = new AuthorModel
            {
                Id   = Faker.RandomNumber.Next(1, 100),
                Name = Faker.Name.FullName()
            };

            return(author);
        }
コード例 #29
0
        public IActionResult Put(int id, [FromBody] AuthorModel updatedAuthor)
        {
            var author = _AuthorService.Update(updatedAuthor.ToDomainModel());

            if (author == null)
            {
                return(NotFound());
            }
            return(Ok(author));
        }
コード例 #30
0
        // GET: Author/Details/5
        public ActionResult Details(int id)
        {
            AUTHOR author = AuthorModel.Filter(id);

            if (author == null)
            {
                return(HttpNotFound());
            }
            return(View(author));
        }