예제 #1
0
        public PrivateEvent getCurrentPrivateEvent()
        {
            ApplicationUser currentUser = db.Users.Find(User.Identity.GetUserId());

            PrivateEvent currentPrivateEvent = new PrivateEvent();
            bool         found = false;

            foreach (PrivateEvent myEvent in db.PrivateEvents)
            {
                if (myEvent.UserID == currentUser)
                {
                    currentPrivateEvent = myEvent;
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                PrivateEvent newPrivateList = new PrivateEvent();
                newPrivateList.UserID  = currentUser;
                newPrivateList.AdminID = db.Admins.FirstOrDefault();
                db.PrivateEvents.Add(newPrivateList);
                db.SaveChanges();
                currentPrivateEvent = newPrivateList;
            }

            return(currentPrivateEvent);
        }
예제 #2
0
 public async Task AddPrivateEvent(PrivateEvent privateEvent)
 {
     if (privateEvent != null)
     {
         await _context.PrivateEvents.AddAsync(privateEvent);
     }
 }
예제 #3
0
 public void InvokeAllEvents()
 {
     PublicEvent?.Invoke();
     PrivateEvent?.Invoke();
     InternalEvent?.Invoke();
     ProtectedEvent?.Invoke();
     ProtectedInternalEvent?.Invoke();
 }
        public async Task <IActionResult> Create([Bind("EventId,DepartmentId,EventDate,Price,GuestCapacity,Location,EventType,ImageUrl,Description,IsBooked")] PrivateEvent privateEvent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(privateEvent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", privateEvent.DepartmentId);
            return(View(privateEvent));
        }
        public async Task <IActionResult> Edit(int id, [Bind("EventId,DepartmentId,EventDate,Price,GuestCapacity,Location,EventType,ImageUrl,Description,IsBooked")] PrivateEvent privateEvent)
        {
            if (id != privateEvent.EventId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    PrivateEvent _privateEvent = _context.PrivateEvent.Where(s => s.EventId == privateEvent.EventId).First();
                    _privateEvent.DepartmentId  = privateEvent.DepartmentId;
                    _privateEvent.EventDate     = privateEvent.EventDate;
                    _privateEvent.Price         = privateEvent.Price;
                    _privateEvent.GuestCapacity = privateEvent.GuestCapacity;
                    _privateEvent.Location      = privateEvent.Location;
                    _privateEvent.EventType     = privateEvent.EventType;
                    _privateEvent.ImageUrl      = privateEvent.ImageUrl;
                    _privateEvent.Description   = privateEvent.Description;
                    _privateEvent.IsBooked      = privateEvent.IsBooked;
                    _context.Update(_privateEvent);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PrivateEventExists(privateEvent.EventId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", privateEvent.DepartmentId);
            return(View(privateEvent));
        }
예제 #6
0
 private void PrivateEventHandler(PrivateEvent e)
 {
     PrivateEventHandlerInvokeCount++;
 }
 private void OnPrivateEvent(PrivateEvent e)
 {
     PrivateEventHandlerInvokeCount++;
 }
예제 #8
0
 public void RaisePrivateEvent()
 {
     PrivateEvent.SafeInvoke(this, EventArgs.Empty);
 }
예제 #9
0
 public void InvokePrivateEvent()
 {
     PrivateEvent?.Invoke(this, new PrivateEventArgs());
 }