Пример #1
0
        public JsonResult SaveOrUpdateInterestInformation(SaveInterestInformationFlt oSaveInterestInformationFlt)
        {
            var DataString = System.Web.HttpContext.Current.Request.Params.Get("JsonMaster").ToString();

            List <HttpPostedFile> adjuntoList = null;

            if (System.Web.HttpContext.Current.Request.Files.Count > 0)
            {
                adjuntoList = new List <HttpPostedFile>(System.Web.HttpContext.Current.Request.Files.GetMultiple("dataFile"));
            }

            var response = _ISafeService.SaveInterestInformation(DataString, adjuntoList);

            return(Json(new
            {
                response
            }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ApiResponse SaveInterestInformation(string stringJson, List <HttpPostedFile> files)
        {
            ApiResponse response;

            try
            {
                int IdUsuario = Int32.Parse(SessionHelper.GetUser().ToString());
                var IdEmpresa = int.Parse(SessionHelper.GetValueSession(Settings.Session.IdEmpresa).ToString());
                SaveInterestInformationFlt saveEntity = JsonConvert.DeserializeObject <SaveInterestInformationFlt>(stringJson);
                saveEntity.IdUsuarioRegistro = IdUsuario;
                saveEntity.IdEmpresa         = IdEmpresa;
                string folder         = Settings.GetKey(Settings.KEY.InformacionInteres);
                string FolderGenerate = CreateFolder(TypeFolder.generated, folder);
                foreach (var archivos in files)
                {
                    string routeFile = string.Format("{0}\\{1}_{2}", FolderGenerate, DateTime.Now.ToString("HH:mm:ss").Replace(':', '_'), archivos.FileName);
                    if (File.Exists(routeFile))
                    {
                        File.Delete(routeFile);
                    }
                    archivos.SaveAs(routeFile);
                    saveEntity.RutaArchivo = routeFile;
                }

                var _JsonRequest = JsonConvert.SerializeObject(saveEntity, Formatting.Indented);
                var _response    = ConsumeService.ConsumirAPIConToken(
                    Enums.Method.POST,
                    _JsonRequest,
                    _UrlService,
                    _ServicePrefix,
                    String.Format(UrlService.UrlSaveInterestInformation),
                    _LoginService.GetToken());

                response = JsonConvert.DeserializeObject <ApiResponse>(_response);
            }
            catch (Exception ex)
            {
                response = new ApiResponse("Error", ex.Message);
            }
            return(response);
        }