public JsonResult StationEdit() { var stationJson = Request["station"]; var station = JsonHelper.Deserialize <BaseStation>(stationJson); var updateType = station.Id > 0 ? DataUpdateType.Update : DataUpdateType.Insert; // 更新车站 var stationUpdateRes = false; var stationBll = new BaseStationBll(); if (station.Id > 0) { stationUpdateRes = stationBll.Update(station); } else { var condition = string.Format("StationName='{0}' AND IsDelete=0", station.StationName); if (stationBll.Exists(condition)) { return(Json(ErrorModel.ExistSameItem)); } var insertedStation = stationBll.Insert(station); stationUpdateRes = insertedStation.Id > 0; } // 更新文件 if (stationUpdateRes) { // 写入更新记录 DataUpdateLog.SingleUpdate(typeof(BaseStation).Name, station.Id, updateType); var filesJson = Request["files"]; var files = JsonHelper.Deserialize <StationFiles[]>(filesJson); if (!files.Any()) { return(Json(ErrorModel.OperateSuccess)); } files.ForEach(f => { f.StationId = station.Id; }); var filesToInsert = files.Where(f => f.Id == 0); var filesBll = new StationFilesBll(); var maxId = (int)filesBll.GetMaxId(); filesBll.BulkInsert(filesToInsert); // 写入更新记录 DataUpdateLog.BulkUpdate(typeof(StationFiles).Name, maxId); return(Json(ErrorModel.OperateSuccess)); } return(Json(ErrorModel.OperateFailed)); }
public JsonResult DeleteStationFiles(int fileId) { var stationFilesBll = new StationFilesBll(); var success = stationFilesBll.DeleteSoftly(fileId); if (success) { DataUpdateLog.SingleUpdate(typeof(StationFiles).Name, fileId, DataUpdateType.Delete); return(Json(ErrorModel.OperateSuccess)); } return(Json(ErrorModel.OperateFailed)); }
public JsonResult GetStationInfo(int stationId) { var stationBll = new BaseStationBll(); var station = stationBll.QuerySingle(stationId); if (station != null) { var stationFileBll = new StationFilesBll(); var files = stationFileBll.QueryList(string.Format("StationId={0} AND IsDelete=0", stationId)); var jsonObj = new { station = station, files = files }; var response = ErrorModel.GetDataSuccess(jsonObj); return(Json(response)); } return(Json(ErrorModel.GetDataFailed)); }