using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using dccdc.Models; using Dapper; namespace dccdc.DAL { public class yanzhengDal { public yanzhengModel getYZ(string id) { //throw new NotImplementedException(); string sql = "select * from yanzheng where pno=@id"; using (var conn = CommHelper.GetSqlConnection()) { var yzm = conn.Query(sql, new { id = id }).FirstOrDefault(); if (yzm != null) return yzm; else { yzm = new yanzhengModel { pno = id, yzcod = Guid.NewGuid().ToString("N") }; sql = "insert into yanzheng(pno,yzcod) values(@pno,@yzcod)"; conn.Execute(sql, yzm); return yzm; } } } public yanzhengModel yanZhen(string pno, string yzcod) { //throw new NotImplementedException(); string sql = "select * from yanzheng where pno=@pno and yzcod=@yzcod"; using (var conn = CommHelper.GetSqlConnection()) { var yzm = conn.Query(sql, new { pno = pno,yzcod=yzcod }).FirstOrDefault(); return yzm; } } } }