public HttpResponseMessage Post(Detalle_Identificacion_Oficial_Medicos varDetalle_Identificacion_Oficial_Medicos)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varDetalle_Identificacion_Oficial_Medicos));
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsDetalle_Identificacion_Oficial_Medicos", new JavaScriptSerializer().Serialize(varDetalle_Identificacion_Oficial_Medicos), true);
                    serviceBitacora.Insert(bitacora);
                }
                catch (ServiceException ex)
                {
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsDetalle_Identificacion_Oficial_Medicos", new JavaScriptSerializer().Serialize(varDetalle_Identificacion_Oficial_Medicos), 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_InsDetalle_Identificacion_Oficial_Medicos", new JavaScriptSerializer().Serialize(varDetalle_Identificacion_Oficial_Medicos), false, errors.ToString());
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
        public HttpResponseMessage Delete(int id)
        {
            Detalle_Identificacion_Oficial_Medicos varDetalle_Identificacion_Oficial_Medicos = this.service.GetByKey(id, false);
            bool result = false;

            if (varDetalle_Identificacion_Oficial_Medicos == 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_DelDetalle_Identificacion_Oficial_Medicos", new JavaScriptSerializer().Serialize(varDetalle_Identificacion_Oficial_Medicos), result);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelDetalle_Identificacion_Oficial_Medicos", new JavaScriptSerializer().Serialize(varDetalle_Identificacion_Oficial_Medicos), result, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Beispiel #3
0
        public ActionResult Post(bool IsNew, Detalle_Identificacion_Oficial_MedicosModel varDetalle_Identificacion_Oficial_Medicos)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IDetalle_Identificacion_Oficial_MedicosApiConsumer.SetAuthHeader(_tokenManager.Token);


                    if (varDetalle_Identificacion_Oficial_Medicos.DocumentoRemoveAttachment != 0 && varDetalle_Identificacion_Oficial_Medicos.DocumentoFile == null)
                    {
                        varDetalle_Identificacion_Oficial_Medicos.Documento = 0;
                    }

                    if (varDetalle_Identificacion_Oficial_Medicos.DocumentoFile != null)
                    {
                        var fileAsBytes = HttpPostedFileHelper.GetPostedFileAsBytes(varDetalle_Identificacion_Oficial_Medicos.DocumentoFile);
                        _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token);
                        varDetalle_Identificacion_Oficial_Medicos.Documento = (int)_ISpartane_FileApiConsumer.Insert(new Spartane_File()
                        {
                            File        = fileAsBytes,
                            Description = varDetalle_Identificacion_Oficial_Medicos.DocumentoFile.FileName,
                            File_Size   = fileAsBytes.Length
                        }).Resource;
                    }


                    var result = "";
                    var Detalle_Identificacion_Oficial_MedicosInfo = new Detalle_Identificacion_Oficial_Medicos
                    {
                        Folio = varDetalle_Identificacion_Oficial_Medicos.Folio
                        , Tipo_de_Identificacion_Oficial = varDetalle_Identificacion_Oficial_Medicos.Tipo_de_Identificacion_Oficial
                        , Documento = (varDetalle_Identificacion_Oficial_Medicos.Documento.HasValue && varDetalle_Identificacion_Oficial_Medicos.Documento != 0) ? ((int?)Convert.ToInt32(varDetalle_Identificacion_Oficial_Medicos.Documento.Value)) : null
                    };

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

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public HttpResponseMessage PutTunnel(Detalle_Identificacion_Oficial_Medicos 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 Get_Datos_Generales(int id)
        {
            Detalle_Identificacion_Oficial_Medicos entity = this.service.ListaSelAll(1, 1, "Detalle_Identificacion_Oficial_Medicos.Folio='" + id.ToString() + "'", "").Detalle_Identificacion_Oficial_Medicoss.First();
            Detalle_Identificacion_Oficial_Medicos result = new Detalle_Identificacion_Oficial_Medicos();

            result.Folio = entity.Folio;
            result.Tipo_de_Identificacion_Oficial = entity.Tipo_de_Identificacion_Oficial;
            result.Tipo_de_Identificacion_Oficial_Identificaciones_Oficiales = entity.Tipo_de_Identificacion_Oficial_Identificaciones_Oficiales;
            result.Documento = entity.Documento;
            result.Documento_Spartane_File = entity.Documento_Spartane_File;

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

            try
            {
                data = Convert.ToString(this.service.Update_Datos_Generales(varDetalle_Identificacion_Oficial_Medicos_Datos_Generales));
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varDetalle_Identificacion_Oficial_Medicos_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdDetalle_Identificacion_Oficial_Medicos", new JavaScriptSerializer().Serialize(varDetalle_Identificacion_Oficial_Medicos_Datos_Generales), true);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, varDetalle_Identificacion_Oficial_Medicos_Datos_Generales.Folio, BitacoraHelper.TypeSql.UPDATE, "sp_UpdDetalle_Identificacion_Oficial_Medicos", new JavaScriptSerializer().Serialize(varDetalle_Identificacion_Oficial_Medicos_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 Detalle_Identificacion_Oficial_MedicosGenerateID()
        {
            Detalle_Identificacion_Oficial_Medicos varDetalle_Identificacion_Oficial_Medicos = new Detalle_Identificacion_Oficial_Medicos();
            var data = "-1";

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

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

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