Ejemplo n.º 1
0
        public EventModel AddEvent(EventRequest eventRequest, string userId)
        {
            if (string.IsNullOrEmpty(eventRequest.Description)) return null;

            var newEvent = new Event()
            {
                Description = eventRequest.Description,
                Time = eventRequest.Time,
                Location = eventRequest.Location,
                Date = DateTime.Now,
                EventDate = eventRequest.Date,
                UserId = userId,
            };

            _repository.Add(newEvent);

            _repository.SaveChanges();

            var userFullName =
                _repository.GetEntities<AspNetUser>()
                    .Where(u => u.Id == userId)
                    .Select(u => u.UserInfo.FullName)
                    .FirstOrDefault();
            if (userFullName == null) return null;

            return new EventModel()
            {
                Id = newEvent.Id,
                Date = newEvent.Date,
                Description = newEvent.Description,
                UserName = userFullName,
                FullName = userFullName,
                Time = newEvent.Time,
                EventDate = newEvent.EventDate,
                Location = newEvent.Location,
                NotNowUsers = new List<UserModel>(),
                GoingUsers = new List<UserModel>(),
                TentativeUsers = new List<UserModel>()
            };
        }
 public void ArchiveEvent(EventRequest EventRequest)
 {
     _eventService.ArchiveEvent(EventRequest.Id);
 }
        public void Cancel(EventRequest EventRequest)
        {
            var userId = UserId;

            _eventService.CancelEvent(EventRequest, userId);
        }
        public EventModel AddEvent(EventRequest EventRequest)
        {
            var userId = UserId;

            return _eventService.AddEvent(EventRequest, userId);
        }
Ejemplo n.º 5
0
        public void CancelEvent(EventRequest eventRequest, string userId)
        {
            var eventObject = _repository.GetEntities<Event>().FirstOrDefault(
              p => p.Id == eventRequest.Id && p.UserId.Equals(userId));

            if (eventObject == null) return;

            eventObject.IsCanceld = true;

            _repository.SaveChanges();
        }