public HttpResponseMessage Post(MS_Semanas_Planes varMS_Semanas_Planes)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varMS_Semanas_Planes));
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Semanas_Planes", new JavaScriptSerializer().Serialize(varMS_Semanas_Planes), true);
                    serviceBitacora.Insert(bitacora);
                }
                catch (ServiceException ex)
                {
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Semanas_Planes", new JavaScriptSerializer().Serialize(varMS_Semanas_Planes), true);
                    serviceBitacora.Insert(bitacora);
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                var errors   = ModelState.SelectMany(m => m.Value.Errors.Select(err => err.ErrorMessage != string.Empty ? err.ErrorMessage : err.Exception.Message).ToList()).ToList();
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsMS_Semanas_Planes", new JavaScriptSerializer().Serialize(varMS_Semanas_Planes), false, errors.ToString());
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
        public HttpResponseMessage Delete(int id)
        {
            MS_Semanas_Planes varMS_Semanas_Planes = this.service.GetByKey(id, false);
            bool result = false;

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

            try
            {
                result = this.service.Delete(id);//, globalData, dataReference);
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelMS_Semanas_Planes", new JavaScriptSerializer().Serialize(varMS_Semanas_Planes), result);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelMS_Semanas_Planes", new JavaScriptSerializer().Serialize(varMS_Semanas_Planes), result, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
        public ActionResult Post(bool IsNew, MS_Semanas_PlanesModel varMS_Semanas_Planes)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IMS_Semanas_PlanesApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var MS_Semanas_PlanesInfo = new MS_Semanas_Planes
                    {
                        Folio     = varMS_Semanas_Planes.Folio
                        , Semanas = varMS_Semanas_Planes.Semanas
                    };

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

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            MS_Semanas_Planes entity = this.service.ListaSelAll(1, 1, "MS_Semanas_Planes.Folio='" + id.ToString() + "'", "").MS_Semanas_Planess.First();
            MS_Semanas_Planes result = new MS_Semanas_Planes();

            result.Folio   = entity.Folio;
            result.Semanas = entity.Semanas;
            result.Semanas_Semanas_Planes = entity.Semanas_Semanas_Planes;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
        public HttpResponseMessage PutTunnel(MS_Semanas_Planes 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.Folio), "PUT"
                                             , dataString);

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
        public HttpResponseMessage Put_Datos_Generales(MS_Semanas_Planes varMS_Semanas_Planes_Datos_Generales)
        {
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Update_Datos_Generales(varMS_Semanas_Planes_Datos_Generales));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMS_Semanas_Planes_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMS_Semanas_Planes", new JavaScriptSerializer().Serialize(varMS_Semanas_Planes_Datos_Generales), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varMS_Semanas_Planes_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdMS_Semanas_Planes", new JavaScriptSerializer().Serialize(varMS_Semanas_Planes_Datos_Generales), false, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
        public HttpResponseMessage MS_Semanas_PlanesGenerateID()
        {
            MS_Semanas_Planes varMS_Semanas_Planes = new MS_Semanas_Planes();
            var data = "-1";

            try
            {
                data = Convert.ToString(this.service.Insert(varMS_Semanas_Planes));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_MS_Semanas_PlanesGenerateID", new JavaScriptSerializer().Serialize(varMS_Semanas_Planes), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_MS_Semanas_PlanesGenerateID", new JavaScriptSerializer().Serialize(varMS_Semanas_Planes), true);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
        }
        public ActionResult Delete(int id)
        {
            try
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _IMS_Semanas_PlanesApiConsumer.SetAuthHeader(_tokenManager.Token);

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