public void AddOrUpdate(IFlatModel model) { try { using (var ctx = new DBProjectEntities()) { var newObject = ctx.Mieszkania.Find(model.Id); if (newObject == null) { newObject = Mapper.ModelMapper.Mapper.Map <Mieszkania>(model); ctx.Mieszkania.Add(newObject); } else { newObject.id_budynku = model.id_budynku; newObject.metraz = model.metraz; newObject.numer = model.numer; newObject.opis = model.opis; } ctx.SaveChanges(); } } catch (Exception ex) { Logger.Log(ex.Message); } }
public bool Remove(IFlatModel model) { return(Remove(model.Id)); }