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

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

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

                    //object then unbox to int
                    int userId = data.UserId;

                    if (data.CategoryId == null)
                    {
                        bool inChat = data.InChat;
                        context.usp_tech_cat(null, userId, inChat);
                    }

                    else
                    {
                        int categoryId = data.CategoryId;
                        context.usp_tech_cat(categoryId, userId, null);
                    }

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

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