Example #1
0
        public HttpResponseMessage PutTunnel(Spartan_Traduction_Process_Workflow emp, string user, string password)
        {
            var client = new System.Net.WebClient();

            client.Headers = TokenManager.GetAuthenticationHeader(user, password);
            client.Headers["Content-Type"] = "application/json";
            var dataString = new JavaScriptSerializer().Serialize(emp);

            var result = client.UploadString(new Uri(baseApi + ApiControllerUrl + "/Put?Id=" + emp.Clave), "PUT"
                                             , dataString);

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
Example #2
0
        public HttpResponseMessage Delete(int id)
        {
            Spartan_Traduction_Process_Workflow varSpartan_Traduction_Process_Workflow = this.service.GetByKey(id, false);
            bool result = false;

            if (varSpartan_Traduction_Process_Workflow == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            try
            {
                result = this.service.Delete(id);//, globalData, dataReference);
            }
            catch (ServiceException ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Example #3
0
        public HttpResponseMessage Post(Spartan_Traduction_Process_Workflow varSpartan_Traduction_Process_Workflow)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varSpartan_Traduction_Process_Workflow));
                }
                catch (ServiceException ex)
                {
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors).Select(error => error.ErrorMessage);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
        public ActionResult Delete(int id)
        {
            try
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ISpartan_Traduction_Process_WorkflowApiConsumer.SetAuthHeader(_tokenManager.Token);

                Spartan_Traduction_Process_Workflow varSpartan_Traduction_Process_Workflow = null;
                if (id.ToString() != "0")
                {
                    string where = "";
                }
                var result = _ISpartan_Traduction_Process_WorkflowApiConsumer.Delete(id, null, null).Resource;
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Post(bool IsNew, Spartan_Traduction_Process_WorkflowModel varSpartan_Traduction_Process_Workflow)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _ISpartan_Traduction_Process_WorkflowApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var Spartan_Traduction_Process_WorkflowInfo = new Spartan_Traduction_Process_Workflow
                    {
                        Clave             = varSpartan_Traduction_Process_Workflow.Clave
                        , Concept         = varSpartan_Traduction_Process_Workflow.Concept
                        , ID_of_Step      = varSpartan_Traduction_Process_Workflow.ID_of_Step
                        , Original_Text   = varSpartan_Traduction_Process_Workflow.Original_Text
                        , Translated_Text = varSpartan_Traduction_Process_Workflow.Translated_Text
                    };

                    result = !IsNew?
                             _ISpartan_Traduction_Process_WorkflowApiConsumer.Update(Spartan_Traduction_Process_WorkflowInfo, null, null).Resource.ToString() :
                                 _ISpartan_Traduction_Process_WorkflowApiConsumer.Insert(Spartan_Traduction_Process_WorkflowInfo, null, null).Resource.ToString();

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }