示例#1
0
        public async Task <IActionResult> GetPhoneBooks()
        {
            _ = new ObjectResult(false);

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

                var PhoneBooks = await _PhoneBookApi.GetAllPhoneBooks();

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

                    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" }));
            }
        }