Esempio n. 1
0
        public IActionResult AttendEvent(int EventID)
        {
            AttendeeRepo c     = new AttendeeRepo(_context);
            EventRepo    e     = new EventRepo(_context);
            var          claim = HttpContext.User.Claims.ElementAt(0);
            string       email = claim.Value;
            var          user  = c.GetOneByEmail(email);

            try
            {
                e.AttendEvent(EventID, user.ID);

                var res = new
                {
                    StatusCode = "You are attending this event.",
                };
                return(new ObjectResult(res));
            }
            catch
            {
                var res = new
                {
                    error = "You are already attending this event.",
                };
                return(new ObjectResult(res));
            }
        }