/// <inheritdoc /> public async Task <bool> InsertRecordAsync(BotDataModel botDataModel) { // Add new record to the database await _botDbContext.BotData.AddAsync(botDataModel); // Save changes return(await _botDbContext.SaveChangesAsync() > 0); }
// Add a method to save item in BotCart public int AddNewBot(BotDataModel model) { var newBot = new CartBot(model.HeadId, model.LeftArmId, model.RightArmId, model.TorsoId, model.BaseId, model.Cost); _dbContext.Robots.Add(newBot); _dbContext.SaveChanges(); return(newBot.CartBotId); }
public static async Task <BotDataModel> GetColleagueAsync(this string username, string id) { try { BotDataModel passCode = await CoreDi.ReadDataService.RetrieveUserAsync(username); return(await CoreDi.ReadDataService.RetrieveUserAsync(int.Parse(id), passCode.PassCode)); } catch (Exception e) { Console.WriteLine(e); return(null); } }
/// <summary> /// Authenticates a user against the data base if they already exists /// </summary> /// <param name="username">The username of the telegram user</param> /// <returns>A boolean indicating whether the user exists</returns> public static async Task <bool> AuthenticateSenderAsync(this string username) { // Check if user already exist in the database try { BotDataModel result = await CoreDi.ReadDataService.RetrieveUserAsync(username); return(result.Id > 0); } catch (Exception e) { Console.WriteLine(e); return(false); } }
/// <summary> /// Queries for a colleagues account info. /// </summary> /// <param name="chat">The chat to reply to</param> /// <param name="message">The message to send</param> /// <returns></returns> private static async Task QueryForDataAsync(Chat chat, string message) { if (!message.StartsWith("/")) { return; } message = message.Split('/')[1]; BotDataModel colleague = await chat.Username.GetColleagueAsync(message); if (colleague != null) { await WhitsModelBot.SendReplyAsync(chat, $"Contact Details For {colleague.Firstname}\n" + $"Role : {colleague.Role}\n" + $"Skype Id: {colleague.Skype}\n" + $"Team Account Name: {colleague.TeamAccount}\n" + $"Office Mail: {colleague.MailAccount}"); await WhitsModelBot.SendContactAsync(chat, $"{colleague.Phone}", $"{colleague.Firstname}"); } }
public int Post(BotDataModel request) { return(_repo.AddNewBot(request)); }
public static async Task <string> GetUserPassCode(this string username) { BotDataModel passCode = await CoreDi.ReadDataService.RetrieveUserAsync(username); return(passCode.PassCode); }