Exemplo n.º 1
0
        public async Task <ApiResult> RsvpToEvent(long eventid, int?rsvpTypeId, string rsvpName)
        {
            var apiresult = new ApiResult();

            if (UserContext == null)
            {
                return(apiresult.Failure("Must be logged in."));
            }
            if (!UserContext.IsVerifiedLogin)
            {
                return(apiresult.Failure("Insufficient account permissions."));
            }
            if (eventid <= 0)
            {
                return(apiresult.Failure("Invalid Event"));
            }
            if (rsvpTypeId.UnBox() <= 0 && string.IsNullOrWhiteSpace(rsvpName))
            {
                return(apiresult.Failure("Must specifify an rsvpTypeId or rsvpName"));
            }

            RSVPType rsvp = rsvpTypeId.UnBox() > 0 ? Factory.RSVPTypeManager[rsvpTypeId.UnBox()] : Factory.RSVPTypeManager[rsvpName];

            if (rsvp == null)
            {
                return(apiresult.Failure("RSVPType does not exists"));
            }
            try {
                await Factory.RSVPTypeManager.AddOrUpdateRSVPToEvent(UserContext.AccountID, eventid, rsvp.RSVPTypeID);

                return(apiresult.Success("Success"));
            } catch (Exception ex) { return(apiresult.Failure(ex)); }
        }
Exemplo n.º 2
0
 private async Task <bool> Init()
 {
     using (var cmd = new SqlCommand("[dbo].[sp_RSVPTypes_Get]", new SqlConnection(Ctx.Config.dbUniHangoutsConfiguration))
     {
         CommandType = CommandType.StoredProcedure
     }) {
         if (cmd.Connection.State != ConnectionState.Open)
         {
             await cmd.Connection.OpenAsync().ConfigureAwait(false);
         }
         using (var reader = await cmd.ExecuteReaderAsync().ConfigureAwait(false)) {
             var ls = new List <RSVPType>();
             while (await reader.ReadAsync().ConfigureAwait(false))
             {
                 var y = new RSVPType()
                 {
                     RSVPTypeID  = reader.GetInt16("RSVPTypeID"),
                     Name        = reader.GetString("Name"),
                     Description = reader.GetString("Description")
                 };
                 if (y.Name.EqAlphaNumIgCase(nameof(No)))
                 {
                     this._No = y;
                 }
                 else if (y.Name.EqAlphaNumIgCase(nameof(Maybe)))
                 {
                     this._Maybe = y;
                 }
                 else if (y.Name.EqAlphaNumIgCase(nameof(StopBy)))
                 {
                     this._StopBy = y;
                 }
                 else if (y.Name.EqAlphaNumIgCase(nameof(Later)))
                 {
                     this._Later = y;
                 }
                 else if (y.Name.EqAlphaNumIgCase(nameof(Attending)))
                 {
                     this._Attending = y;
                 }
                 ls.Add(y);
             }
             _RSVPTypes = ls.AsReadOnly();
         }
     }
     return(true);
 }