Пример #1
0
        public string Save([FromBody] Models.TableConfiguration value)
        {
            try
            {
                if (value == null)
                {
                    return("Empty");
                }

                var filePath = System.Web.Hosting.HostingEnvironment.MapPath(path);
                var document = value.Id + ".json";


                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }

                using (StreamWriter writer = new StreamWriter(filePath + document, false))
                {
                    writer.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(value));
                }
                return(filePath + document);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Пример #2
0
        public string Delete([FromBody] Models.TableConfiguration value)
        {
            try
            {
                if (value == null)
                {
                    return("Empty");
                }

                var filePath = System.Web.Hosting.HostingEnvironment.MapPath(path);
                var document = value.Id + ".json";

                File.Delete(filePath + document);
                return(filePath + document);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Пример #3
0
        public void ActivateDeActivateConfig([FromBody] Models.TableConfiguration value)
        {
// TODO alleen active omzetten. niet hele config update
            if (value == null)
            {
                return;
            }

            var filePath = System.Web.Hosting.HostingEnvironment.MapPath(path);
            var document = value.Id + ".json";


            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }

            using (StreamWriter writer = new StreamWriter(filePath + document, false))
            {
                writer.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(value));
            }
        }