Beispiel #1
0
        public IHttpActionResult EditContact(int contactID, Contact contact)
        {
            bool status = _contactManager.EditContact(contactID, contact);

            if (status)
            {
                return(Ok(status));
            }

            return(NotFound());
        }
Beispiel #2
0
 public IActionResult Edit(Contact contact)
 {
     try
     {
         return(Ok(_contactManager.EditContact(contact)));
     }
     catch (Exception ex)
     {
         return(BadRequest(Util.ErrorResponse.FormatResponse("Something went wrong!", ex.Message)));
     }
 }
        public async Task <IActionResult> EditContact(ContactEditRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(StatusCode(400));
            }

            var identityClaimNum = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var dto = _mapper.Map <ContactEditDTO>(request);

            dto.OwnerId = identityClaimNum;

            if (await _contactCreateManager.EditContact(dto))
            {
                return(StatusCode(201));
            }

            throw new Exception();
        }
Beispiel #4
0
        public async Task <IActionResult> EditContact([FromBody] ContactEditDTO contactEditDTO, int id)
        {
            try
            {
                var contact = mapper.Map <Contact>(contactEditDTO);

                var result = await contactManager.EditContact(id, contact);

                if (result == true)
                {
                    return(NoContent());
                }

                return(BadRequest());
            }
            catch (Exception)
            {
                throw;
            }
        }
 // PUT api/values/5
 public IHttpActionResult Put([FromBody] Contact value)
 {
     try
     {
         var success = _contactManager.EditContact(value);
         if (success)
         {
             return(Ok());
         }
         else
         {
             return(NotFound());
         }
     }
     catch (Exception ex)
     {
         //Added Logger here.
         //Also we can handle exception in Exception Filter
         return(InternalServerError());
     }
 }