public async Task <int> AddTransaction(int offerId, decimal amount, int userId, int swapId) { DIBZ.Common.Model.Transaction trans = new DIBZ.Common.Model.Transaction { IsActive = true, Aomunt = amount, OfferId = offerId, IsPaid = true, ApplicationUserId = userId }; Db.Add(trans); var swapObj = await Db.GetObjectById <DIBZ.Common.Model.Swap>(swapId); DIBZ.Common.Model.Swap swap = new DIBZ.Common.Model.Swap(); swap = swapObj; if (swapObj.GameSwapPsersonId == userId) { swapObj.SwapStatus = SwapStatus.Payment_Done_By_Swapper; } else { swapObj.SwapStatus = SwapStatus.Payment_Done_By_Offerer; } Db.Add(swap); return(await Db.SaveAsync()); }
public async Task <DIBZ.Common.Model.Swap> AddSwap(DIBZ.Common.Model.Swap swap) { Db.Add(swap); await Db.SaveAsync(); return(swap); }
private async Task HandlingOfferedImpact(DIBZ.Common.Model.CounterOffer counterOffer) { //Creating new offer for counter person's game DIBZ.Common.Model.Offer impactOffer = new DIBZ.Common.Model.Offer { OfferStatus = OfferStatus.Accept, GameCatalogId = counterOffer.GameCounterOfferWithId, ApplicationUserId = counterOffer.CounterOfferPersonId, ReturnGameCatalogId = counterOffer.Offer.GameCatalogId, IsActive = true, }; Db.Add(impactOffer); //Creating new Swap for Counter Person's game DIBZ.Common.Model.Swap impactSwap = new DIBZ.Common.Model.Swap { OfferId = impactOffer.Id, IsActive = true, IsDeleted = false, GameSwapPsersonId = counterOffer.Offer.ApplicationUserId, GameSwapWithId = impactOffer.ReturnGameCatalogId.Value, SwapStatus = SwapStatus.Accepted }; await Db.SaveAsync(); await MarkOtherOffersNotAvailable(impactOffer); }
public async Task <DIBZ.Common.Model.Swap> CreateDeal(int id) { var counterOffer = await Db.GetObjectById <DIBZ.Common.Model.CounterOffer>(id); Scorecard offerCreaterSC = await Db.GetObjectById <DIBZ.Common.Model.Scorecard>(counterOffer.Offer.ApplicationUserId); if (offerCreaterSC == null) { offerCreaterSC = new Scorecard(); offerCreaterSC.ApplicationUserId = counterOffer.Offer.ApplicationUserId; offerCreaterSC.Proposals += 1; Db.Add(offerCreaterSC); } else { offerCreaterSC.ApplicationUserId = counterOffer.Offer.ApplicationUserId; offerCreaterSC.Proposals += 1; } Scorecard offerWantSC = await Db.GetObjectById <DIBZ.Common.Model.Scorecard>(counterOffer.CounterOfferPersonId); if (offerWantSC == null) { offerWantSC = new Scorecard(); offerWantSC.ApplicationUserId = counterOffer.CounterOfferPersonId; offerWantSC.Proposals += 1; Db.Add(offerWantSC); } else { offerWantSC.ApplicationUserId = counterOffer.CounterOfferPersonId; offerWantSC.Proposals += 1; } DIBZ.Common.Model.Swap swap = new DIBZ.Common.Model.Swap(); swap.OfferId = counterOffer.OfferId; swap.IsActive = true; swap.IsDeleted = false; swap.GameSwapPsersonId = counterOffer.CounterOfferPersonId; swap.GameSwapWithId = counterOffer.GameCounterOfferWithId; swap.SwapStatus = SwapStatus.Accepted; Db.Add(swap); var offer = await Db.GetObjectById <DIBZ.Common.Model.Offer>(counterOffer.OfferId); offer.OfferStatus = OfferStatus.Accept; await Db.SaveAsync(); await MarkOtherOffersNotAvailable(offer); //handling impact await HandlingOfferedImpact(counterOffer); return(swap); }
public async Task <ActionResult> CancelSwap(int swapStatus, int offerId, int gameSwapWithId, int gameSwapPersonId, bool isActive, DateTime updatedTime, string offererEmail, string swapperEmail, string offererNickName, string swapperNickName) { DIBZ.Common.Model.Swap swap = new DIBZ.Common.Model.Swap(); var swapLogic = LogicContext.Create <SwapLogic>(); swap.SwapStatus = (DIBZ.Common.Model.SwapStatus)swapStatus; swap.OfferId = offerId; swap.GameSwapWithId = gameSwapWithId; swap.GameSwapPsersonId = gameSwapPersonId; swap.IsActive = true; swap.UpdatedTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss")); swap = await swapLogic.AddSwap(swap); //EmailTemplateHelper templates = new EmailTemplateHelper(); EmailTemplateResponse emailTemplateResponse = new EmailTemplateResponse(); var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>(); emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(DIBZ.Common.Model.EmailType.Email, DIBZ.Common.Model.EmailContentType.SwapCancel); EmailTemplateHelper OffererTemplate = new EmailTemplateHelper(); OffererTemplate.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, offererNickName); OffererTemplate.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); var emailBodyOfferrer = OffererTemplate.FillTemplate(emailTemplateResponse.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(CurrentLoginSession.ApplicationUser.Email, emailTemplateResponse.Title, emailBodyOfferrer, EmailType.Email, Priority.Low); EmailHelper.Email(offererEmail, emailTemplateResponse.Title, emailBodyOfferrer); EmailTemplateHelper SwapperTemplate = new EmailTemplateHelper(); SwapperTemplate.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swapperNickName); SwapperTemplate.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); var emailBodySwapperr = SwapperTemplate.FillTemplate(emailTemplateResponse.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(CurrentLoginSession.ApplicationUser.Email, emailTemplateResponse.Title, emailBodySwapperr, EmailType.Email, Priority.Low); EmailHelper.Email(swapperEmail, emailTemplateResponse.Title, emailBodySwapperr); return(RedirectToAction("MyAllOffers", "Offer")); }
public async Task <DIBZ.Common.Model.Swap> CreateDealWithOfferStatusPaymentNeeded(int offerID, int gameSwapPsersonId, int gameSwapWithId) { var counterOffer = await GetCounterOfferByOfferId(offerID); Scorecard offerCreaterSC = await Db.GetObjectById <DIBZ.Common.Model.Scorecard>(counterOffer.Offer.ApplicationUserId); if (offerCreaterSC == null) { offerCreaterSC = new Scorecard(); offerCreaterSC.ApplicationUserId = counterOffer.Offer.ApplicationUserId; offerCreaterSC.Proposals += 1; Db.Add(offerCreaterSC); } else { offerCreaterSC.ApplicationUserId = counterOffer.Offer.ApplicationUserId; offerCreaterSC.Proposals += 1; } Scorecard offerWantSC = await Db.GetObjectById <DIBZ.Common.Model.Scorecard>(counterOffer.CounterOfferPersonId); if (offerWantSC == null) { offerWantSC = new Scorecard(); offerWantSC.ApplicationUserId = counterOffer.CounterOfferPersonId; offerWantSC.Proposals += 1; Db.Add(offerWantSC); } else { offerWantSC.ApplicationUserId = counterOffer.CounterOfferPersonId; offerWantSC.Proposals += 1; } DIBZ.Common.Model.Swap swap = new DIBZ.Common.Model.Swap(); swap.OfferId = offerID; swap.IsActive = true; swap.IsDeleted = false; swap.GameSwapPsersonId = gameSwapPsersonId; swap.GameSwapWithId = gameSwapWithId; swap.SwapStatus = SwapStatus.Accepted; swap.GamerOffererDFOM = this.DFOMCodeForGameOfferer(); swap.GamerSwapperDFOM = this.DFOMCodeForGameSwapper(); Db.Add(swap); await Db.SaveAsync(); var offer = await Db.GetObjectById <DIBZ.Common.Model.Offer>(offerID); offer.OfferStatus = OfferStatus.PaymentNeeded; offer.GameOffererDFOM = this.DFOMCodeForGameOfferer(); offer.GameSwapperDFOM = this.DFOMCodeForGameSwapper(); await Db.SaveAsync(); await Task.Delay(2000); await MarkOtherOffersNotAvailable(offer); //handling impact await HandlingOfferedImpact(counterOffer); return(swap); }
public async Task <IEnumerable <DIBZ.Common.DTO.Swap> > GetAllSwaps() { //declarations try { List <DIBZ.Common.Model.Swap> tempSwapList = new List <DIBZ.Common.Model.Swap>(); List <DIBZ.Common.DTO.Swap> swapListToShow = new List <DIBZ.Common.DTO.Swap>(); DIBZ.Common.Model.Swap swap = new DIBZ.Common.Model.Swap(); // 5 day rule check and its impact --- starts // DIBZ SRS for phase 2 version 1.5 //5 day rule starts after both parties have paid. var swapListExpiryRule = await Db.Query <DIBZ.Common.Model.Swap>(o => o.IsActive == true && !o.IsDeleted).QueryAsync(); //AllSwapsRecord Group by with OfferID and get list decrease order var groupbyOfferIDsExpiryRule = swapListExpiryRule.OrderByDescending(d => d.Id).GroupBy(g => g.OfferId); List <DIBZ.Common.Model.Swap> tempSwapListExpiryRule = new List <DIBZ.Common.Model.Swap>(); //now for loop to get latest swap status foreach (var item in groupbyOfferIDsExpiryRule) { //to get latest swap status var tempdata = item.First(); swap = (DIBZ.Common.Model.Swap)tempdata; tempSwapListExpiryRule.Add(swap); } foreach (var tempSwap in tempSwapListExpiryRule) { var scorecardLogic = LogicContext.Create <ScorecardLogic>(); // ************ 5 day rule starts after both parties have paid. ************** var getWorkingDaysCount = GetWorkingDaysCount(ConversionHelper.ConvertDateToTimeZone(tempSwap.CreatedTime)); LogHelper.LogInfo("getWorkingDaysCount: " + getWorkingDaysCount); //Condition when both party hasn't sent game on time. if (tempSwap.Offer.OfferStatus == OfferStatus.Accept && tempSwap.Offer.Transactions.Count() == 2 && (tempSwap.SwapStatus == SwapStatus.Payment_Done_By_Offerer || tempSwap.SwapStatus == SwapStatus.Payment_Done_By_Swapper) && getWorkingDaysCount > SystemSettings.DayRule) { await scorecardLogic.UpdateScoreCardOfApplicationUserWithNoShow(tempSwap.GameSwapPsersonId); await scorecardLogic.UpdateScoreCardOfApplicationUserWithNoShow(tempSwap.Offer.ApplicationUserId); await this.UpdateOfferStatusToPendingAndSetSwapToInActiveAndRemoveTransactionIfAny(tempSwap.OfferId, tempSwap.Id); } //Condition when offerer party hasn't sent game on time. if (tempSwap.Offer.OfferStatus == OfferStatus.Accept && tempSwap.Offer.Transactions.Count() == 2 && (tempSwap.SwapStatus != SwapStatus.Payment_Done_By_Offerer || tempSwap.SwapStatus != SwapStatus.Payment_Done_By_Swapper && tempSwap.SwapStatus == SwapStatus.Game2_Received) && getWorkingDaysCount > SystemSettings.DayRule) { await scorecardLogic.UpdateScoreCardOfApplicationUserWithNoShow(tempSwap.Offer.ApplicationUserId); await UpdateOfferStatusToPendingAndSetSwapToInActiveAndRemoveTransactionIfAny(tempSwap.OfferId, tempSwap.Id); } //Condition when swapper party hasn't sent game on time. if (tempSwap.Offer.OfferStatus == OfferStatus.Accept && tempSwap.Offer.Transactions.Count() == 2 && (tempSwap.SwapStatus != SwapStatus.Payment_Done_By_Offerer || tempSwap.SwapStatus != SwapStatus.Payment_Done_By_Swapper && tempSwap.SwapStatus == SwapStatus.Game1_Received) && getWorkingDaysCount > SystemSettings.DayRule) { await scorecardLogic.UpdateScoreCardOfApplicationUserWithNoShow(tempSwap.GameSwapPsersonId); await UpdateOfferStatusToPendingAndSetSwapToInActiveAndRemoveTransactionIfAny(tempSwap.OfferId, tempSwap.Id); } } // 5 day rule check and its impact --- ends var swapList = await Db.Query <DIBZ.Common.Model.Swap>(o => !o.IsDeleted).QueryAsync(); //AllSwapsRecord Group by with OfferID and get list decrease order var groupbyOfferIDs = swapList.OrderByDescending(d => d.Id).GroupBy(g => g.OfferId); //now for loop to get latest swap status foreach (var item in groupbyOfferIDs) { //to get latest swap status var tempdata = item.First(); swap = (DIBZ.Common.Model.Swap)tempdata; tempSwapList.Add(swap); } foreach (var tempSwap in tempSwapList) { DIBZ.Common.DTO.Swap swapModel = new DIBZ.Common.DTO.Swap(); if (tempSwap.IsActive) { if (tempSwap.SwapStatus == DIBZ.Common.Model.SwapStatus.Game2_Received) { var result = swapList.Where(d => d.OfferId == tempSwap.OfferId).Any(r => r.SwapStatus == DIBZ.Common.Model.SwapStatus.Game1_Received); if (result) { //this assignment is for ,which button to show swapModel.SwapButtonToShow = DIBZ.Common.Model.SwapStatus.Testing; } else { swapModel.SwapButtonToShow = DIBZ.Common.Model.SwapStatus.Game1_Received; } } else if (tempSwap.SwapStatus == DIBZ.Common.Model.SwapStatus.Game1_Received) { var result = swapList.Where(d => d.OfferId == tempSwap.OfferId).Any(r => r.SwapStatus == DIBZ.Common.Model.SwapStatus.Game2_Received); if (result) { swapModel.SwapButtonToShow = DIBZ.Common.Model.SwapStatus.Testing; } else { swapModel.SwapButtonToShow = DIBZ.Common.Model.SwapStatus.Game2_Received; } } if (tempSwap.SwapStatus == DIBZ.Common.Model.SwapStatus.Game2_NoShow) { var result = swapList.Where(d => d.OfferId == tempSwap.OfferId).Any(r => r.SwapStatus == DIBZ.Common.Model.SwapStatus.Game1_NoShow); if (result) { //this assignment is for ,which button to show swapModel.SwapButtonToShow = DIBZ.Common.Model.SwapStatus.Returned; } else { swapModel.SwapButtonToShow = DIBZ.Common.Model.SwapStatus.Game1_NoShow; } } else if (tempSwap.SwapStatus == DIBZ.Common.Model.SwapStatus.Game1_NoShow) { var result = swapList.Where(d => d.OfferId == tempSwap.OfferId).Any(r => r.SwapStatus == DIBZ.Common.Model.SwapStatus.Game2_NoShow); if (result) { swapModel.SwapButtonToShow = DIBZ.Common.Model.SwapStatus.Returned; } else { swapModel.SwapButtonToShow = DIBZ.Common.Model.SwapStatus.Game2_NoShow; } } swapModel.Id = tempSwap.Id; swapModel.CreatedTime = tempSwap.CreatedTime; swapModel.OfferedGameImageId = tempSwap.Offer.GameCatalog.GameImageId; swapModel.SwapGameImageId = tempSwap.GameSwapWith.GameImageId; swapModel.GameSwapPersonNickName = tempSwap.GameSwapPserson.NickName; swapModel.OfferPersonNickName = tempSwap.Offer.ApplicationUser.NickName; swapModel.GameSwapWithId = tempSwap.GameSwapWithId; swapModel.GameSwapPersonId = tempSwap.GameSwapPsersonId; swapModel.OfferPersonId = tempSwap.Offer.ApplicationUserId; swapModel.SwapStatus = (tempSwap.Offer.Transactions.Count == 2 && (tempSwap.SwapStatus == SwapStatus.Payment_Done_By_Offerer || tempSwap.SwapStatus == SwapStatus.Payment_Done_By_Swapper)) ? SwapStatus.Payment_Successful : tempSwap.SwapStatus; swapModel.OfferId = tempSwap.OfferId; swapModel.GameOffererDFOM = tempSwap.Offer.GameOffererDFOM; swapModel.GameSwapperDFOM = tempSwap.Offer.GameSwapperDFOM; swapModel.OfferStatus = tempSwap.Offer.OfferStatus; swapListToShow.Add(swapModel); } } return(swapListToShow); } catch (Exception ex) { LogHelper.LogError(ex.Message, ex); } return(null); }
public async Task <DIBZ.Common.Model.Notification> SaveNotificationForSwapAction(DIBZ.Common.Model.Swap swap, int tosent, int gameCatalogImageId, string message) { NotificationModel notificationModel = new NotificationModel(); DIBZ.Common.Model.Notification notification = new DIBZ.Common.Model.Notification(); var notificationLogic = LogicContext.Create <NotificationLogic>(); var additionalData = new { OfferId = swap.OfferId, GameCatalogImageId = gameCatalogImageId }; notificationModel.AdditionalData = Helpers.GetJson(additionalData); notificationModel.AppUserId = Convert.ToInt32(tosent); //Channel like Android,Ios,Web notificationModel.Channel = Convert.ToInt32(DIBZ.Common.Model.Channel.Web); notificationModel.Content = message; notificationModel.CreatedTime = DateTime.Now; notificationModel.LastError = ""; notificationModel.OfferId = swap.OfferId; //notificationModel.OfferIds = allOffers.Select(o => o.Id).ToList(); notificationModel.Status = Convert.ToInt32(DIBZ.Common.Model.NotificationStatus.Unseen); notificationModel.Title = "Swap Action"; notificationModel.NotificationType = Convert.ToInt32(DIBZ.Common.Model.NotificationType.Desktop); notificationModel.NotificationBusinessType = Convert.ToInt32(DIBZ.Common.Model.NotificationBusinessType.SwapAction); return(await notificationLogic.AddNotification(notificationModel)); }
public async Task <ActionResult> ChangeSwipStatus(int swapStatus, int offerId, int gameSwipWithId, int gameSwapPersonId, int offerPersonId, string failReasonVal, string failGameVal) { //declarations int failReasonIntValue = 0; int failGameIntVal = 0; string notificationMessage = string.Empty; DIBZ.Common.Model.Swap swap = new DIBZ.Common.Model.Swap(); DIBZ.Common.Model.Offer offer = new DIBZ.Common.Model.Offer(); DIBZ.Common.Model.ApplicationUser swapPerson = new DIBZ.Common.Model.ApplicationUser(); DIBZ.Common.Model.GameCatalog gameCatalog = new DIBZ.Common.Model.GameCatalog(); DIBZ.Common.Model.Notification notification = new DIBZ.Common.Model.Notification(); DIBZ.Common.Model.EmailTemplate emailTemplate = new DIBZ.Common.Model.EmailTemplate(); EmailTemplateHelper templates = new EmailTemplateHelper(); EmailTemplateResponse emailTemplateResponse = new EmailTemplateResponse(); DIBZ.Common.Model.EmailNotification email = new DIBZ.Common.Model.EmailNotification(); var scorecardLogic = LogicContext.Create <ScorecardLogic>(); var swapLogic = LogicContext.Create <SwapLogic>(); var offerLogic = LogicContext.Create <OfferLogic>(); var gameCatalogLogic = LogicContext.Create <GameCatalogLogic>(); var AuthLogic = LogicContext.Create <AuthLogic>(); var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>(); swap.SwapStatus = (DIBZ.Common.Model.SwapStatus)swapStatus; swap.OfferId = offerId; swap.GameSwapWithId = gameSwipWithId; swap.GameSwapPsersonId = gameSwapPersonId; swap.IsActive = true; swap.UpdatedTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss")); //get offer by Id to get Id of Offer Creater person offer = await offerLogic.GetOfferById(offerId); //add swap swap = await swapLogic.AddSwap(swap); //get applicationUserBy applicationUserID swapPerson = await AuthLogic.GetApplicationUserById(swap.GameSwapPsersonId); //get gamecatalog by gameCatalogId gameCatalog = await gameCatalogLogic.GetGameCatalogById(swap.GameSwapWithId); if (swap != null) { var status = (DIBZ.Common.Model.SwapStatus)swapStatus; if (status == DIBZ.Common.Model.SwapStatus.Game1_NoShow) { //if it is SentGame case so update status of only one party at one one await scorecardLogic.UpdateScoreCardByAppUserId(offer.ApplicationUserId, swapStatus, failReasonIntValue, false); //Save notification notificationMessage = "Your " + swap.Offer.GameCatalog.Name + " game hasn't been received with in 5 day, Thank you."; int gameImageId = swap.Offer.GameCatalog.GameImageId; notification = await SaveNotificationForSwapAction(swap, swap.Offer.ApplicationUserId, gameImageId, notificationMessage); //sent notification to user new DIBZ.Services.ServerNotificationService().SwapAction(notification.AppUserId, notification.AdditionalData); //create email template emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.Game_1_NoShow); templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.Offer.ApplicationUser.NickName); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.GameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, swap.Offer.GameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, gameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, gameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); //templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.GameCatalog.Name); var emailBody = templates.FillTemplate(emailTemplateResponse.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(swap.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low); EmailHelper.Email(swap.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody); } else if (status == DIBZ.Common.Model.SwapStatus.Game2_NoShow) { //if it is SentGame case so update status of only one party at one one await scorecardLogic.UpdateScoreCardByAppUserId(swap.GameSwapPsersonId, swapStatus, failReasonIntValue, false); //Save notification notificationMessage = "Your " + swap.Offer.ReturnGameCatalog.Name + " game hasn't been received with in 5 day, Thank you."; int gameImageId = swap.Offer.ReturnGameCatalog.GameImageId; notification = await SaveNotificationForSwapAction(swap, swap.GameSwapPsersonId, gameImageId, notificationMessage); //sent notification to user new DIBZ.Services.ServerNotificationService().SwapAction(notification.AppUserId, notification.AdditionalData); //create email template emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.Game_2_NoShow); templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.GameSwapPserson.NickName); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.GameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, swap.Offer.GameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, gameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, gameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); //templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.ReturnGameCatalog.Name); var emailBody = templates.FillTemplate(emailTemplateResponse.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(swap.GameSwapPserson.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low); EmailHelper.Email(swap.GameSwapPserson.Email, emailTemplateResponse.Title, emailBody); } else if (status == DIBZ.Common.Model.SwapStatus.All_NoShow) { //get email template emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.All_NoShow); //Save notification notificationMessage = "Your " + swap.Offer.GameCatalog.Name + " game hasn't been received with in 5 day, Thank you."; int offerGameImageId = swap.Offer.GameCatalog.GameImageId; notification = await SaveNotificationForSwapAction(swap, swap.Offer.ApplicationUserId, offerGameImageId, notificationMessage); //sent notification to user new DIBZ.Services.ServerNotificationService().SwapAction(notification.AppUserId, notification.AdditionalData); templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.Offer.ApplicationUser.NickName); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.GameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, swap.Offer.GameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, swap.Offer.ReturnGameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, swap.Offer.ReturnGameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); //templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.GameCatalog.Name); var emailBodyOfferCreator = templates.FillTemplate(emailTemplateResponse.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(swap.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBodyOfferCreator, EmailType.Email, Priority.Low); EmailHelper.Email(swap.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBodyOfferCreator); //Save notification notificationMessage = "Your " + swap.Offer.ReturnGameCatalog.Name + " game hasn't been received with in 5 day, Thank you."; int gameImageId = swap.Offer.ReturnGameCatalog.GameImageId; notification = await SaveNotificationForSwapAction(swap, swap.GameSwapPsersonId, gameImageId, notificationMessage); //sent notification to user new DIBZ.Services.ServerNotificationService().SwapAction(notification.AppUserId, notification.AdditionalData); //create email template EmailTemplateHelper template2 = new EmailTemplateHelper(); EmailTemplateResponse emailTemplateResponse2 = new EmailTemplateResponse(); emailTemplateResponse2 = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.All_NoShow); template2.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.GameSwapPserson.NickName); template2.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.ReturnGameCatalog.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameFormat, swap.Offer.ReturnGameCatalog.Format.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, swap.Offer.GameCatalog.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, swap.Offer.GameCatalog.Format.Name); template2.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); var emailBodyGameSwapPerson = template2.FillTemplate(emailTemplateResponse2.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(swap.GameSwapPserson.Email, emailTemplateResponse2.Title, emailBodyGameSwapPerson, EmailType.Email, Priority.Low); EmailHelper.Email(swap.GameSwapPserson.Email, emailTemplateResponse2.Title, emailBodyGameSwapPerson); } else if (status == DIBZ.Common.Model.SwapStatus.Game1_Received) { //if it is SentGame case so update status of only one party at one one await scorecardLogic.UpdateScoreCardByAppUserId(offer.ApplicationUserId, swapStatus, failReasonIntValue, true); //Save notification notificationMessage = "Your" + swap.Offer.GameCatalog.Name + "game has been received! Thank you."; int gameImageId = swap.Offer.GameCatalog.GameImageId; notification = await SaveNotificationForSwapAction(swap, swap.Offer.ApplicationUserId, gameImageId, notificationMessage); //sent notification to user new DIBZ.Services.ServerNotificationService().SwapAction(notification.AppUserId, notification.AdditionalData); //create email template emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.Game_1_Recieved); templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.Offer.ApplicationUser.NickName); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.GameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, swap.Offer.GameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, swap.Offer.ReturnGameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, swap.Offer.ReturnGameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); var emailBody = templates.FillTemplate(emailTemplateResponse.Body); LogHelper.LogInfo("sending email..."); LogHelper.LogInfo("UrlContactUsPage: " + ConfigurationManager.AppSettings["UrlContactUsPage"]); //save email data in table await emailTemplateLogic.SaveEmailNotification(swap.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low); EmailHelper.Email(swap.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody); //sent email // await EmailHelper.SendEmail(swap.Offer.ApplicationUser.Email,EmailTemplateResponce.Title, emailBody); } else if (status == DIBZ.Common.Model.SwapStatus.Game2_Received) { //if it is SentGame case so update status of only one party at one one await scorecardLogic.UpdateScoreCardByAppUserId(gameSwapPersonId, swapStatus, failReasonIntValue, true); //Save notification notificationMessage = "Your " + gameCatalog.Name + " game has been received! Thank you."; int gameImageId = gameCatalog.GameImageId; notification = await SaveNotificationForSwapAction(swap, swap.GameSwapPsersonId, gameImageId, notificationMessage); //sent notification to user new DIBZ.Services.ServerNotificationService().SwapAction(notification.AppUserId, notification.AdditionalData); //create email template emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(DIBZ.Common.Model.EmailType.Email, DIBZ.Common.Model.EmailContentType.Game_2_Recieved); templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.GameSwapPserson.NickName); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, gameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, gameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, swap.Offer.GameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, swap.Offer.GameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); //templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, gameCatalog.Name); var emailBody = templates.FillTemplate(emailTemplateResponse.Body); LogHelper.LogInfo("sending email..."); LogHelper.LogInfo("UrlContactUsPage: " + ConfigurationManager.AppSettings["UrlContactUsPage"]); //save email data in table await emailTemplateLogic.SaveEmailNotification(swap.GameSwapPserson.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low); EmailHelper.Email(swap.GameSwapPserson.Email, emailTemplateResponse.Title, emailBody); } else { if (failReasonVal != "" || failReasonVal == string.Empty) { failReasonIntValue = ConversionHelper.SafeConvertToInt32(failReasonVal); } if (failGameVal != "" || failGameVal == string.Empty) { failGameIntVal = ConversionHelper.SafeConvertToInt32(failGameVal); } //if is not a SentGame case so update status of both parties if (status != DIBZ.Common.Model.SwapStatus.Test_Fail) { await scorecardLogic.UpdateScoreCardByAppUserId(offer.ApplicationUserId, swapStatus, failReasonIntValue, false); await scorecardLogic.UpdateScoreCardByAppUserId(gameSwapPersonId, swapStatus, failReasonIntValue, false); } if (status == DIBZ.Common.Model.SwapStatus.Test_Pass) { notificationMessage = "Congratulation! your swap test has been passed!"; } if (status == DIBZ.Common.Model.SwapStatus.Test_Fail) { string failGameName = string.Empty; if (failGameIntVal == (int)DIBZ.Common.Model.SwapStatus.Game1_Received) { //get OfferCreater GameName failGameName = swap.Offer.GameCatalog.Name; //update score card only offer creater await scorecardLogic.UpdateScoreCardByAppUserId(offer.ApplicationUserId, swapStatus, failReasonIntValue, false); } if (failGameIntVal == (int)DIBZ.Common.Model.SwapStatus.Game2_Received) { //get SwapPerson GameName failGameName = gameCatalog.Name; //update score card only SwapPerson await scorecardLogic.UpdateScoreCardByAppUserId(gameSwapPersonId, swapStatus, failReasonIntValue, false); } if (failReasonIntValue == (int)DIBZ.Common.Model.FailCasses.DiscScratched) { notificationMessage = "Sorry! " + failGameName + " has been failed due to discScratched!"; } else if (failReasonIntValue == (int)DIBZ.Common.Model.FailCasses.CaseOrInstructionsInPoorCondition) { notificationMessage = "Sorry! " + failGameName + " has been failed due to case/instruction in poor condition!"; } else if (failReasonIntValue == (int)DIBZ.Common.Model.FailCasses.GameFailedTesting) { notificationMessage = "Sorry! " + failGameName + " has been failed due to game failed testing!"; } } if (status == DIBZ.Common.Model.SwapStatus.Dispatched) { LogHelper.LogInfo("swaps status set to dispatach."); // removing game from offer creator's collection. await gameCatalogLogic.RemoveGameFromCollectionOnDispatch(offer.ApplicationUserId, offer.GameCatalogId); // removing game from swapper's collection. await gameCatalogLogic.RemoveGameFromCollectionOnDispatch(swap.GameSwapPsersonId, swap.GameSwapWithId); notificationMessage = "Congratulation! swap has been Successfuly dibz!"; } if (status == DIBZ.Common.Model.SwapStatus.Test_Pass || status == DIBZ.Common.Model.SwapStatus.Test_Fail || status == DIBZ.Common.Model.SwapStatus.Dispatched) { int gameImageId = swap.Offer.GameCatalog.GameImageId; int swapperGameImageId = swap.GameSwapWithId; //Save notification to one User notification = await SaveNotificationForSwapAction(swap, swap.Offer.ApplicationUserId, gameImageId, notificationMessage); //sent notification to One user new DIBZ.Services.ServerNotificationService().SwapAction(notification.AppUserId, notification.AdditionalData); //Save notification to anotherUSerr notification = await SaveNotificationForSwapAction(swap, swap.GameSwapPsersonId, swapperGameImageId, notificationMessage); // sent notification to anotherUSer new DIBZ.Services.ServerNotificationService().SwapAction(notification.AppUserId, notification.AdditionalData); //sent Bcc email List <string> emailList = new List <string>(); emailList.Add(swapPerson.Email); emailList.Add(swap.Offer.ApplicationUser.Email); if (status == SwapStatus.Test_Pass) { //create email template for offerrer emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.Test_Pass); templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.Offer.ApplicationUser.NickName); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.GameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, swap.Offer.GameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, swap.Offer.ReturnGameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, swap.Offer.ReturnGameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); var emailBody = templates.FillTemplate(emailTemplateResponse.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(swap.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low); EmailHelper.Email(swap.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody); //create template for swapper EmailTemplateResponse emailTemplateResponse2 = new EmailTemplateResponse(); EmailTemplateHelper template2 = new EmailTemplateHelper(); emailTemplateResponse2 = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.Test_Pass); template2.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.GameSwapPserson.NickName); template2.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.GameSwapWith.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameFormat, swap.GameSwapWith.Format.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, swap.Offer.GameCatalog.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, swap.Offer.GameCatalog.Format.Name); template2.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); var emailBodySwapper = template2.FillTemplate(emailTemplateResponse2.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(swapPerson.Email, emailTemplateResponse2.Title, emailBodySwapper, EmailType.Email, Priority.Low); EmailHelper.Email(swapPerson.Email, emailTemplateResponse2.Title, emailBodySwapper); } else if (status == SwapStatus.Test_Fail) { if (failGameIntVal == (int)DIBZ.Common.Model.SwapStatus.Game1_Received) { //create email template game1 test failed emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.Test_Fail); templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.Offer.ApplicationUser.NickName); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.GameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, swap.Offer.GameCatalog.Format.Name); if (failReasonIntValue == (int)DIBZ.Common.Model.FailCasses.DiscScratched) { notificationMessage = "Sorry! " + swap.Offer.GameCatalog.Name + " has been failed due to discScratched!"; templates.AddParam(DIBZ.Common.Model.Contants.FailReason, notificationMessage); } else if (failReasonIntValue == (int)DIBZ.Common.Model.FailCasses.CaseOrInstructionsInPoorCondition) { notificationMessage = "Sorry! " + swap.Offer.GameCatalog.Name + " has been failed due to case/instruction in poor condition!"; templates.AddParam(DIBZ.Common.Model.Contants.FailReason, notificationMessage); } else if (failReasonIntValue == (int)DIBZ.Common.Model.FailCasses.GameFailedTesting) { notificationMessage = "Sorry! " + swap.Offer.GameCatalog.Name + " has been failed due to game failed testing!"; templates.AddParam(DIBZ.Common.Model.Contants.FailReason, notificationMessage); } templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, gameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, gameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); var emailBody = templates.FillTemplate(emailTemplateResponse.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low); EmailHelper.Email(offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody); } else { //create email template game2 test failed EmailTemplateResponse emailTemplateResponse2 = new EmailTemplateResponse(); EmailTemplateHelper template2 = new EmailTemplateHelper(); emailTemplateResponse2 = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.Test_Fail); template2.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.GameSwapPserson.NickName); template2.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, gameCatalog.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, gameCatalog.Format.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.GameCatalog.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameFormat, swap.Offer.GameCatalog.Format.Name); template2.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); var emailBody = template2.FillTemplate(emailTemplateResponse2.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(swap.GameSwapPserson.Email, emailTemplateResponse2.Title, emailBody, EmailType.Email, Priority.Low); EmailHelper.Email(swap.GameSwapPserson.Email, emailTemplateResponse2.Title, emailBody); } } else if (status == SwapStatus.Dispatched) { //create email template for Offerrer emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.Dispatch); templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.Offer.ApplicationUser.NickName); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.Offer.GameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, swap.Offer.GameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, swap.Offer.ReturnGameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, swap.Offer.ReturnGameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Dispatch, swap.Offer.ReturnGameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper_Dispatch, swap.Offer.ReturnGameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.AppUserAddress, swap.Offer.ApplicationUser.Address); templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); var emailBody = templates.FillTemplate(emailTemplateResponse.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(swap.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low); EmailHelper.Email(swap.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody); //create email template for Swapper EmailTemplateResponse emailTemplateResponse2 = new EmailTemplateResponse(); EmailTemplateHelper template2 = new EmailTemplateHelper(); emailTemplateResponse2 = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.Dispatch); template2.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, swap.GameSwapPserson.NickName); template2.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, swap.GameSwapWith.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameFormat, swap.GameSwapWith.Format.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, swap.Offer.GameCatalog.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, swap.Offer.GameCatalog.Format.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Dispatch, swap.Offer.GameCatalog.Name); template2.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper_Dispatch, swap.Offer.GameCatalog.Format.Name); template2.AddParam(DIBZ.Common.Model.Contants.AppUserAddress, swap.GameSwapPserson.Address); template2.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); var emailBodySwapper = template2.FillTemplate(emailTemplateResponse2.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(swapPerson.Email, emailTemplateResponse2.Title, emailBodySwapper, EmailType.Email, Priority.Low); EmailHelper.Email(swapPerson.Email, emailTemplateResponse2.Title, emailBodySwapper); } // await EmailHelper.SendEmailBcc(emailList, "Dibz swap status update", notificationMessage); } } return(Json(new { IsSuccess = true, data = string.Empty }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, fail = "Some thing wrong!" }, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> AcceptOfferAfterTransactionDone(int counterOfferId) { DIBZ.Common.Model.CounterOffer counterOffer = new DIBZ.Common.Model.CounterOffer(); var counterOfferLogic = LogicContext.Create <CounterOfferLogic>(); counterOffer = await counterOfferLogic.GetCounterOfferById(counterOfferId); //variable declations var offerLogic = LogicContext.Create <OfferLogic>(); var notificationLogic = LogicContext.Create <NotificationLogic>(); var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>(); DIBZ.Common.DTO.NotificationModel notificationModel = new DIBZ.Common.DTO.NotificationModel(); DIBZ.Common.Model.Swap swap = new DIBZ.Common.Model.Swap(); DIBZ.Common.Model.Notification notification = new DIBZ.Common.Model.Notification(); DIBZ.Common.Model.EmailTemplate emailTemplate = new DIBZ.Common.Model.EmailTemplate(); EmailTemplateHelper templates = new EmailTemplateHelper(); EmailTemplateResponse emailTemplateResponse = new EmailTemplateResponse(); DIBZ.Common.Model.EmailNotification email = new DIBZ.Common.Model.EmailNotification(); //create deal swap = await counterOfferLogic.CreateDeal(counterOffer.Offer.Id, counterOffer.CounterOfferPersonId, counterOffer.GameCounterOfferWithId); //Deleting all the other offers of offered game await offerLogic.GetAllOfferByGameAndApplicationUser(counterOffer.Offer.ApplicationUserId, counterOffer.Offer.GameCatalogId); //Deleting all the offers of counter offer game. await offerLogic.GetAllOfferByGameAndApplicationUser(counterOffer.CounterOfferPersonId, counterOffer.Offer.ReturnGameCatalogId.Value); //sent notification to requested person to inform that his request has been accepted notificationModel.AppUserId = swap.GameSwapPsersonId; notificationModel.Channel = Convert.ToInt32(DIBZ.Common.Model.Channel.Web); notificationModel.Content = "Swap has been committed for " + counterOffer.Offer.GameCatalog.Name + "."; notificationModel.CreatedTime = DateTime.Now; notificationModel.IsActive = true; notificationModel.IsDeleted = false; notificationModel.LastError = ""; notificationModel.NotificationBusinessType = Convert.ToInt32(DIBZ.Common.Model.NotificationBusinessType.AcceptOffer); notificationModel.NotificationType = Convert.ToInt32(DIBZ.Common.Model.NotificationType.Desktop); notificationModel.OfferId = counterOffer.OfferId; notificationModel.Status = Convert.ToInt32(DIBZ.Common.Model.NotificationStatus.Unseen); notificationModel.Title = "Accept Offer"; //save notification in notification table var additionalData = new { OfferId = counterOffer.Offer.Id, CounterOfferPersonId = counterOffer.CounterOfferPersonId, GameCounterOfferWithId = counterOffer.GameCounterOfferWithId, GameCatalogImageId = counterOffer.Offer.GameCatalog.GameImageId }; notificationModel.AdditionalData = Helpers.GetJson(additionalData); notification = await notificationLogic.AddNotification(notificationModel); //sent notification new DIBZ.Services.ServerNotificationService().AcceptOffer(counterOffer.CounterOfferPersonId, notification.Id, notificationModel.Content, notificationModel.CreatedTime, notificationModel.AdditionalData); //create email template emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.AcceptOffer); templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, counterOffer.Offer.ApplicationUser.NickName); templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName_Swapper, counterOffer.CounterOfferPerson.NickName); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, counterOffer.Offer.GameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, counterOffer.Offer.ReturnGameCatalog.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, counterOffer.Offer.GameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, counterOffer.Offer.ReturnGameCatalog.Format.Name); templates.AddParam(DIBZ.Common.Model.Contants.UrlPossibleSwap, string.Format("<a href='{0}'>here</a>", hostName + "/Offer/PossibleSwaps")); templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs")); //templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, counterOffer.Offer.GameCatalog.Name); var emailBody = templates.FillTemplate(emailTemplateResponse.Body); //save email data in table await emailTemplateLogic.SaveEmailNotification(counterOffer.CounterOfferPerson.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low); EmailHelper.Email(counterOffer.CounterOfferPerson.Email, emailTemplateResponse.Title, emailBody); // and as well as, email sent to him // EmailHelper.Email(counterOffer.CounterOfferPerson.Email, EmailTemplateResponce.Title,emailBody); return(RedirectToAction("MySwaps", "Offer")); }