Beispiel #1
0
        public IHttpActionResult PutUser(string id, UserViewModel userViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != userViewModel.Id)
            {
                return(BadRequest());
            }
            User user = ViewModelMapper.ToModelUsers(userViewModel);

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }