public ShopPurchaseEN PurchaseAndGetSouvenir(int consumerID, int StoreId, ref string error, int LevelBarrel1, int LevelBarrel2) { ShopPurchaseEN result = new ShopPurchaseEN(); AchievementEN achievement = new AchievementEN(); try { con.Cnn.Open(); con.Tra = con.Cnn.BeginTransaction(); result = con.Cnn.Query <ShopPurchaseEN>("SpPurchaseStore", new { ConsumerID = consumerID, StoreId = StoreId, LevelBarrel1 = LevelBarrel1, LevelBarrel2 = LevelBarrel2 }, con.Tra, commandType: CommandType.StoredProcedure).FirstOrDefault(); if (result.Code == "00") { result.tracking = con.Cnn.Query <PlayersTrackingEN>("SpGetProgressGameByConsumer", new { @ConsumerID = consumerID }, con.Tra, commandType: CommandType.StoredProcedure).FirstOrDefault(); int TotalWinCoins = result.tracking.TotalWinCoins; result.Achievement = ProcessToWinAchievement(consumerID, 1, TotalWinCoins, 7, con.Tra); } con.Tra.Commit(); } catch (Exception ex) { con.Tra.Rollback(); Console.WriteLine("Error GameDAL: " + ex.Message); EventViewerLoggerDAL.LogError(ex.Message); error = ex.StackTrace; result = null; } finally { con.Cnn.Close(); } return(result); }
public IResponse createPurchaseResponse(ShopPurchaseEN pSouvenir, string error) { ShopPurchaseResponse response = new ShopPurchaseResponse(); if (pSouvenir == null) { response.Code = "04"; response.Message = error; } else { response.Title = pSouvenir.Title; response.Description = pSouvenir.Description; response.ImgUrl = pSouvenir.ImgUrl; response.Value = pSouvenir.Value; response.tracking = new TrackingResponse(); response.tracking.TotalWinCoins = pSouvenir.tracking.TotalWinCoins; response.tracking.TotalWinPrizes = pSouvenir.tracking.TotalWinPrizes; response.tracking.TotalSouvenirs = pSouvenir.tracking.TotalSouvenirs; response.tracking.AgeID = pSouvenir.tracking.AgeID; if (pSouvenir.Achievement.NewLevel > 0) { response.Achievement = new NewAchievement(); response.Achievement.Name = pSouvenir.Achievement.Name; response.Achievement.Level = pSouvenir.Achievement.Level; response.Achievement.Score = pSouvenir.Achievement.Score; response.Achievement.ValueNextLevel = pSouvenir.Achievement.ValueNextLevel; response.Achievement.Prize = pSouvenir.Achievement.Prize; } response.Code = pSouvenir.Code; response.Message = (error == "") ? pSouvenir.Message : error; } return(response); }