public Meeting CreateMeeting(Meeting meetingModel) { _context.Entry(meetingModel.creator).State = System.Data.Entity.EntityState.Unchanged; _context.Entry(meetingModel).State = System.Data.Entity.EntityState.Added; _context.SaveChanges(); return(_context.Meetings.SingleOrDefault(x => x.Title == meetingModel.Title)); }
public void DeleteConnection(Connection connection) { _context.Entry(connection.User1).State = System.Data.Entity.EntityState.Unchanged; _context.Entry(connection.User2).State = System.Data.Entity.EntityState.Unchanged; _context.Entry(connection).State = System.Data.Entity.EntityState.Deleted; _context.SaveChanges(); }
public void createMeetingRequest(MeetingRequest meetingRequest) { _context.Entry(meetingRequest.User).State = System.Data.Entity.EntityState.Unchanged; _context.Entry(meetingRequest.Meeting).State = System.Data.Entity.EntityState.Unchanged; _context.Entry(meetingRequest).State = System.Data.Entity.EntityState.Added; var result = _context.SaveChanges(); }
public async Task <Event> DeleteEvent(string title, Guid id, string username) { Event toDelete = (Event)_context.Events.SingleOrDefault(o => o.Title == title && o.ID == id); Meeting meetingToDelete = _context.Meetings.Include("creator").Where(x => x.Title == title).SingleOrDefault(); List <Event> eventsToDelete = _context.Events.Where(x => x.Title == title).ToList(); if (meetingToDelete == null) { _context.Events.Remove(toDelete); _context.SaveChanges(); } else { // _context.Events.Remove(toDelete); // _context.SaveChanges(); if (meetingToDelete.creator.UserName == username) { List <MeetingRequest> mrLista = _context.MeetingRequests.Where(x => x.Meeting.ID == meetingToDelete.ID).ToList(); foreach (MeetingRequest m in mrLista) { _context.MeetingRequests.Remove(m); } foreach (Event e in eventsToDelete) { _context.Events.Remove(e); } _context.Meetings.Remove(meetingToDelete); _context.SaveChanges(); } else { _context.Events.Remove(toDelete); _context.SaveChanges(); } } return(toDelete); }
public void readConnestionNotification(ConnectionNotification notification) { _context.Entry(notification.User1).State = System.Data.Entity.EntityState.Unchanged; _context.Entry(notification).State = System.Data.Entity.EntityState.Modified; var result = _context.SaveChanges(); }