예제 #1
0
 public void AddEvent(DTO.Event Event)
 {
     if (!_events.Exists(e => e.Name.ToUpper().Trim() == Event.Name.ToUpper().Trim()))
     {
         _eventRepository.AddEvent(Event);
         _events = _eventRepository.GetAllEvents();
     }
 }
예제 #2
0
        public void EditEvent(DTO.Event eventToEdit, DTO.Event modifiedEvent)
        {
            var modelEventToEdit = _events.Find(e => e.Name == eventToEdit.Name);

            if (modelEventToEdit != null)
            {
                _eventRepository.EditEvent(eventToEdit, modifiedEvent);
            }
            _events = _eventRepository.GetAllEvents();
        }
예제 #3
0
        internal static Event ToEvent(this DTO.Event dto)
        {
            Event e = new Event();

            e.Min    = dto.Min;
            e.Player = dto.Player;
            e.Team   = dto.Team;
            e.Type   = dto.Type;
            return(e);
        }
예제 #4
0
        private void EditDialog(object obj)
        {
            _eventToEdit = _eventDataService.GetEvent(SelectedEvent.Name);

            // The Selected event details should appear in the edit dialog.
            SelectedEvent.Name = _eventToEdit.Name;
            SelectedEvent.Date = _eventToEdit.Date;

            _canEditEventDetails = true;
            _canCreateNewEvent   = false;
            _selectionValidated  = false;
            CreateAndEditEventWindowVisibility = Visibility.Visible;
        }
예제 #5
0
        public static Model.Event TranslateDTOEventToModelEvent(DTO.Event e)
        {
            if (e == null)
            {
                return(null);
            }

            return(new Model.Event
            {
                Id = e.Id,
                InstigatorUser = UserMapper.TranslateDTOUserToModelUser(e.InstigatorUser),
                Name = e.Name,
                Timestamp = e.Timestamp
            });
        }
예제 #6
0
        private void CreateNewEvent(object obj)
        {
            _eventDataService.AddEvent(SelectedEvent);

            //The order here is critical because after LoadEvenNames() is called, the SelectedEvent gets changed. The original
            //SelectedEvent is needed later in order to be able to edit immediately after creating the new event.

            var newEvent = _eventDataService.GetEvent(SelectedEvent.Name);

            LoadEventNames();
            SelectedEvent.Name = newEvent.Name;
            SelectedEvent.Date = newEvent.Date;
            _eventToEdit       = _eventDataService.GetEvent(SelectedEvent.Name);

            _canEditEventDetails = true;
            _canCreateNewEvent   = false;
        }
예제 #7
0
        public void EditEvent(DTO.Event eventToEdit, DTO.Event modifiedEvent)
        {
            try
            {
                using (var db = new GuestAppContext())
                {
                    var modelEvent = db.Events.Find(eventToEdit.Id);
                    modelEvent.Name = modifiedEvent.Name;
                    modelEvent.Date = modifiedEvent.Date;

                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #8
0
        public void AddEvent(DTO.Event newEvent)
        {
            var modelEvent = Mapper.EventMapper(newEvent, new Model.Event());

            try
            {
                using (var db = new GuestAppContext())
                {
                    modelEvent.UserId = User.Id;
                    db.Events.Add(modelEvent);
                    db.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #9
0
        public static Event MapFromDal(DTO.Event currentEvent)
        {
            var res = currentEvent == null ? null : new Event
            {
                Id                = currentEvent.Id,
                CreatedAt         = currentEvent.CreatedAt,
                ChangedAt         = currentEvent.ChangedAt,
                CreatedBy         = currentEvent.CreatedBy,
                ChangedBy         = currentEvent.ChangedBy,
                Name              = currentEvent.Name,
                Place             = currentEvent.Place,
                StartTime         = currentEvent.StartDateTime,
                EndDateTime       = currentEvent.EndDateTime,
                ShowStartDateTime = currentEvent.ShowStartDateTime,
                ShowEndDateTime   = currentEvent.ShowEndDateTime
            };

            return(res ?? default !);
        }
예제 #10
0
 public GuestRepository(string userId = null, DTO.Event currentEvent = null)
 {
     _currentEvent = currentEvent;
     _userId       = userId;
 }