示例#1
0
        public int addFrostyRegistration(WebFrostyRegistration webRegistration)
        {
            // Check if registration is enabled for this event occurrence.
            EventOccurrence eventOccurrence = db.EventOccurrences
                                              .SingleOrDefault(e => e.id == webRegistration.eventOccurrenceId);

            if (eventOccurrence != null)
            {
                if (!eventOccurrence.isActive)
                {
                    throw new Exception("You cannot register for this event because it is not active");
                }
                FrostyRegistration registration = new FrostyRegistration();
                registration.eventOccurrenceId = webRegistration.eventOccurrenceId;
                registration.userId            = this.me.id;
                registration.isPaid            = false;
                registration.isMinor           = webRegistration.isMinor;
                registration.dateCreated       = DateTime.UtcNow;

                db.FrostyRegistrations.Add(registration);
                db.SaveChanges();

                return(registration.id);
            }
            else
            {
                throw new PermissionDeniedException();
            }
        }
        public int addFrostyRegistration(WebFrostyRegistration webRegistration)
        {
            // Check if registration is enabled for this event occurrence.
            EventOccurrence eventOccurrence = db.EventOccurrences
                .SingleOrDefault(e => e.id == webRegistration.eventOccurrenceId);
            if (eventOccurrence != null)
            {
                if (!eventOccurrence.isActive)
                {
                    throw new Exception("You cannot register for this event because it is not active");
                }
                FrostyRegistration registration = new FrostyRegistration();
                registration.eventOccurrenceId = webRegistration.eventOccurrenceId;
                registration.userId = this.me.id;
                registration.isPaid = false;
                registration.isMinor = webRegistration.isMinor;
                registration.dateCreated = DateTime.UtcNow;

                db.FrostyRegistrations.Add(registration);
                db.SaveChanges();

                return registration.id;
            }
            else
            {
                throw new PermissionDeniedException();
            }
        }
示例#3
0
        public void updateFrostyRegistration(WebFrostyRegistration webRegistration)
        {
            // Check if registration is enabled for this event occurrence.
            EventOccurrence eventOccurrence = db.EventOccurrences
                                              .SingleOrDefault(e => e.id == webRegistration.eventOccurrenceId);

            if (eventOccurrence != null)
            {
                if (!eventOccurrence.isActive)
                {
                    throw new Exception("You cannot register for this event because it is not active");
                }
                FrostyRegistration registration = db.FrostyRegistrations
                                                  .SingleOrDefault(r => r.id == webRegistration.id);
                if (registration != null && (registration.userId == me.id || me.type == "admin"))
                {
                    registration.eventOccurrenceId = webRegistration.eventOccurrenceId;
                    // Only allow admins to manually mark registration as being paid (e.g. in person with cash/check).
                    if (me.type == "admin")
                    {
                        registration.isPaid = webRegistration.isPaid;
                    }
                    registration.isMinor = webRegistration.isMinor;

                    db.SaveChanges();
                }
                else
                {
                    throw new PermissionDeniedException();
                }
            }
            else
            {
                throw new PermissionDeniedException();
            }
        }