public List <AdViewModel> GetFilteredList(AdBindingModel model) { if (model == null) { return(null); } using (var context = new AdBoardDatabase()) { return(context.Ads .Select(rec => new AdViewModel { Id = rec.Id, Name = rec.Name, Username = rec.User.Username, Price = rec.Price, Date = rec.Date, Address = rec.Address, Description = rec.Description, Type = rec.Type, SubType = rec.SubType, UserId = rec.UserId }) .ToList()); } }
public AdViewModel GetElement(AdBindingModel model) { if (model == null) { return(null); } using (var context = new AdBoardDatabase()) { var user = context.Ads .FirstOrDefault(rec => rec.Id == model.Id); return(user != null ? new AdViewModel { Id = rec.Id, Name = rec.Name, Username = rec.User.Username, Price = rec.Price, Date = rec.Date, Address = rec.Address, Description = rec.Description, Type = rec.Type, SubType = rec.SubType, UserId = rec.UserId } : null); } }
public void Insert(BalanceBindingModel model) { using (var context = new AdBoardDatabase()) { context.Balance.Add(CreateModel(model, new Balance())); context.SaveChanges(); } }
public void Insert(FavoritesBindingModel model) { using (var context = new AdBoardDatabase()) { context.Favorites.Add(CreateModel(model, new Favorites())); context.SaveChanges(); } }
public void Update(FavoritesBindingModel model) { using (var context = new AdBoardDatabase()) { var element = context.Favorites.FirstOrDefault(rec => rec.Id == model.Id); if (element == null) { throw new Exception("Сообщение не найдено"); } CreateModel(model, element); context.SaveChanges(); } }
public void Update(BalanceBindingModel model) { using (var context = new AdBoardDatabase()) { var element = context.Balance.FirstOrDefault(rec => rec.Id == model.Id); if (element == null) { throw new Exception("Баланс не найден"); } CreateModel(model, element); context.SaveChanges(); } }
public List <BalanceViewModel> GetFullList() { using (var context = new AdBoardDatabase()) { return(context.Balance.Select(rec => new BalanceViewModel { Id = rec.Id, CardFIO = rec.CardFIO, Username = context.Messages.Include(x => x.User).FirstOrDefault(x => x.UserId == x.UserId).User.Username, CardNumb = rec.CardFIO, CardDate = rec.CardFIO, }) .ToList()); } }
public List <MessagesViewModel> GetFullList() { using (var context = new AdBoardDatabase()) { return(context.Messages.Include(rec => rec.User).Select(rec => new MessagesViewModel { Id = rec.Id, Username = context.Messages.Include(x => x.User).FirstOrDefault(x => x.UserId == rec.UserId).User.Username, UserId = rec.UserId, Text = rec.Text, Date = rec.Date }) .ToList()); } }
public List <FavoritesViewModel> GetFullList() { using (var context = new AdBoardDatabase()) { return(context.Favorites.Include(rec => rec.User).Select(rec => new FavoritesViewModel { Id = rec.Id, Username = context.Favorites.Include(x => x.User).FirstOrDefault(x => x.UserId == rec.UserId).User.Username, UserId = rec.UserId, AdName = rec.AdName, Link = rec.Link }) .ToList()); } }
public void Delete(FavoritesBindingModel model) { using (var context = new AdBoardDatabase()) { Favorites element = context.Favorites.FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { context.Favorites.Remove(element); context.SaveChanges(); } else { throw new Exception("Сообщение не найдено"); } } }
public void Delete(BalanceBindingModel model) { using (var context = new AdBoardDatabase()) { Balance element = context.Balance.FirstOrDefault(rec => rec.Id == model.Id); if (element != null) { context.Balance.Remove(element); context.SaveChanges(); } else { throw new Exception("Клиент не найден"); } } }
public List <UsersViewModel> GetFullList() { using (var context = new AdBoardDatabase()) { return(context.Users.Select(rec => new UsersViewModel { Id = rec.Id, Username = rec.Username, Login = rec.Login, Password = rec.Password, Phone = rec.Phone, IsAdmin = rec.IsAdmin, IsVerificated = rec.IsVerificated }) .ToList()); } }
public List <BalanceViewModel> GetFilteredList(BalanceBindingModel model) { if (model == null) { return(null); } using (var context = new AdBoardDatabase()) { return(context.Balance .Select(rec => new BalanceViewModel { Id = rec.Id, CardFIO = rec.CardFIO, Username = rec.User.Username, CardNumb = rec.CardFIO, CardDate = rec.CardFIO, }) .ToList()); } }
public List <AdViewModel> GetFullList() { using (var context = new AdBoardDatabase()) { return(context.Ads.Select(rec => new AdViewModel { Id = rec.Id, Name = rec.Name, Username = context.Messages.Include(x => x.User).FirstOrDefault(x => x.UserId == x.UserId).User.Username, Price = rec.Price, Date = rec.Date, Address = rec.Address, Description = rec.Description, Type = rec.Type, SubType = rec.SubType, UserId = rec.UserId }) .ToList()); } }
public List <MessagesViewModel> GetFilteredList(MessagesBindingModel model) { if (model == null) { return(null); } using (var context = new AdBoardDatabase()) { return(context.Messages .Include(rec => rec.User) .Where(rec => rec.UserId == model.UserId) .Select(rec => new MessagesViewModel { Id = rec.Id, Username = rec.User.Username, UserId = rec.UserId, Text = rec.Text, Date = rec.Date }) .ToList()); } }
public BalanceViewModel GetElement(BalanceBindingModel model) { if (model == null) { return(null); } using (var context = new AdBoardDatabase()) { var user = context.Balance .FirstOrDefault(rec => rec.Id == model.Id); return(user != null ? new BalanceViewModel { Id = rec.Id, CardFIO = rec.CardFIO, Username = rec.User.Username, CardNumb = rec.CardFIO, CardDate = rec.CardFIO, } : null); } }
public MessagesViewModel GetElement(MessagesBindingModel model) { if (model == null) { return(null); } using (var context = new AdBoardDatabase()) { var message = context.Messages .FirstOrDefault(rec => rec.Id == model.Id); return(message != null ? new MessagesViewModel { Id = message.Id, Username = context.Messages.Include(x => x.User).FirstOrDefault(x => x.UserId == x.UserId).User.Username, UserId = message.UserId, Text = message.Text, Date = message.Date } : null); } }
public FavoritesViewModel GetElement(FavoritesBindingModel model) { if (model == null) { return(null); } using (var context = new AdBoardDatabase()) { var message = context.Favorites .FirstOrDefault(rec => rec.Id == model.Id); return(message != null ? new FavoritesViewModel { Id = rec.Id, Username = context.Favorites.Include(x => x.User).FirstOrDefault(x => x.UserId == rec.UserId).User.Username, UserId = rec.UserId, AdName = rec.AdName, Link = rec.Link } : null); } }
public List <FavoritesViewModel> GetFilteredList(FavoritesBindingModel model) { if (model == null) { return(null); } using (var context = new AdBoardDatabase()) { return(context.Favorites .Include(rec => rec.User) .Where(rec => rec.UserId == model.UserId) .Select(rec => new FavoritesViewModel { Id = rec.Id, Username = context.Favorites.Include(x => x.User).FirstOrDefault(x => x.UserId == rec.UserId).User.Username, UserId = rec.UserId, AdName = rec.AdName, Link = rec.Link }) .ToList()); } }
public List <UsersViewModel> GetFilteredList(UsersBindingModel model) { if (model == null) { return(null); } using (var context = new AdBoardDatabase()) { return(context.Users .Where(rec => rec.Login == model.Login && rec.Password == model.Password) .Select(rec => new UsersViewModel { Id = rec.Id, Username = rec.Username, Login = rec.Login, Password = rec.Password, Phone = rec.Phone, IsAdmin = rec.IsAdmin, IsVerificated = rec.IsVerificated }) .ToList()); } }
public UsersViewModel GetElement(UsersBindingModel model) { if (model == null) { return(null); } using (var context = new AdBoardDatabase()) { var user = context.Users .FirstOrDefault(rec => rec.Login == model.Login || rec.Id == model.Id); return(user != null ? new UsersViewModel { Id = user.Id, Username = user.Username, Login = user.Login, Password = user.Password, Phone = user.Phone, IsAdmin = user.IsAdmin, IsVerificated = user.IsVerificated } : null); } }