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

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

            return(NotFound());
        }
コード例 #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)));
     }
 }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: ContactController.cs プロジェクト: firate/easycrm
        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;
            }
        }
コード例 #5
0
 // 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());
     }
 }