Esempio n. 1
0
        public AuthorView Get(int id)
        {
            Author     author     = _unitOfWork.Author.Get(id);
            AuthorView authorView = MapToViewModel(author);

            return(authorView);
        }
        public void AddAuthor(AuthorView Author)
        {
            Author a = GetAuthorEntityForView(Author);

            _db.Add(a);
            _db.SaveChanges();
        }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     view = gameObject.AddComponent <AuthorView>();
     view.Return.onClick.AddListener(delegate() {
         Destroy(gameObject);
     });
 }
Esempio n. 4
0
        public async Task <IHttpActionResult> Update([FromBody, CustomizeValidator] AuthorView author)
        {
            var authorInfo = _mapper.Map <AuthorView, AuthorInfo>(author);
            var result     = await _authorService.UpdateAsync(authorInfo);

            return(result.IsError ? BadRequest(result.Message) : (IHttpActionResult)Ok(result.Data));
        }
        public async Task Setup()
        {
            var author = new AuthorView {
                Name = RandomData.Name
            };

            _response = await Client.PostObject($"/libraries/{LibraryId}/authors", author);
        }
Esempio n. 6
0
 public static AuthorModel Map(this AuthorView source)
 => source == null ? null : new AuthorModel
 {
     Id          = source.Id,
     Name        = source.Name,
     Description = source.Description,
     AuthorType  = source.AuthorType.ToEnum <AuthorTypes>(AuthorTypes.Writer)
 };
Esempio n. 7
0
 public ActionResult Edit([Bind(Include = "AuthorID,FirstName,LastName")] AuthorView authorView)
 {
     if (ModelState.IsValid)
     {
         service.UpdateAuthor(authorView.ToAuthorDM());
         return(RedirectToAction("Index"));
     }
     return(View(authorView));
 }
Esempio n. 8
0
        public async Task Setup()
        {
            _author = new AuthorView {
                Name = RandomData.Name
            };

            _response = await Client.PutObject($"/libraries/{LibraryId}/authors/{_author.Id}", _author);

            _assert = AuthorAssert.WithResponse(_response).InLibrary(LibraryId);
        }
Esempio n. 9
0
 public bool Add(AuthorView model)
 {
     if (model != null)
     {
         Author author = MapToDataModel(model);
         author.IsAlive = true;
         _unitOfWork.Author.Add(author);
         Save();
         return(true);
     }
     return(false);
 }
Esempio n. 10
0
        public async Task <IHttpActionResult> Create([FromBody, CustomizeValidator] AuthorView author)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var authorInfo = _mapper.Map <AuthorView, AuthorInfo>(author);
            var result     = await _authorService.AddAsync(authorInfo);

            return(result.IsError ? BadRequest(result.Message) : (IHttpActionResult)Ok(result.Data));
        }
Esempio n. 11
0
        private AuthorView Convert(Author a)
        {
            var authorView = new AuthorView()
            {
                Name     = a.Name,
                LastName = a.LastName,
                BirthDay = a.BirthDay,
                Email    = a.Email,
                Id       = a.Id,
            };

            return(authorView);
        }
Esempio n. 12
0
        public async Task <ActionResult> Delete(AuthorView author)
        {
            try
            {
                await _http.Delete(author.Id);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
        public void EditAuthor(AuthorView author)
        {
            var col = _db.Authors.Single(x => x.ID == author.ID);

            if (col != null)
            {
                col.Birthday    = author.Birthday;
                col.Description = author.Description;
                col.ImagePath   = author.ImagePath;
                col.Name        = author.Name;
                _db.SaveChanges();
            }
        }
Esempio n. 14
0
        // GET: AuthorViews/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AuthorView authorView = new AuthorView(service.GetAuthor(Convert.ToInt32(id)));

            if (authorView == null)
            {
                return(HttpNotFound());
            }
            return(View(authorView));
        }
Esempio n. 15
0
        public ActionResult Edit(AuthorView model)
        {
            var authorBO = mapper.Map <AuthorBO>(model);

            if (ModelState.IsValid)
            {
                authorBO.Save();
                return(RedirectToActionPermanent("Index", "Author"));
            }
            else
            {
                return(View(model));
            }
        }
        public async Task Setup()
        {
            var authors = AuthorBuilder.WithLibrary(LibraryId).WithBooks(3).Build(4);

            var author = authors.PickRandom();

            _expected = new AuthorView {
                Name = RandomData.Name
            };

            _response = await Client.PutObject($"/libraries/{LibraryId}/authors/{author.Id}", author);

            _assert = AuthorAssert.WithResponse(_response).InLibrary(LibraryId);
        }
Esempio n. 17
0
        public async Task <IActionResult> CreateAuthor(int libraryId, [FromBody] AuthorView author, CancellationToken token = default(CancellationToken))
        {
            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(ModelState));
            }

            var request = new AddAuthorRequest(libraryId, author.Map());
            await _commandProcessor.SendAsync(request, cancellationToken : token);

            var renderResult = _authorRenderer.Render(request.Result, libraryId);

            return(new CreatedResult(renderResult.Links.Self(), renderResult));
        }
 public Author GetAuthorEntityForView(AuthorView a)
 {
     if (a == null)
     {
         return(null);
     }
     return(new Author
     {
         Birthday = a.Birthday,
         Description = a.Description,
         ID = a.ID,
         ImagePath = a.ImagePath,
         Name = a.Name
     });
 }
Esempio n. 19
0
 public IActionResult AddAuthor(AuthorView authorView)
 {
     if (authorValidator.ValidateFirstname(authorView.Firstname) && authorValidator.ValidatePreposition(authorView.Preposition) && authorValidator.ValidateLastname(authorView.Lastname) && authorValidator.ValidateCity(authorView.City) && authorValidator.ValidateYearofbirth(authorView.Year_of_birth) && authorValidator.ValidateYearofdeath(authorView.Year_of_death))
     {
         Author author = AuthorViewToAuthor(authorView);
         authorContainer.AddAuthor(author);
         ModelState.AddModelError("Succes", "de auteur is toegevoegd!");
         return(View("AuthorToevoegen"));
     }
     else
     {
         ModelState.AddModelError("Alert", authorValidator.Result);
         return(View("AuthorToevoegen"));
     }
 }
Esempio n. 20
0
        public IEnumerable <AuthorView> GetAll()
        {
            IEnumerable <Author> authors     = _unitOfWork.Author.GetAll();
            List <AuthorView>    authorViews = new List <AuthorView>();

            foreach (Author author in authors)
            {
                if (author.IsAlive == true)
                {
                    AuthorView authorView = MapToViewModel(author);
                    authorViews.Add(authorView);
                }
            }
            return(authorViews);
        }
Esempio n. 21
0
        public List<AuthorView> GetAuthorList(List<Author> authors)
        {
            List<AuthorView> result = new List<AuthorView>();

            foreach (var item in authors)
            {
                AuthorView author = new AuthorView
                {
                    Id = item.Id,
                    FullName = NameRefactorer.GetFullName(item.FirstName, item.MiddleName, item.LastName),
                    BooksCount = GetAuthorBooksCount(item),
                    Country = GetAuthorCountry(item)
                };

                result.Add(author);
            }

            return result;
        }
 private void OpenAuthorView()
 {
     if (SelectedAuthor == null)
     {
         CurrentAuthor = new AuthorModel();
     }
     else
     {
         var q = new AuthorModel();
         q                          = _selectedAuthor;
         CurrentAuthor              = SelectedAuthor ?? new AuthorModel();
         CurrentAuthor.LastName     = q.LastName;
         CurrentAuthor.FirstName    = q.FirstName;
         CurrentAuthor.AuthorNumber = q.AuthorNumber;
         CurrentAuthor.BookList     = q.BookList;
         AuthorBookList             = q.BookList;
         CurrentAuthor.Birthdate    = q.Birthdate;
         CurrentAuthor.Gender       = q.Gender;
     }
     AV = new AuthorView();
     AV.Show();
 }
Esempio n. 23
0
        public NoteViewModel ToNoteViewModel(ApplicationUser applicationUser, Note note, VoteModel voteModel)
        {
            AuthorView authorView;

            if (note.IsAnonymous)
            {
                authorView = null;
            }
            else if (note.User == null)             // viewer is self
            {
                authorView = new AuthorView {
                    Uid = applicationUser.Uid, Username = applicationUser.Username
                }
            }
            ;
            else
            {
                authorView = new AuthorView {
                    Uid = note.User.Uid.Value, Username = note.User.Username
                }
            };

            return(new NoteViewModel
            {
                Id = note.Id,
                Uid = note.Uid.Value,
                Score = note.Score,
                DateCreated = note.DateCreated.Value,
                Subject = note.Subject,
                Body = note.Body,
                Latitude = note.Latitude,
                Longitude = note.Longitude,
                Radius = note.Radius,
                User = authorView,
                MyVote = voteModel?.Vote ?? VoteEnum.None
            });
        }
    }
Esempio n. 24
0
        public bool Update(AuthorView model)
        {
            if (model == null)
            {
                return(false);
            }

            Author author    = _unitOfWork.Author.Get(model.AuthorId);
            Author authorNew = MapToDataModel(model);

            if (authorNew != null)
            {
                author.AuthorName = authorNew.AuthorName;
                author.History    = author.History;
            }

            if (author != null)
            {
                _unitOfWork.Author.Update(author);
                Save();
                return(true);
            }
            return(false);
        }
Esempio n. 25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // set settings item to datasource or context

            settingsItem = Sitecore.Feature.XBlog.General.DataManager.GetBlogSettingsItem(DataSourceItem != null ? DataSourceItem : Sitecore.Context.Item);

            bool authorFound = false;

            if (!String.IsNullOrEmpty(Request.QueryString[XBSettings.XBAuthorViewQS]))
            {
                Author authorItem = AuthorManager.GetAuthorByName(DataSourceItem, Request.QueryString[XBSettings.XBAuthorViewQS]);
                if (authorItem != null)
                {
                    authorFound          = true;
                    lvAuthorList.Visible = false;
                    pnlAuthor.Visible    = true;

                    frTitle.Item      = authorItem.InnerItem;
                    frTitle.FieldName = Author.AuthorFullNameFieldId;

                    frAuthorTitle.Item      = authorItem.InnerItem;
                    frAuthorTitle.FieldName = Author.AuthorTitleFieldId;

                    frLocation.Item      = authorItem.InnerItem;
                    frLocation.FieldName = Author.AuthorLocationFieldId;

                    frBio.Item      = authorItem.InnerItem;
                    frBio.FieldName = Author.AuthorBioFieldId;

                    frProfileImage.Item      = authorItem.InnerItem;
                    frProfileImage.FieldName = Author.AuthorProfileImageFieldId;
                    frProfileImage.CssClass  = "authorImage";


                    string searchHeading = "";
                    string categoryID    = "";
                    string authorID      = "";
                    string tagID         = "";
                    string searchText    = "";


                    authorID = authorItem.InnerItem.ID.ToString();

                    if (settingsItem.DisplayFilterMessage)
                    {
                        searchHeading = settingsItem.AuthorFilterTitle + authorItem.FullName;
                    }


                    //Get search results
                    int  currentPage   = 1;
                    int  maximumRows   = 5;
                    int  startRowIndex = 1;
                    bool rowResult     = Int32.TryParse(settingsItem.PageSize, out maximumRows);
                    if (!rowResult)
                    {
                        maximumRows = 5;
                    }

                    bool pageResult = false;

                    if (!String.IsNullOrEmpty(Request.QueryString[XBSettings.XBPageQS]))
                    {
                        pageResult = Int32.TryParse(Request.QueryString[XBSettings.XBPageQS], out currentPage);
                    }
                    if (!pageResult)
                    {
                        currentPage = 1;
                    }

                    startRowIndex = (currentPage - 1) * maximumRows;


                    IEnumerable <BlogPost> blogs = BlogManager.GetBlogPosts(DataSourceItem, categoryID, authorID, tagID, searchText, startRowIndex, maximumRows);
                    int totalRows = BlogManager.GetBlogsCount(DataSourceItem, categoryID, authorID, tagID, searchText);

                    if (searchHeading != "")
                    {
                        searchHeading = totalRows.ToString() + " " + searchHeading;
                    }

                    litSearchHeading.Text = searchHeading;

                    litPagination.Text = BlogManager.GetBlogPagination(settingsItem, currentPage, totalRows, maximumRows);

                    if (blogs == null || !blogs.Any())
                    {
                        return;
                    }

                    // Bind data source
                    lvBlogPosts.DataSource = blogs;
                    lvBlogPosts.DataBind();
                }
            }

            if (!authorFound)
            {
                lvAuthorList.Visible = true;
                pnlAuthor.Visible    = false;

                // no author found, get list
                AuthorView authorItem = Sitecore.Context.Item.CreateAs <AuthorView>();

                frTitle.Item      = authorItem.InnerItem;
                frTitle.FieldName = AuthorView.AuthorDefaultTitleFieldId;

                //Get search results
                IEnumerable <Author> authors = AuthorManager.GetAuthors(DataSourceItem);

                if (authors == null || !authors.Any())
                {
                    return;
                }

                // Bind data source
                lvAuthorList.DataSource = authors;
                lvAuthorList.DataBind();
            }
        }
Esempio n. 26
0
 private AuthorAssert(AuthorView view)
 {
     _author = view;
 }
 public IActionResult PutAuthor([FromBody] AuthorView authorView)
 {
     return(Ok(_authorService.Update(authorView)));
 }
 public IActionResult PostAuthor([FromBody] AuthorView authorView)
 {
     return(Ok(_authorService.Add(authorView)));
 }
Esempio n. 29
0
 public static AuthorAssert ShouldMatch(this AuthorView view, AuthorDto dto)
 {
     return(AuthorAssert.FromObject(view)
            .ShouldBeSameAs(dto));
 }
 public void RemoveAuthor(AuthorView Author)
 {
     RemoveAuthorByID(Author.ID);
 }