Esempio n. 1
0
 public void AddEvent(Event entity)
 {
     try
     {
         _unitOfWork.Context.Users.Attach(entity.User);
         _unitOfWork.Context.Events.Attach(entity);
         _unitOfWork.EventRepository.Add(entity);
         _unitOfWork.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Esempio n. 2
0
 public static Report CreateReport(string reason, User user, Event @event)
 {
     return new Report()
     {
         ReportedBy = user,
         ReportedEvent = @event,
         Reason = reason
     };
 }
Esempio n. 3
0
 public bool AttendEvent(Event @event)
 {
     if (AttendedEvents == null)
         AttendedEvents = new List<Event>();
     if (!AttendedEvents.Contains(@event))
     {
         AttendedEvents.Add(@event);
         return true;
     }
     return false;
 }
Esempio n. 4
0
        public void AttendEvent(User user, Event @event)
        {
            try
            {
                @event = EventRepository.FindById(@event.Id);
                user = UserRepository.FindById(user.UserId);
                user.AttendedEvents.Add(@event);
                @event.Attendees.Add(user);
                _userRepository.Update(user);
                _eventRepository.Update(@event);

               // @event2.Attendees.Add(user);
               // _context.Entry<Event>(@event).State = EntityState.Modified;
                //_context.Entry<User>(user).State = EntityState.Modified;
                //FindById(user.UserId).AttendedEvents.Add(@esvent);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
 private void CleanUp(CongregatioServiceClient client, Event @event, User attendee)
 {
     var user = @event.User;
     @event.Attendees = new List<User>();
     client.UpdateEvent(@event);
     attendee.AttendedEvents = new List<Event>();
     client.UpdateUser(attendee);
     @event = client.GetEventByIdLong(@event.Id);
     attendee = client.FindUserById(attendee.UserId);
     client.RemoveUser(attendee);
     client.RemoveEvent(@event);
     user = client.FindUserById(user.UserId);
     client.RemoveUser(user);
 }
 private void CleanUp(UnitOfWork unit, Event @event, User attendee)
 {
     //var user = @event.Host;
     @event.Attendees = new List<User>();
     unit.EventRepository.Update(@event);
     unit.SaveChanges();
     attendee.AttendedEvents = new List<Event>();
     unit.UserRepository.Update(attendee);;
     unit.UserRepository.Remove(attendee);
     unit.EventRepository.Remove(@event);
     //unit.UserRepository.Remove(user);
     unit.SaveChanges();
 }
 private void CleanUp(CongregatioServiceClient client, User stalker, Event stalkedEvent)
 {
     client.RemoveUser(stalker);
     client.RemoveEvent(stalkedEvent);
     client.RemoveUser(stalkedEvent.User);
 }
Esempio n. 8
0
        private void Search_Click(object sender, RoutedEventArgs e)
        {
            if (NavigationComboBox != null)
            {
                string value = NavigationComboBox.SelectedItem as string;
                if (value.Equals("Event"))
                {
                    int id = Convert.ToInt32(
                        ((EventPartialPage) ContentFrame.Content).TxtEventId.Text
                        );
                    var @event = new Event();
                    try
                    {
                        @event = _client.GetEventById(id);
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(exc.Message);
                    }

                    ContentFrame.Navigate(new EventPartialPage(@event));

                }
                else if (value.Equals("User"))
                {

                    //Guid id = new Guid(
                    //    ((UserPartialPage) ContentFrame.Content).TxtUserId.Text
                    //    );
                    string email = ((UserPartialPage) ContentFrame.Content).TxtUserEmail.Text;
                    var user = _client.FindUserByEmail(email);
                    ContentFrame.Navigate(new UserPartialPage(user));
                }
            }
        }
Esempio n. 9
0
 private Event UpdateEvent(Event @event, EventPartialPage page)
 {
     @event.EventTitle = page.TxtEventTitle.Text;
     @event.EventDescription = page.TxtEventDescription.Text;
     @event.City = page.TxtEventCity.Text;
     //Admin client parses date from db weirdly
     //@event.EventDate = DateTime.Parse(page.TxtEventDate.Text);
     //@event.EventTime = DateTime.Parse(page.TxtEventTime.Text).TimeOfDay;
     @event.EventLocation = page.TxtEventLocation.Text;
     @event.MaxPeople = Convert.ToInt32(page.TxtEventMaxPeople.Text);
     @event.Price = decimal.Parse(page.TxtEventPrice.Text);
     return @event;
 }
Esempio n. 10
0
 public void UpdateEvent(Event entity)
 {
     _unitOfWork.EventRepository.Update(entity);
     _unitOfWork.SaveChanges();
 }
Esempio n. 11
0
 public void RemoveNotAttachedEvent(Event entity)
 {
     _unitOfWork.EventRepository.RemoveNotAttached(entity);
     _unitOfWork.SaveChanges();
 }
Esempio n. 12
0
 public void RemoveEvent(Event entity)
 {
     try
     {
         entity = _unitOfWork.EventRepository.FindById(entity.Id);
         _unitOfWork.Context.Events.Attach(entity);
         //_unitOfWork.EventRepository.Remove(entity);
         _unitOfWork.Context.Events.Remove(entity);
         _unitOfWork.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Esempio n. 13
0
 //public bool AttentEvent(string userId, Event @event)
 public void AttendEvent(Guid userId, Event @event)
 {
     var user = _unitOfWork.UserRepository.FindById(userId);
     _unitOfWork.AttendEvent(user, @event);
     try
     {
         _unitOfWork.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }