private async void BotClient_OnUpdate(System.Object sender, Telegram.Bot.Args.UpdateEventArgs e) { DataBase db = Singleton.GetInstance().Context; if (e.Update.PreCheckoutQuery != null) { await BotClient.AnswerPreCheckoutQueryAsync(e.Update.PreCheckoutQuery.Id); if (e.Update.PreCheckoutQuery.InvoicePayload == "Pay is correct") { User user = db.GetUser(e.Update.PreCheckoutQuery.From.Id); user.BanDate = System.DateTime.Now; db.Save(); IsUnBan.ThisUnBan(BotClient, user); await Task.Run(() => SetIncomeChannel(e.Update.PreCheckoutQuery.From.Id, e.Update.PreCheckoutQuery.TotalAmount / 100)); } else if (e.Update.PreCheckoutQuery.InvoicePayload == "Balance is correct") { AdUser adUser = db.GetAdUser(e.Update.PreCheckoutQuery.From.Id); adUser.Balance += e.Update.PreCheckoutQuery.TotalAmount / 100; db.Save(); await Task.Run(() => SetIncomeChannel(e.Update.PreCheckoutQuery.From.Id, e.Update.PreCheckoutQuery.TotalAmount / 100)); } else if (e.Update.PreCheckoutQuery.InvoicePayload == "PostTemplate is correct") { AdUser adUser = db.GetAdUser(e.Update.PreCheckoutQuery.From.Id); PostTemplate postTemplate = db.GetTempalte(adUser.User.ID, adUser.EditingPostTemplateId); postTemplate.IsPaid = true; System.Object ob = await AdController.AssemblyTemplate(BotClient, postTemplate); if (ob is Message) { Message mes = (Message)ob; System.String text = mes.Text; await BotClient.SendTextMessageAsync(CommandText.bufferChannelId, text); } else { List <InputMediaBase> inputMedias = (List <InputMediaBase>)ob; await BotClient.SendMediaGroupAsync(CommandText.bufferChannelId, inputMedias); } IsDataTaken.IsCheck(BotClient, e.Update.PreCheckoutQuery.From.Id, postTemplate.PostTime.ToList()); db.Save(); await Task.Run(() => SetIncomeChannel(e.Update.PreCheckoutQuery.From.Id, e.Update.PreCheckoutQuery.TotalAmount / 100, postTemplate)); } else if (e.Update.PreCheckoutQuery.InvoicePayload == "Pay Confirm User") { User user = db.GetUser(e.Update.PreCheckoutQuery.From.Id); user.PayConfirm = true; user.PayDate = System.DateTime.Today.AddMonths(1); db.Save(); await Task.Run(() => SetIncomeChannel(e.Update.PreCheckoutQuery.From.Id, e.Update.PreCheckoutQuery.TotalAmount / 100)); } } }
private Boolean GetPostTemplate(Int32 idPostTemplate) { adUser = db.GetAdUser(user.ID); postTemplate = db.GetTempalte(adUser.User.ID, idPostTemplate); return(postTemplate == null); }