public void RejectAdv(PropertyAdv entity) { using (PropertyHubContext context = new PropertyHubContext()) { context.Entry(entity.Status).State = EntityState.Unchanged; context.Update(entity); context.SaveChanges(); } }
public PropertyAdv AddAdvertizement(PropertyAdv entity) { using (PropertyHubContext context = new PropertyHubContext()) { context.Entry(entity.Status).State = EntityState.Unchanged; context.Entry(entity.Type).State = EntityState.Unchanged; context.Entry(entity.Neighborhood).State = EntityState.Unchanged; context.Entry(entity.PostedBy).State = EntityState.Unchanged; context.Entry(entity.Area.PropertyAreaUnit).State = EntityState.Unchanged; context.Add(entity); context.SaveChanges(); return(entity); } }
public PropertyAdv GetAdvertizement(int id) { using (PropertyHubContext context = new PropertyHubContext()) { PropertyAdv found = (from adv in context.PropertyAdvs .Include(adv => adv.Images) .Include(adv => adv.Neighborhood.City.Province.Country) .Include(adv => adv.Area.PropertyAreaUnit) .Include(adv => adv.PostedBy.Role) .Include(adv => adv.Status) .Include(adv => adv.Type) where adv.Id == id select adv).FirstOrDefault(); return(found); } }