public ActionResult Post(bool IsNew, Spartan_BR_Rejection_ReasonModel varSpartan_BR_Rejection_Reason) { try { //if (ModelState.IsValid) //{ if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _ISpartan_BR_Rejection_ReasonApiConsumer.SetAuthHeader(_tokenManager.Token); var result = ""; var Spartan_BR_Rejection_ReasonInfo = new Spartan_BR_Rejection_Reason { Key_Rejection_Reason = varSpartan_BR_Rejection_Reason.Key_Rejection_Reason , Description = varSpartan_BR_Rejection_Reason.Description }; result = !IsNew? _ISpartan_BR_Rejection_ReasonApiConsumer.Update(Spartan_BR_Rejection_ReasonInfo, null, null).Resource.ToString() : _ISpartan_BR_Rejection_ReasonApiConsumer.Insert(Spartan_BR_Rejection_ReasonInfo, null, null).Resource.ToString(); Session["KeyValueInserted"] = result; return(Json(result, JsonRequestBehavior.AllowGet)); //} //return Json(false, JsonRequestBehavior.AllowGet); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public HttpResponseMessage PutTunnel(Spartan_BR_Rejection_Reason 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.Key_Rejection_Reason), "PUT" , dataString); return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter)); }
public HttpResponseMessage Delete(int id) { Spartan_BR_Rejection_Reason varSpartan_BR_Rejection_Reason = this.service.GetByKey(id, false); bool result = false; if (varSpartan_BR_Rejection_Reason == 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)); }
public HttpResponseMessage Post(Spartan_BR_Rejection_Reason varSpartan_BR_Rejection_Reason) { if (ModelState.IsValid) { var data = "-1"; try { data = Convert.ToString(this.service.Insert(varSpartan_BR_Rejection_Reason)); } 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_BR_Rejection_ReasonApiConsumer.SetAuthHeader(_tokenManager.Token); Spartan_BR_Rejection_Reason varSpartan_BR_Rejection_Reason = null; if (id.ToString() != "0") { string where = ""; } var result = _ISpartan_BR_Rejection_ReasonApiConsumer.Delete(id, null, null).Resource; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }