public Get_OutSendGoods Send(string data) { Get_OutSendGoods json = new Get_OutSendGoods(); try { Get_InSendGoods input = Newtonsoft.Json.JsonConvert.DeserializeObject <Get_InSendGoods>(data); foreach (LendingInfoDetail l in input.lendingDetailList) { if (db.CheckLendAble(l, input.WorkShopGUID)) { json.resultStr = "提交失败:" + l.strLendingTypeAlias + " " + l.strLendingExInfo + "已经出借,无法再次借出!"; throw new ArgumentOutOfRangeException(l.strLendingTypeAlias + " " + l.strLendingExInfo + "已经出借,无法再次借出!"); } if (input.UsesGoodsRange) { if (!db.IsGoodInRange(l.nLendingType, l.strLendingExInfo, input.WorkShopGUID)) { json.resultStr = "提交失败:" + l.strLendingTypeAlias + " " + l.strLendingExInfo + "物品编码不在指定的编码范围内,请检查!"; throw new ArgumentOutOfRangeException(l.strLendingTypeAlias + " " + l.strLendingExInfo + "物品编码不在指定的编码范围内,请检查!"); } } } db.SendLendingInfo(input.TrainmanGUID, input.remark, input.lendingDetailList); json.result = "0"; json.resultStr = "返回成功"; } catch (Exception ex) { json.result = "1"; // json.resultStr = "提交失败:" + ex.Message; } return(json); }
public void CheckLendAbleTest() { // string ConnectionString = string.Empty; // TODO: 初始化为适当的值 DBLendingInfoDetail target = new DBLendingInfoDetail(connstr); // TODO: 初始化为适当的值 LendingInfoDetail newmodel = null; // TODO: 初始化为适当的值 string strWorkShop = string.Empty; // TODO: 初始化为适当的值 strWorkShop = "3b50bf66-dabb-48c0-8b6d-05db80591090"; 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"; strWorkShop = "3b50bf66-dabb-48c0-8b6d-05db80591090"; bool expected = true; // TODO: 初始化为适当的值 bool actual; actual = target.CheckLendAble(newmodel, strWorkShop); Assert.AreEqual(expected, actual); // Assert.Inconclusive("验证此测试方法的正确性。"); }