Beispiel #1
0
 /// <summary>
 /// Получение модели лодки из БД по названию
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public BoatModel GetByName(string name)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.BoatModels.FirstOrDefault(x => x.Name == name));
     }
 }
Beispiel #2
0
 /// <summary>
 /// Получить все заявки для лодки
 /// </summary>
 /// <param name="boat_id"></param>
 /// <returns></returns>
 public IEnumerable <Message> GetAllByBoat(int boat_id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Messages.Where(x => x.BoatId == boat_id && x.Type.Equals("message")).ToList());
     }
 }
Beispiel #3
0
 /// <summary>
 /// Получение модели лодки из БД по Id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public BoatModel GetById(int id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.BoatModels.FirstOrDefault(x => x.Id == id));
     }
 }
Beispiel #4
0
 /// <summary>
 /// Получение лодок из БД для указанного пользователя
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Boat> Boat_GetByUserId(int owner_id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Boats.Where(x => x.OwnerId == owner_id).ToList());
     }
 }
Beispiel #5
0
 /// <summary>
 /// Получение всех новостей из БД
 /// </summary>
 /// <returns></returns>
 public IEnumerable <News> GetAll()
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.News.ToList());
     }
 }
Beispiel #6
0
 /// <summary>
 /// Возвращает последнюю лодку из списка
 /// </summary>
 /// <returns></returns>
 public Boat Boat_GetLast()
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Boats.ToList().Last());
     }
 }
Beispiel #7
0
 /// <summary>
 /// Получение всех лодок из БД
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Boat> Boat_GetAll(string kind)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Boats.Where(x => x.Kind.Equals(kind)).ToList());
     }
 }
Beispiel #8
0
 /// <summary>
 /// Получение аккаунта из БД по электронному адресу
 /// </summary>
 /// <param name="email"></param>
 /// <returns></returns>
 public Account GetByEmail(string email)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Accounts.FirstOrDefault(x => x.Email == email));
     }
 }
Beispiel #9
0
 /// <summary>
 /// Получение аккаунта из БД по логину
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Account GetByLogin(string login)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Accounts.FirstOrDefault(x => x.Login == login));
     }
 }
Beispiel #10
0
 /// <summary>
 /// Получение аккаунта из БД по Id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Account GetById(int id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Accounts.FirstOrDefault(x => x.Id == id));
     }
 }
Beispiel #11
0
 /// <summary>
 /// Получение заявки из БД по Id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Message GetById(int id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Messages.FirstOrDefault(x => x.Id == id));
     }
 }
Beispiel #12
0
 /// <summary>
 /// Получение всех моделей лодок из БД
 /// </summary>
 /// <returns></returns>
 public IEnumerable <BoatModel> Read()
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.BoatModels.ToList());
     }
 }
 /// <summary>
 /// Получение текстового блока из БД по Id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public TextBlock Read(int id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.NewsTexts.FirstOrDefault(x => x.Id == id));
     }
 }
Beispiel #14
0
 /// <summary>
 /// Получение всех заявок из БД
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Message> Read()
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Messages.ToList());
     }
 }
Beispiel #15
0
 /// <summary>
 /// Получить все исходящие заявки от пользователя
 /// </summary>
 /// <param name="user_id"></param>
 /// <returns></returns>
 public IEnumerable <Message> GetAllOutbox(int user_id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Messages.Where(x => x.FromId == user_id && x.Type.Equals("recall")).ToList());
     }
 }
Beispiel #16
0
 /// <summary>
 /// Получение всех договоров аренды из БД
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Rent> Read()
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Rents.ToList());
     }
 }
Beispiel #17
0
 /// <summary>
 /// Получение договора аренды из БД по Id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Rent Read(int id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Rents.FirstOrDefault(x => x.Id == id));
     }
 }
Beispiel #18
0
 /// <summary>
 /// Получение всех договоров аренды для указанной лодки
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Rent> GetByOwnerId(int owner_id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Rents.Where(x => x.RecallId == owner_id).ToList());
     }
 }
Beispiel #19
0
 /// <summary>
 /// Получение изображения из БД по Id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Image GetFirstByOwnerId(int owner_id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.Images.Where(x => x.OwnerId == owner_id).FirstOrDefault());
     }
 }
 /// <summary>
 /// Получение всех текстовых блоков из БД
 /// </summary>
 /// <returns></returns>
 public IEnumerable <TextBlock> GetByOwnerId(int owner_id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         return(db.NewsTexts.Where(x => x.OwnerId == owner_id).ToList());
     }
 }
Beispiel #21
0
 /// <summary>
 /// Получение всех изображений из БД
 /// </summary>
 /// <returns></returns>
 public IEnumerable <Image> GetAllByOwnerId(int owner_id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         var result = db.Images.Where(x => x.OwnerId == owner_id).ToList();
         return(result);
     }
 }
 /// <summary>
 /// Обновление данных текстового блока в БД
 /// </summary>
 /// <param name="textblock"></param>
 public void Update(TextBlock textblock)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         if (textblock != null)
         {
             db.NewsTexts.Update(textblock);
             db.SaveChanges();
         }
     }
 }
Beispiel #23
0
 /// <summary>
 /// Обновление данных договора аренды в БД
 /// </summary>
 /// <param name="rent"></param>
 public void Update(Rent rent)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         if (rent != null)
         {
             db.Rents.Update(rent);
             db.SaveChanges();
         }
     }
 }
Beispiel #24
0
 /// <summary>
 /// Обновление данных модели лодки в БД
 /// </summary>
 /// <param name="boatmodel"></param>
 public void Update(BoatModel boatmodel)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         if (boatmodel != null)
         {
             db.BoatModels.Update(boatmodel);
             db.SaveChanges();
         }
     }
 }
Beispiel #25
0
 /// <summary>
 /// Добавление аккаунта в БД
 /// </summary>
 /// <param name="account"></param>
 public void Create(Account account)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         if (account != null)
         {
             db.Accounts.Add(account);
             db.SaveChanges();
         }
     }
 }
Beispiel #26
0
 /// <summary>
 /// Обновление данных заявки в БД
 /// </summary>
 /// <param name="recall"></param>
 public void Update(Message recall)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         if (recall != null)
         {
             db.Messages.Update(recall);
             db.SaveChanges();
         }
     }
 }
Beispiel #27
0
 /// <summary>
 /// Добавление изображения в БД
 /// </summary>
 /// <param name="image"></param>
 public void Create(Image image)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         if (image != null)
         {
             db.Images.Add(image);
             db.SaveChanges();
         }
     }
 }
Beispiel #28
0
 /// <summary>
 /// Удаление заявки из БД
 /// </summary>
 /// <param name="id"></param>
 public void Delete(int id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         Message recall = db.Messages.FirstOrDefault(x => x.Id == id);
         if (recall != null)
         {
             db.Messages.Remove(recall);
             db.SaveChanges();
         }
     }
 }
Beispiel #29
0
 /// <summary>
 /// Удаление договора аренды из БД
 /// </summary>
 /// <param name="id"></param>
 public void Delete(int id)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         Rent rent = db.Rents.FirstOrDefault(x => x.Id == id);
         if (rent != null)
         {
             db.Rents.Remove(rent);
             db.SaveChanges();
         }
     }
 }
Beispiel #30
0
 /// <summary>
 /// Добавление заявки в БД
 /// </summary>
 /// <param name="recall"></param>
 public int Create(Message recall)
 {
     using (TripleBDbContext db = new TripleBDbContext())
     {
         if (recall != null)
         {
             db.Messages.Add(recall);
             db.SaveChanges();
         }
     }
     return(recall.Id);
 }