示例#1
0
        public async Task <IActionResult> AddPhoneBook([FromBody] PhoneBookViewModel AddPhoneBook)
        {
            _ = new ObjectResult(false);

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                else
                {
                    await _PhoneBookApi.AddPhoneBook(AddPhoneBook.ReverseMap());
                }

                return(Ok(new { message = "Phone Book is added successfully." }));
            }

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