public List <SubCatagory> GeSubtCatagorie() { using (DemoContaxt _context = new DemoContaxt()) { return((from ct in _context.SubCatagories select ct).ToList()); } }
public List <Role> GetRoles() { using (DemoContaxt _context = new DemoContaxt()) { return((from r in _context.Roles select r).ToList()); } }
public User GetUser(string loginId, string password) { using (DemoContaxt _context = new DemoContaxt()) { return((from u in _context.Useres.Include("Role").Include("Address.City.Province.Country") where u.loginId == loginId && u.Password == password select u).FirstOrDefault()); } }
public List <User> GetUseres() { using (DemoContaxt _context = new DemoContaxt()) { return((from u in _context.Useres.Include("Role").Include("Address.City.Province.Country") select u).ToList()); } }
public List <AdvertisementType> GetAdvertisementTypes() { using (DemoContaxt _context = new DemoContaxt()) { return((from adtype in _context.Types select adtype).ToList()); } }
public ActionResult Delete(int id) { DemoContaxt c = new DemoContaxt(); var rem = c.Advertisements.Where(x => x.Id.Equals(id)).SingleOrDefault(); c.Advertisements.Remove(rem); c.SaveChanges(); return(View()); }
public List <SubCatagory> GetSubCatagories(int id) { using (DemoContaxt _context = new DemoContaxt()) { return((from sct in _context.SubCatagories .Include("Catagory") where sct.Catagory.Id == id select sct).ToList()); } }
public Advertisement GetAllAdvertisementsById(int id) { using (DemoContaxt _context = new DemoContaxt()) { return((from adv in _context.Advertisements .Include(a => a.Images) where adv.Id == id select adv).FirstOrDefault()); } }
//Remove the Images public void Delete(Advertisement adv) { using (DemoContaxt con = new DemoContaxt()) { Advertisement delete = (from c in con.Advertisements .Include(a => a.Images) where c.Id == adv.Id select c).FirstOrDefault(); con.Advertisements.Remove(delete); con.SaveChanges(); } }
public void Addd(Advertisement advertisementObj) { using (DemoContaxt _context = new DemoContaxt()) { _context.Entry(advertisementObj.City).State = EntityState.Unchanged; _context.Entry(advertisementObj.Type).State = EntityState.Unchanged; _context.Entry(advertisementObj.SubCatagory).State = EntityState.Unchanged; _context.Entry(advertisementObj.Status).State = EntityState.Unchanged; _context.Entry(advertisementObj.User).State = EntityState.Unchanged; _context.Advertisements.Add(advertisementObj); _context.SaveChanges(); } }
public List <Advertisement> GetLatestAllAdvertisements(int count) { using (DemoContaxt _context = new DemoContaxt()) { return((from adv in _context.Advertisements .Include(a => a.SubCatagory.Catagory) .Include(a => a.City.Province.Country) .Include(a => a.User) .Include(a => a.Images) .Include(a => a.Status) .Include(a => a.Type) select adv).Take(count).ToList()); } }
public List <Advertisement> GetAllAdvertisementsByCatagory(Catagory catagory) { using (DemoContaxt _context = new DemoContaxt()) { return((from adv in _context.Advertisements .Include(a => a.SubCatagory.Catagory) .Include(a => a.City.Province.Country) .Include(a => a.User) .Include(a => a.Images) .Include(a => a.Status) .Include(a => a.Type) where adv.SubCatagory.Catagory.Id == catagory.Id select adv).ToList()); } }