Exemplo n.º 1
0
        public HttpResponseMessage PutTunnel(Spartan_WorkFlow_Phases 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.PhasesId), "PUT"
                                             , dataString);

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
Exemplo n.º 2
0
        public HttpResponseMessage Delete(int id)
        {
            Spartan_WorkFlow_Phases varSpartan_WorkFlow_Phases = this.service.GetByKey(id, false);
            bool result = false;

            if (varSpartan_WorkFlow_Phases == 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));
        }
Exemplo n.º 3
0
        public HttpResponseMessage Post(Spartan_WorkFlow_Phases varSpartan_WorkFlow_Phases)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varSpartan_WorkFlow_Phases));
                }
                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 Post(bool IsNew, Spartan_WorkFlow_PhasesModel varSpartan_WorkFlow_Phases)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _ISpartan_WorkFlow_PhasesApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var Spartan_WorkFlow_PhasesInfo = new Spartan_WorkFlow_Phases
                    {
                        PhasesId       = varSpartan_WorkFlow_Phases.PhasesId
                        , Phase_Number = varSpartan_WorkFlow_Phases.Phase_Number
                        , Name         = varSpartan_WorkFlow_Phases.Name
                        , Phase_Type   = varSpartan_WorkFlow_Phases.Phase_Type
                        , Type_of_Work_Distribution = varSpartan_WorkFlow_Phases.Type_of_Work_Distribution
                        , Type_Flow_Control         = varSpartan_WorkFlow_Phases.Type_Flow_Control
                        , Phase_Status = varSpartan_WorkFlow_Phases.Phase_Status
                    };

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

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Delete(int id)
        {
            try
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ISpartan_WorkFlow_PhasesApiConsumer.SetAuthHeader(_tokenManager.Token);

                Spartan_WorkFlow_Phases varSpartan_WorkFlow_Phases = null;
                if (id.ToString() != "0")
                {
                    string where = "";
                }
                var result = _ISpartan_WorkFlow_PhasesApiConsumer.Delete(id, null, null).Resource;
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }