public void DeleteHousePic(long housePicId) { using (WarmHomeContext db = new WarmHomeContext()) { HousepicEntity entity = new HousepicEntity(); entity.Id = housePicId; db.Entry(entity).State = EntityState.Deleted; db.SaveChanges(); } }
public long AddNewHousePic(HousePicDTO housePic) { HousepicEntity hpEntity = new HousepicEntity(); hpEntity.HouseId = housePic.HouseId; hpEntity.ThumbUrl = housePic.ThumbUrl; hpEntity.Url = housePic.Url; using (MyDbContext ctx = new MyDbContext()) { ctx.Housepics.Add(hpEntity); ctx.SaveChanges(); return(hpEntity.Id); } }
public long AddNewHousePic(HousePicDTO housePic) { using (WarmHomeContext db = new WarmHomeContext()) { HousepicEntity entity = new HousepicEntity() { ThumbUrl = housePic.ThumbUrl, Url = housePic.Url, HouseId = housePic.HouseId }; db.Housepics.Add(entity); db.SaveChanges(); return(entity.Id); } }