public BasicPropertyBindingModel Add(BasicPropertyBindingModel item) { using (ApplicationDbContext db = new ApplicationDbContext()) { Property property = Mapper.Map<Property>(item); db.Properties.Add(property); db.SaveChanges(); return Mapper.Map<BasicPropertyBindingModel>(property); } }
public void Update(int id, BasicPropertyBindingModel item) { using (ApplicationDbContext db = new ApplicationDbContext()) { Property property = Mapper.Map<Property>(item); var entry = db.Entry(property); entry.State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { //todo check if exists throw; } } }