public IHttpActionResult GetAuthorByFirstName(string firstName)
        {
            AuthorServices authorService = CreateAuthorService();
            AuthorDetail   author        = authorService.GetAuthorByFirstName(firstName);

            return(Ok(author));
        }
Beispiel #2
0
        public async Task <AuthorDetail> GetAuthorByLastName(string lastName)
        {
            _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", $"{AccessToken}");
            HttpResponseMessage response = _client.GetAsync($"https://localhost:44388/api/Author?lastName={lastName}").Result;

            if (response.IsSuccessStatusCode)
            {
                AuthorDetail author = await response.Content.ReadAsAsync <AuthorDetail>();

                return(author);
            }
            return(null);
        }
        public ActionResult Edit(int id)
        {
            AuthorDetail detail = AuthorDetailService(id);
            var          model  =
                new AuthorEdit
            {
                AuthorId    = detail.AuthorId,
                Name        = detail.Name,
                CountryName = detail.CountryName
            };

            return(View(model));
        }
        // GET: Authors/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Author       author       = _authorService.GetAuthor(a => a.Id == id, a => a.BookList);
            AuthorDetail authorDetail = AutoMapper.Mapper.Map <Author, AuthorDetail>(author);

            if (author == null)
            {
                return(HttpNotFound());
            }
            return(View(authorDetail));
        }
Beispiel #5
0
        private void listView_DoubleClick(object sender, EventArgs e)
        {
            if (listView.SelectedIndices.Count != 1)
            {
                return;
            }

            var index    = listView.SelectedIndices[0];
            var authorId = _authors[index].Id;

            var detailForm = new AuthorDetail(_client, authorId);

            if (detailForm.ShowDialog(this) == DialogResult.OK)
            {
                Reload();
            }
        }
Beispiel #6
0
        public async Task <ActionResult <AuthorDetail> > Details(int?id)
        {
            if (id == null)
            {
                return(BadRequest("Object not found"));
            }

            AuthorDetail authorDetail = await authorService.GetAuthor(id.Value);

            if (authorDetail == null)
            {
                // Only for eample
                return(StatusCode(StatusCodes.Status400BadRequest, "Object not found"));
            }

            return(Ok(authorDetail));
        }
Beispiel #7
0
 public ActionResult AddAuthor([Bind(Include = "Name,DateOfBirth,Email")] AuthorDetail authorDetail)
 {
     if (Session["UserEmail"] != null)
     {
         if (ModelState.IsValid)
         {
             db.AuthorDetails.Add(authorDetail);
             db.SaveChanges();
             return(RedirectToAction("AuthorList"));
         }
         return(View(authorDetail));
     }
     else
     {
         Response.Write("<script>alert('Please Login')</script>");
         Session.Clear();
         return(RedirectToAction("SignIn", "Authentication"));
     }
 }
Beispiel #8
0
        public void GetAuthorByLastName()
        {
            Console.Clear();
            Console.Write("Enter author's last name: ");
            string       LastName = Console.ReadLine();
            AuthorDetail author   = BookLoverUI.Service.GetAuthorByLastName(LastName).Result;

            if (author != null)
            {
                Console.WriteLine($"Author Id: {author.AuthorId}");
                Console.WriteLine($"FirstName: {author.FirstName}");
                Console.WriteLine($"LastName: {author.LastName}");
                Console.WriteLine($"Description: {author.Description}");
            }
            else
            {
                Console.WriteLine("Sorry, we don't have information for that author.");
                Console.WriteLine("Please press any key to return to the main menu.");
            }
            Console.ReadKey();
        }
Beispiel #9
0
        public AuthorDetail Get(AuthorCriteria criteria)
        {
            var qAuthor = View <Author>().All();

            if (criteria.IDToInt > 0)
            {
                qAuthor = qAuthor.Where(w => w.ID == criteria.IDToInt);
            }

            var author = qAuthor.SingleOrDefault();

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

            var detail = new AuthorDetail();

            MapProperty(author, detail);

            return(detail);
        }
Beispiel #10
0
 public void TestValidateSqlResponseInvalidResult()
 {
     var result = new AuthorDetail { Id = 1 };
     var actual = PrivateAccessor.ValidateSqlResponse(2, result);
     Assert.IsFalse(actual);
 }
Beispiel #11
0
 public void TestValidateSqlResponse()
 {
     var result = new AuthorDetail { Id = 1 };
     var actual = PrivateAccessor.ValidateSqlResponse(result.Id, result);
     Assert.IsTrue(actual);
 }
        public ActionResult Delete(int id)
        {
            AuthorDetail detail = AuthorDetailService(id);

            return(View(detail));
        }