初始化
This commit is contained in:
60
MyQianLiMa/Controllers/ValuesController.cs
Normal file
60
MyQianLiMa/Controllers/ValuesController.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
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()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user