public object updateVIPStatus(PartnerViewModel param)
        {
            var api = GoPlayApi.Instance;
            string username = param.username;
            var user = api.GetUserByUserName(username).Data;
            string status = param.status;
            var partner = api.GetPartner(ConfigurationManager.AppSettings["PARTNER_CLIENT_ID"]).Data;
            ErrorCodes? err = null;

            if (partner == null)
                err = ErrorCodes.INVALID_PARTNER_ID;
            else if (user == null)
                err = ErrorCodes.NON_EXISTING_USER;
            else
            {
                string tokenRawString = username + status + partner.client_id;
                string generatedToken = Helper.CalculateMD5Hash(tokenRawString);

                if (string.Compare(generatedToken, param.token, true) != 0)
                    err = ErrorCodes.INVALID_TOKEN;
            }
            if (err == null)
            {
                if (!api.UpdateCustomerAccount(user.id, user.email, user.nickname, user.gender, status))
                    err = ErrorCodes.ServerError;
                else
                {
                    var notification = new user_notification();
                    if (status == EUserStatus.ClassicReseller.ToDescription())
                        notification.game_notification_id = (int)EUserStatus.ClassicReseller;
                    else if (status == EUserStatus.GoldReseller.ToDescription())
                        notification.game_notification_id = (int)EUserStatus.GoldReseller;
                    notification.customer_account_id = user.id;
                    api.CreateUserNotification(notification);
                }
            }
            api.LogApi("1", "/partner/update-vip-status", err == null,
               Request.UserAgent != null ? Request.UserAgent.ToString() : string.Empty,
               0, user == null ? 0 : user.id, HttpContext.Request.UserHostAddress,
               err.ToErrorCode(), JsonConvert.SerializeObject(param));
            return JsonConvert.SerializeObject(new
            {
                success = err == null,
                message = err.ToErrorMessage(),
                error_code = err.ToErrorCode()
            });
        }
Exemplo n.º 2
0
 public int CreateUserNotification(user_notification user_noti)
 {
     var repo = Repo.Instance;
     using (var db = repo.OpenConnectionFromPool())
     {
         return repo.CreateUserNotification(db, user_noti);
     }
 }
Exemplo n.º 3
0
 public int CreateUserNotification(IDbConnection db, user_notification user_noti)
 {
     string sql = @"INSERT INTO user_notification(
                   customer_account_id, game_notification_id)
                   VALUES (@customer_account_id,@game_notification_id)
                    RETURNING id";
     return db.Query<int>(sql, user_noti).FirstOrDefault();
 }