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