public Get_OutGiveBackLendingInfo Recieve(string data) { Get_OutGiveBackLendingInfo json = new Get_OutGiveBackLendingInfo(); try { Get_InGiveBackLendingInfo input = Newtonsoft.Json.JsonConvert.DeserializeObject <Get_InGiveBackLendingInfo>(data); foreach (LendingInfoDetail l in input.lendingDetailList) { if (!db.CheckReturnAble(input.TrainmanGUID, l)) { json.resultStr = "提交失败:未找到" + l.strLendingTypeAlias + " " + l.strLendingExInfo + "的借用记录!"; throw new ArgumentOutOfRangeException("未找到" + l.strLendingTypeAlias + " " + l.strLendingExInfo + "的借用记录!"); } } db.GiveBackDetail(input.lendingDetailList); foreach (LendingInfoDetail l in input.lendingDetailList) { db.UpdateLendingInfoRemark(l.strLendingInfoGUID, input.remark); } json.result = "0"; json.resultStr = "返回成功"; } catch (Exception ex) { json.result = "1"; //json.resultStr = "提交失败:" ; } return(json); }
public void CheckReturnAbleTest() { // string ConnectionString = string.Empty; // TODO: 初始化为适当的值 DBLendingInfoDetail target = new DBLendingInfoDetail(connstr); // TODO: 初始化为适当的值 string TrainmanGUID = string.Empty; // TODO: 初始化为适当的值 TrainmanGUID = "08809D42-3B1C-4318-B818-756A7ED04300"; LendingInfoDetail newmodel = null; // TODO: 初始化为适当的值 newmodel = new LendingInfoDetail(); newmodel.dtBorrwoTime = DateTime.Today; newmodel.dtModifyTime = DateTime.Today; newmodel.nBorrowVerifyType = 0; newmodel.nKeepMunites = 20; newmodel.nLendingType = 0; newmodel.nReturnState = 1; newmodel.strBorrowVerifyTypeName = "1"; newmodel.strGiveBackTrainmanGUID = "08809D42-3B1C-4318-B818-756A7ED04300"; newmodel.strGiveBackTrainmanName = "张勇"; newmodel.strGiveBackTrainmanNumber = "2300679"; newmodel.strGiveBackVerifyTypeName = "1"; newmodel.strGUID = Guid.NewGuid().ToString(); newmodel.strLenderGUID = ""; newmodel.strLenderName = ""; newmodel.strLenderNumber = ""; newmodel.strLendingExInfo = 420; newmodel.strLendingInfoGUID = ""; newmodel.strLendingTypeAlias = ""; newmodel.strLendingTypeName = ""; newmodel.strStateName = ""; newmodel.strTrainmanGUID = "08809D42-3B1C-4318-B818-756A7ED04300"; newmodel.strTrainmanName = "张勇"; newmodel.strTrainmanNumber = "2300679"; newmodel.strWorkShopGUID = "3b50bf66-dabb-48c0-8b6d-05db80591090"; bool expected = true; // TODO: 初始化为适当的值 bool actual; actual = target.CheckReturnAble(TrainmanGUID, newmodel); Assert.AreEqual(expected, actual); //Assert.Inconclusive("验证此测试方法的正确性。"); }