Files
Web_PMSApi_Server_V1_Prod/MyQianLiMa/Controllers/ValuesController.cs

60 lines
1.7 KiB
C#
Raw Normal View History

2025-11-20 15:56:30 +08:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using BLWWS.PMS;
namespace MoNi_QianLiMa.Controller
{
public class ValuesController : ApiController
{
[HttpPost()]
public string PostData(string hotelcode, string add_or_remove)
{
string msg = "";
try
{
var q = HttpContext.Current.Application["config"];
var D = (ConfigData)q;
if (add_or_remove.Equals("add"))
{
D.DuiJieInfos.RemoveAll(A=>A.hotel_code.Equals(hotelcode));
DuiJieInfo ddd = new DuiJieInfo();
ddd.hotel_code = hotelcode;
D.DuiJieInfos.Add(ddd);
}
else if (add_or_remove.Equals("remove"))
{
D.DuiJieInfos.RemoveAll(A => A.hotel_code.Equals(hotelcode));
}
string str = Newtonsoft.Json.JsonConvert.SerializeObject(D);
//var filepath = Path.Combine(Directory.GetCurrentDirectory(), "config.json");
string filepath1 = HttpContext.Current.Server.MapPath("~/config.json");
File.WriteAllText(filepath1, str);
msg = "sucess";
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
[HttpPost()]
public string PostDataOne()
{
return "hello";
}
public void SaveData2File()
{
}
}
}