Esempio n. 1
0
        // POST api/WorkFlowConfig
        public HttpResponseMessage PostWorkFlowConfig(WorkFlowConfig workflowconfig)
        {
            if (ModelState.IsValid)
            {
                workflowconfig.InsertBy = loginUser.UserID;
                db.WorkFlowConfigs.Add(workflowconfig);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, workflowconfig);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = workflowconfig.WorkFlowConfigID }));
                return response;
            }
            else
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
        }
Esempio n. 2
0
        // PUT api/WorkFlowConfig/5
        public HttpResponseMessage PutWorkFlowConfig(long id, WorkFlowConfig workflowconfig)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != workflowconfig.WorkFlowConfigID)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
            workflowconfig.UpdateBy = loginUser.UserID;

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }