public MemberVo insert(MemberVo input) { using (var db = new MainDb()) { db.members.Add(input); db.SaveChanges(); return input; } }
public MemberVo update(MemberVo input, int? memberId= null) { using (var db = new MainDb()) { if (memberId == null) memberId = input.memberId; var res = db.members.FirstOrDefault(e => e.memberId == memberId); if (res == null) return null; input.created = res.created; // input.createdBy = res.createdBy; db.Entry(res).CurrentValues.SetValues(input); db.SaveChanges(); return res; } }