Ejemplo n.º 1
0
        public IHttpActionResult UpdateUser(dynamic data)
        {
            using (var context = new TicketCenterAPI.Models.ticketcenterdbEntities1())
            {
                context.Configuration.ProxyCreationEnabled = false;

                //is the model with binding is incorrect
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                try
                {
                    //alternative => req.Content.ReadAsStringAsync().Result;

                    //object then unbox to int
                    int    id        = data.id;
                    int    roleId    = data.RoleId;
                    string firstName = data.FirstName;
                    string lastName  = data.LastName;

                    //update role
                    context.usp_role_user(id, roleId, firstName, lastName);


                    System.Diagnostics.Debug.WriteLine(roleId + " and ");
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    return(NotFound());
                }

                return(Ok("Update succesfull"));
            }
        }