public async Task <IHttpActionResult> PutPhonebookEntry(int id, Entry request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != request.Id)
            {
                return(BadRequest());
            }

            try
            {
                await PhonebookService.EditPhonebookEntry(request);
            }
            catch (Exception ex)
            {
                if (PhonebookService.GetSinglePhonebookEntry(id) == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public async Task <IHttpActionResult> PatchPhonebookEntry(PhonebookEntry request)
        {
            if (ModelState.IsValid)
            {
                var response = await PhonebookService.EditPhonebookEntry(request);

                return(Ok(response));
            }

            return(BadRequest(ModelState));
        }