Exemple #1
0
        public async Task <IActionResult> PutContactInfoDAO(long id, ContactInfoRequest contactInfoRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (!ContactInfoDAOExists(id))
            {
                return(NotFound());
            }

            ContactInfoDAO contactInfoDAO = await _context.ContactInfoDAO.FindAsync(id);

            ContactInfoConverter.RequestToExistingDAO(contactInfoRequest, contactInfoDAO);
            _context.Entry(contactInfoDAO).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(StatusCode(500));
            }

            return(NoContent());
        }
        public async Task <IHttpActionResult> PutContactPerson(int id, ContactPerson contactPerson)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            db.Entry(contactPerson).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContactPersonExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }