public static async Task <string> SaveScreenshotAndGetUrl(IHostingEnvironment env, IImageRepository img_repo, Images img, string resource_id) { bool result = true; DataProvider.DbResult dbResult = null; string igdb = "https://images.igdb.com/igdb/image/upload/"; string fileName = string.Format("{0}.jpg", Guid.NewGuid().ToString()); img.ImageType = Constant.ImageType.Medium; img.Url = string.Format("/{0}/{1}/{2}/{3}", Constant.Resources, img.ImageOf, img.ImageType, fileName); result = await SaveImageAndGetUrl(env, string.Format("{0}/{1}/{2}.jpg", igdb, Constant.ImageType.IGdb.Medium, resource_id), img.ImageType, img.ImageOf, fileName); if (result) { dbResult = await img_repo.Add_New_ImageAsync(img); } img.ImageType = Constant.ImageType.Large; img.Url = string.Format("/{0}/{1}/{2}/{3}", Constant.Resources, img.ImageOf, img.ImageType, fileName); result = await SaveImageAndGetUrl(env, string.Format("{0}/{1}/{2}.jpg", igdb, Constant.ImageType.IGdb.Large, resource_id), img.ImageType, img.ImageOf, fileName); if (result) { dbResult = await img_repo.Add_New_ImageAsync(img); } return(fileName); }
public async Task <DbResult> DeleteByIdAsync(long Id) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { using (var multiple = await con.QueryMultipleAsync(DeleteByIdSP, new { Id }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); } } return(result); }
public async Task <DbResult> Change_Password_By_Id(User obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { obj.Password = EncryptionHelper.Encrypt(obj.Password); using (var multiple = await con.QueryMultipleAsync(Change_Password_By_IdSP, new { obj.Id, obj.Password }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); } } return(result); }
public async Task <DbResult> IsIgdbReview_ExistsAsync(long id) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { using (var multiple = await con.QueryMultipleAsync(IsIgdbReview_ExistsSP, new { id }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <Review>(); } } } return(result); }
public async Task <DbResult> Videos_Get_By_ReferenceId_Video_Of(long ReferenceId, string Video_of) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { using (var multiple = await con.QueryMultipleAsync(Get_By_ReferenceId_Video_OfSP, new { Video_of, ReferenceId }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.Read <Video>(); } } } return(result); }
public async Task <DbResult> GetUserByIdAsync(long Id) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { using (var multiple = await con.QueryMultipleAsync(GetUserByIdSP, new { Id }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <User>(); } } } return(result); }
public async Task <DbResult> Add_New_Release_Date_From_IGDbAsync(Game_Release_Date obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { using (var multiple = await con.QueryMultipleAsync(Add_New_Release_Date_From_IGDbSP, new { obj.Category, obj.Game_Id, obj.IGdb_Date, obj.Platform_Id, obj.Region, obj.Release_On }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <Game_Release_Date>(); } } } return(result); }
public async Task <DbResult> Email_ConfirmationAsync(string UserKey, string SecurityCode) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { using (var multiple = await con.QueryMultipleAsync(Email_ConfirmationSP, new { UserKey, SecurityCode }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <User>(); } } } return(result); }
public async Task <DbResult> Add_NewAsync(Video obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { using (var multiple = await con.QueryMultipleAsync(Add_NewSP, new { obj.Reference_Id, obj.Name, obj.Snapshot, obj.Video_Id, obj.Video_of }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <Video>(); } } } return(result); }
public async Task <DbResult> Add_New_ImageAsync(Images obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { using (var multiple = await con.QueryMultipleAsync(Add_New_ImageSP, new { obj.ImageCategory, obj.Url, obj.Height, obj.Width, obj.ImageOf, obj.ImageType, obj.Reference_Id }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <Images>(); } } } return(result); }
public async Task <DbResult> Get_Image_By_ReferenceId_ImageType_ImageOfAsync(long ReferenceId, string ImageType, string ImageOf) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { using (var multiple = await con.QueryMultipleAsync(Get_Image_By_ReferenceId_ImageType_ImageOfSP, new { ImageOf, ImageType, ReferenceId }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.Read <Images>(); } } } return(result); }
public async Task <DbResult> Check_User_LoginsAsync(UserLogin obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { using (var multiple = await con.QueryMultipleAsync(Check_User_LoginsSP, new { obj.LoginProvider, obj.ProviderKey }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <User>(); } } } return(result); }
public async Task <DbResult> FindUserByEmail_PasswordAsync(string Email, string Password) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { Password = EncryptionHelper.Encrypt(Password); using (var multiple = await con.QueryMultipleAsync(FindUserByEmail_PasswordSP, new { Email, Password }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <User>(); } } } return(result); }
public async Task <DbResult> Change_PasswordAsync(User obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { obj.Password = EncryptionHelper.Encrypt(obj.Password); using (var multiple = await con.QueryMultipleAsync(Change_PasswordSP, new { obj.Id, obj.Password, obj.UserKey, obj.SecurityCode }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <User>(); } } } return(result); }
public async Task <DbResult> GenerateEmailConfirmationTokenAsync(long Id) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { string UserKey = DbHelper.GetUniqueKey(20); string SecurityCode = DbHelper.GetUniqueKey(20); using (var multiple = await con.QueryMultipleAsync(GenerateEmailConfirmationTokenSP, new { Id, UserKey, SecurityCode }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <User>(); } } } return(result); }
public async Task <DbResult> Add_New_From_IdgbAsync(GamePlatform obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { obj.NameUrl = Regex.Replace(obj.Name.Trim(), "[^a-zA-Z0-9]", "-"); obj.NameUrl = Regex.Replace(obj.NameUrl, @"(?<=(-))\1+", "").ToLower(); obj.NameUrl = obj.NameUrl.EndsWith("-") ? obj.NameUrl.Remove(obj.NameUrl.Length - 1, 1) : obj.NameUrl; using (var multiple = await con.QueryMultipleAsync(Add_New_From_IdgbSP, new { obj.Name, obj.NameUrl, obj.Alternative_name, obj.Games, obj.Generation, obj.Igdb_Id, obj.PageContent, obj.Website }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <GamePlatform>(); } } } return(result); }
public async Task <DbResult> UpdateAsync(GameMode obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { obj.NameUrl = Regex.Replace(obj.Name.Trim(), "[^a-zA-Z0-9]", "-"); obj.NameUrl = Regex.Replace(obj.NameUrl, @"(?<=(-))\1+", "").ToLower(); obj.NameUrl = obj.NameUrl.EndsWith("-") ? obj.NameUrl.Remove(obj.NameUrl.Length - 1, 1) : obj.NameUrl; using (var multiple = await con.QueryMultipleAsync(UpdateSP, new { obj.Games, obj.Id, obj.Igdb_Id, obj.Name, obj.NameUrl }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <GameMode>(); } } } return(result); }
public async Task <DbResult> Add_NewGame_From_Idgb_ApiAsync(Game obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { obj.NameUrl = Regex.Replace(obj.Name.Trim(), "[^a-zA-Z0-9]", "-"); obj.NameUrl = Regex.Replace(obj.NameUrl, @"(?<=(-))\1+", "").ToLower(); obj.NameUrl = obj.NameUrl.EndsWith("-") ? obj.NameUrl.Remove(obj.NameUrl.Length - 1, 1) : obj.NameUrl; using (var multiple = await con.QueryMultipleAsync(Add_NewGame_From_Idgb_ApiSP, new { obj.PEGI_Rating, obj.PEGI_Synopsis, obj.ESRB_Rating, obj.ESRB_Synopsis, obj.Platforms, obj.Popularity, obj.First_release_date, obj.Genres, obj.Name, obj.NameUrl, obj.Publishers, obj.Storyline, obj.Summary, obj.Igdb_Id, obj.Collection, obj.Category, obj.Rating, obj.RatingCount, obj.SimilarGames, obj.Tags, obj.Developers, obj.Game_modes, obj.Keywords, obj.Themes }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <Game>(); } } } return(result); }
public async Task <DbResult> Update_Game_DetailsAsync(Game obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { obj.NameUrl = Regex.Replace(obj.Name.Trim(), "[^a-zA-Z0-9]", "-"); obj.NameUrl = Regex.Replace(obj.NameUrl, @"(?<=(-))\1+", "").ToLower(); obj.NameUrl = obj.NameUrl.EndsWith("-") ? obj.NameUrl.Remove(obj.NameUrl.Length - 1, 1) : obj.NameUrl; using (var multiple = await con.QueryMultipleAsync(Update_Game_DetailsSP, new { obj.Barcode, obj.Vendor_Id, obj.PreOrder, obj.Active, obj.Id, obj.PEGI_Rating, obj.PEGI_Synopsis, obj.ESRB_Rating, obj.ESRB_Synopsis, obj.Platforms, obj.Popularity, obj.First_release_date, obj.Genres, obj.Name, obj.NameUrl, obj.Storyline, obj.Summary, obj.Game_modes, obj.Keywords }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <Game>(); } } } return(result); }
public async Task <DbResult> Add_New_Review(Review obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { obj.Link = Regex.Replace(obj.Title.Trim(), "[^a-zA-Z0-9]", "-"); obj.Link = Regex.Replace(obj.Link, @"(?<=(-))\1+", "").ToLower(); obj.Link = obj.Link.EndsWith("-") ? obj.Link.Remove(obj.Link.Length - 1, 1) : obj.Link; using (var multiple = await con.QueryMultipleAsync(Add_New_ReviewSP, new { obj.Rating, obj.Category, obj.Conclusion, obj.Content, obj.Introduction, obj.Likes, obj.Negative_Points, obj.Platform_Id, obj.Positive_Points, obj.Rating_Category, obj.UserId, obj.UserName, obj.Video, obj.Views, obj.Reference_Id, obj.Title, obj.Link, obj.Igdb_Id, obj.ReviewFor }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <Review>(); } } } return(result); }
public async Task <DbResult> UpdateAsync(GamePlatform obj) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { obj.NameUrl = Regex.Replace(obj.Name.Trim(), "[^a-zA-Z0-9]", "-"); obj.NameUrl = Regex.Replace(obj.NameUrl, @"(?<=(-))\1+", "").ToLower(); obj.NameUrl = obj.NameUrl.EndsWith("-") ? obj.NameUrl.Remove(obj.NameUrl.Length - 1, 1) : obj.NameUrl; using (var multiple = await con.QueryMultipleAsync(UpdateSP, new { obj.Code, obj.LogoUrl, obj.Banner, obj.Id, obj.Name, obj.NameUrl, obj.Active, obj.MetaDescription, obj.MetaKeyword, obj.PageContent, obj.PageTitle, obj.Position }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <GamePlatform>(); } } } return(result); }
public async Task <DbResult> UpdateUserAsync(User user) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { user.NameUrl = string.Format("{0}-{1}", user.FirstName, user.LastName); user.NameUrl = Regex.Replace(user.NameUrl.Trim(), "[^a-zA-Z0-9]", "-"); user.NameUrl = Regex.Replace(user.NameUrl, @"(?<=(-))\1+", "").ToLower(); user.NameUrl = user.NameUrl.EndsWith("-") ? user.NameUrl.Remove(user.NameUrl.Length - 1, 1) : user.NameUrl; using (var multiple = await con.QueryMultipleAsync(UpdateUserSP, new { user.Id, user.ISDCode, user.PhoneNumber, user.Country, user.Gender, user.DOB, user.Avatar, user.Background, user.FirstName, user.LastName, user.NameUrl, user.Email, user.PhoneVefified, user.EmailVerified }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <User>(); } } } return(result); }
public async Task <DbResult> RegisterUserAsync(User user) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { user.NameUrl = string.Format("{0}-{1}", user.FirstName, user.LastName); user.NameUrl = Regex.Replace(user.NameUrl.Trim(), "[^a-zA-Z0-9]", "-"); user.NameUrl = Regex.Replace(user.NameUrl, @"(?<=(-))\1+", "").ToLower(); user.NameUrl = user.NameUrl.EndsWith("-") ? user.NameUrl.Remove(user.NameUrl.Length - 1, 1) : user.NameUrl; user.Password = EncryptionHelper.Encrypt(user.Password); using (var multiple = await con.QueryMultipleAsync(RegisterUserSP, new { user.FirstName, user.LastName, user.NameUrl, user.Email, user.Password, user.ReferalKey }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { result.Data = multiple.ReadFirstOrDefault <User>(); } } } return(result); }
public async Task <DbResult> Search_By_query(string query) { DbResult result = null; using (var con = DbHelper.GetSqlConnection()) { using (var multiple = await con.QueryMultipleAsync(Search_By_querySP, new { query }, commandType: CommandType.StoredProcedure)) { result = multiple.ReadFirstOrDefault <DbResult>(); if (result != null && result.Success) { var _data = new SearchResult(); _data.GameList = multiple.Read <Game_Search>(); _data.GamePlatforms = multiple.Read <GamePlatform>(); _data.Accessories = multiple.Read <Product>(); _data.Consoles = multiple.Read <Product>(); _data.Blogs = multiple.Read <Blog>(); result.Data = _data; } } } return(result); }