Exemple #1
0
        public async Task <IActionResult> GetPhoneBook()
        {
            _ = new ObjectResult(false);

            try
            {
                var PhoneBook = await _PhoneBookApi.GetFirstPhoneBook();

                if (PhoneBook == null)
                {
                    return(NotFound(new { message = "Phone Books not found" }));
                }
                else
                {
                    PhoneBookViewModel item = new PhoneBookViewModel();

                    item.MapSinglePhoneBook(PhoneBook);

                    return(new ObjectResult(item));
                }
            }
            catch (Exception ex)
            {
                _loggingApi.Add(new SYS_Error()
                {
                    Message = ex.Message, StackTrace = ex.StackTrace, CreatedDate = DateTime.Now
                });
                await _loggingApi.Commit();

                return(NotFound(new { message = "An error occured" }));
            }
        }