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