public string DeleteSubscription(int user, string name) { GroupActions groupActions = new GroupActions(); ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1(); var group = groupActions.FindGroupByName(name); string answer = null; var result = concertDB.tblSubscriptions.Where(b => (b.user_id == user) && (b.group_id == group.group_id)); try { if (result.ToList().Count() > 0) { foreach (var item in result) { concertDB.tblSubscriptions.Remove(item); } } concertDB.SaveChanges(); answer = "Исполнитель успешно удален"; } catch (Exception e) { answer = "У вас нет подписки с таким именем"; Console.WriteLine(e); return(answer); } return(answer); }
public IQueryable <tblSubscriptions> DeleteSubscription(int user, int group_id) { GroupActions groupActions = new GroupActions(); ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1(); var group = groupActions.FindGroupById(group_id); if (group == null) { return(null); } var Result = concertDB.tblSubscriptions.Where(b => (b.user_id == user) && (b.group_id == group.group_id)); if (Result != null) { foreach (var item in Result) { concertDB.tblSubscriptions.Remove(item); } concertDB.SaveChanges(); } return(Result); }
public string DeleteAllSubscriptions(int user) { string answer = "Ваш список подписок очищен"; try { ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1(); var result = concertDB.tblSubscriptions.Where(b => b.user_id == user); if (result != null) { foreach (var item in result) { concertDB.tblSubscriptions.Remove(item); } concertDB.SaveChanges(); } } catch (Exception e) { Console.WriteLine(e); throw; } return(answer); }
public void UpdateGroup(int id, string name) { ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1(); tblGroups group = concertDB.tblGroups.Where(b => b.group_id == id).First(); group.group_name = name; concertDB.SaveChanges(); }
public void InsertSubscription(int user, int group) { ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1(); var sub = new tblSubscriptions(); var subs = SelectAllSubscriptions(); sub.group_id = group; sub.user_id = user; sub.subscription_id = subs.Count() + 1; concertDB.tblSubscriptions.Add(sub); concertDB.SaveChanges(); }
public string InsertUser(int id, string city) { //ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1(); string answer = null; try { var user = new tblUsers(); user.user_id = id; user.user_city = city; concertDB.tblUsers.Add(user); concertDB.SaveChanges(); answer = string.Format("ѕоздравл¤ем с регистрацией, ваш город {0}", city); } catch (Exception e) { Console.WriteLine(e); throw (new Exception()); } return(answer); }
public void InsertConcerts(Concert concert, int group) { ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1(); var conc = new tblConcerts(); conc.concert_id = group + 1; conc.group_id = group; conc.concert_city = "Test location"; conc.concert_date = System.DateTime.Now; conc.concert_link = "no url"; conc.concert_place = "place location"; conc.concert_title = "Test "; concertDB.tblConcerts.Add(conc); concertDB.SaveChanges(); }
public void InsertConc(tblConcerts concert, int group) { ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1(); var conc = new tblConcerts(); conc.concert_id = concert.concert_id; conc.group_id = group; conc.concert_city = concert.concert_city; conc.concert_date = concert.concert_date; conc.concert_link = concert.concert_link; conc.concert_place = concert.concert_place; conc.concert_title = concert.concert_title; concertDB.tblConcerts.Add(conc); concertDB.SaveChanges(); }
public void InsertConcert(Concert concert, int group) { ConcertNotifierEntities1 concertDB = new ConcertNotifierEntities1(); var conc = new tblConcerts(); conc.concert_id = concert.ID; conc.group_id = group; conc.concert_city = concert.Location; conc.concert_date = concert.Date; conc.concert_link = concert.Link; conc.concert_place = concert.Place; conc.concert_title = concert.Title; concertDB.tblConcerts.Add(conc); concertDB.SaveChanges(); }
public void DeleteAll() { var subs = concertDB.tblSubscriptions; if (subs != null) { foreach (var item in subs) { concertDB.tblSubscriptions.Remove(item); } concertDB.SaveChanges(); } var concs = concertDB.tblConcerts; foreach (var item in concs) { concertDB.tblConcerts.Remove(item); } concertDB.SaveChanges(); var groups = concertDB.tblGroups; foreach (var item in groups) { concertDB.tblGroups.Remove(item); } concertDB.SaveChanges(); var users = concertDB.tblUsers; foreach (var item in users) { concertDB.tblUsers.Remove(item); } concertDB.SaveChanges(); }