예제 #1
0
        public IHttpActionResult UpdateCategory([FromBody] TicketCenterAPI.Models.Category category)
        {
            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
                {
                    //todo change name of SP admin used too
                    context.usp_category(category.CategoryId, category.CategoryDesc);
                }
                catch
                {
                    return(NotFound());
                }

                return(Ok("Update succesfull"));
            }
        }
예제 #2
0
        public IHttpActionResult AddCategory([FromBody] TicketCenterAPI.Models.Category category)
        {
            using (var context = new TicketCenterAPI.Models.ticketcenterdbEntities1())
            {
                context.Configuration.ProxyCreationEnabled = false;

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

                try
                {
                    context.ins_category(category.CategoryDesc);
                }
                catch
                {
                    return(InternalServerError());
                }

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