/// <summary> /// 添加 Customer /// </summary> public bool CustomerInsert(Customer model) { string sql = @" INSERT INTO Customer ( Id,CustomerName,AddTime,IsDelete,CustomerLevel, PhoneNo,Token,VipPrice,Remark ) VALUES ( @Id,@CustomerName,@AddTime,@IsDelete,@CustomerLevel, @PhoneNo,@Token,@VipPrice,@Remark ) "; DynamicParameters param = new DynamicParameters(); param.Add("@Id", model.Id, DbType.Guid); param.Add("@CustomerName", model.CustomerName, DbType.String); param.Add("@AddTime", model.AddTime, DbType.DateTime); param.Add("@IsDelete", model.IsDelete, DbType.Boolean); param.Add("@CustomerLevel", model.CustomerLevel, DbType.Byte); param.Add("@PhoneNo", model.PhoneNo, DbType.String); param.Add("@Token", model.Token, DbType.String); param.Add("@VipPrice", model.VipPrice, DbType.Double); param.Add("@Remark", model.Remark, DbType.String); var result = DataBaseAccessCommand.ExecuteCommand(sql, param); return result < 0 ? false : true; }
public void TestMethod_Update() { Customer model = new Customer(); model.Id = Guid.Parse("a8097724-fabe-4431-b4ec-56364f207b78"); model.CustomerName = "rose"; model.PhoneNo = "13147306612"; var result = dal.CustomerUpdate(model); Assert.IsTrue(result); }
public void TestMethod_Insert() { Customer model = new Customer() { Id = Guid.NewGuid(), AddTime = DateTime.Now, CustomerLevel = 1, CustomerName = "ROSE", IsDelete = false, PhoneNo = "17727510587", VipPrice = 10.5, Token = Guid.NewGuid().ToString(), Remark = "测试" }; var result = dal.CustomerInsert(model); Assert.IsTrue(result); }
/// <summary> /// 修改 Customer /// </summary> public bool CustomerUpdate(Customer model) { string sql = @" UPDATE Customer SET CustomerName=@CustomerName,PhoneNo=@PhoneNo,AddTime=@AddTime,Remark=@Remark WHERE Id=@Id "; DynamicParameters param = new DynamicParameters(); param.Add("@Id", model.Id, DbType.Guid); param.Add("@CustomerName", model.CustomerName, DbType.String); param.Add("@PhoneNo", model.PhoneNo, DbType.String); param.Add("@AddTime", DateTime.Now, DbType.DateTime); param.Add("@Remark", "测试修改", DbType.String); var result = DataBaseAccessCommand.ExecuteCommand(sql, param); return result < 0 ? false : true; }