Ejemplo n.º 1
0
        public async Task <ActionResult> DeleteEvent(int userId, int eventId)
        {
            try
            {
                var user = await _context.UserDetails.FirstOrDefaultAsync(u => u.UserId == userId);

                if (user == null)
                {
                    BadRequest("User not found");
                }

                var eventDetail = await _context.EventDetails.FirstOrDefaultAsync(u => u.EventId == eventId);

                if (eventDetail == null)
                {
                    BadRequest("Event not found");
                }

                var deleteRow = new UserEventDetail()
                {
                    UserId  = userId,
                    EventId = eventId
                };
                _context.UserEventDetails.Remove(deleteRow);
                await _context.SaveChangesAsync();
            }

            catch (Exception ex)
            {
                BadRequest(ex.Message);
            }

            return(Ok());
        }
Ejemplo n.º 2
0
        public UserEventDetail GetUserEventById(int id)
        {
            UserEvent       getEvent    = _db.UserEvents.Single(ue => ue.UserEventId == id);
            UserEventDetail eventDetail = new UserEventDetail()
            {
                UserEventId = getEvent.UserEventId,
                EventId     = getEvent.EventId,
                ProfileId   = getEvent.ProfileId
            };

            return(eventDetail);
        }