public async Task <ActionResult> SendForgotPasswordEmailNotification(string emailAddress)
        {
            DIBZ.Common.Model.ApplicationUser appUser = new DIBZ.Common.Model.ApplicationUser();
            var authLogic = LogicContext.Create <AuthLogic>();
            var result    = authLogic.GetApplicationUserByEmail(emailAddress);

            if (result != null)
            {
                EmailTemplateHelper   templates             = new EmailTemplateHelper();
                EmailTemplateResponse emailTemplateResponse = new EmailTemplateResponse();
                DIBZ.Common.Model.EmailNotification email   = new DIBZ.Common.Model.EmailNotification();
                var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();

                emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.ForgotPassword);

                templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, result.NickName);
                templates.AddParam(DIBZ.Common.Model.Contants.ForgotPassword, string.Format("<a href='{0}'>Here</a>", string.Concat(Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.LastIndexOf("/") + 1), "ChangePassword?id=" + result.Id)));
                templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>link</a>", hostName + "/Dashboard/ContactUs"));
                var emailBody = templates.FillTemplate(emailTemplateResponse.Body);

                //save email data in table
                await emailTemplateLogic.SaveEmailNotification(result.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.High);

                EmailHelper.Email(result.Email, emailTemplateResponse.Title, emailBody);
                return(Json(new { IsSuccess = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { IsSuccess = false, fail = "some thing wrong" }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #2
0
        private static string MapearTemplateHTML(Usuario usuario, string titulo, string templatePath)
        {
            Dictionary <string, string> mapper = new Dictionary <string, string>();

            mapper.Add("{userName}", usuario.UserName);
            mapper.Add("{password}", usuario.Password);


            string template = EmailTemplateHelper.FillTemplate(titulo, templatePath, mapper);

            return(template);
        }
        public async Task <ActionResult> Register(string id, string firstName, string surname, string nickName, string email, string password, string mobileNo, string birthYear, string postalCode, string address, bool?rememberMe = true)
        {
            var authLogic = LogicContext.Create <AuthLogic>();

            try
            {
                var User = authLogic.AddUpdateUser(Convert.ToInt32(id), firstName, surname, nickName, email, password, mobileNo, birthYear, postalCode, address);
                if (User != null)
                {
                    var loginSession = authLogic.CreateLoginSession(email, password, false);
                    Response.Cookies["AuthCookie"].Value = loginSession.Token;
                    if (rememberMe == true)
                    {
                        Response.Cookies["AuthCookie"].Expires = DateTime.Now.AddYears(1);
                    }

                    EmailTemplateHelper   templates             = new EmailTemplateHelper();
                    EmailTemplateResponse emailTemplateResponse = new EmailTemplateResponse();
                    DIBZ.Common.Model.EmailNotification Email   = new DIBZ.Common.Model.EmailNotification();

                    var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();
                    emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.SignUp);

                    String[] parts    = email.Split(new[] { '@' });
                    String   username = parts[0]; // "hello"
                    String   domain   = parts[1]; // "example.com"

                    templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, username);
                    templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs"));
                    var emailBody = templates.FillTemplate(emailTemplateResponse.Body);

                    await emailTemplateLogic.SaveEmailNotification(email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low);

                    EmailHelper.Email(email, emailTemplateResponse.Title, emailBody);
                    //notification to admin if new user registered.
                    EmailHelper.NotificationToAdmin(email, firstName + ' ' + surname, "Signup");
                    await MailChimpsSubs(email, firstName, surname, mobileNo);

                    return(Json(new { IsSuccess = true, AppUserName = loginSession.ApplicationUser.NickName, AppUserId = loginSession.ApplicationUserId }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { IsSuccess = false, fail = "Some Thing Wrong!" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { IsSuccess = false, fail = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #4
0
        public static string MapearTemplateHTML(Reunion reunion, string titulo, string templatePath)
        {
            Dictionary <string, string> mapper = new Dictionary <string, string>();

            mapper.Add("{nroReunion}", reunion.Id.ToString());
            mapper.Add("{reunionTitulo}", reunion.Titulo);
            mapper.Add("{encargado}", string.Format("{0}", reunion.Encargado.FullNameUser));
            mapper.Add("{fechaCulto}", reunion.FechaCulto.ToString("D", CultureInfo.CurrentUICulture));
            mapper.Add("{fechaEnsayo}", reunion.FechaEnsayo.ToString("D", CultureInfo.CurrentUICulture));
            mapper.Add("{descripcion}", reunion.Descripcion);

            mapper.Add("{linkReunion}", string.Format("{0}/Reunion/Details?Reunion_IdReunion={1}", ConfigurationHelper.SiteRoot, reunion.Id));

            string template = EmailTemplateHelper.FillTemplate(titulo, templatePath, mapper);

            return(template);
        }
예제 #5
0
        public static void NotificarActualizacionFechasCulto()
        {
            var usuarios = SeguridadComponent.GetUsuariosByOperaciones(new List <string>()
            {
                Operaciones.REUNIONES_FECHAS_NOTIFICACIONES
            });

            var proximas = GetProximasFechas(DateTime.Now, DateTime.Now.AddMonths(2));

            if (proximas.Count == 0)
            {
                return;
            }

            foreach (var item in proximas.Select(m => m.Encargado).Distinct())
            {
                usuarios.Add(item);
            }

            IList <string> emailsTo = usuarios.Select(m => m.Email).Distinct().ToList();


            Dictionary <string, string> mapper = new Dictionary <string, string>();
            StringBuilder builder = new StringBuilder();

            foreach (var item in proximas)
            {
                mapper = new Dictionary <string, string>();
                mapper.Add("{FECHA_ITEM}", item.Fecha.ToString("dd/MM/yyyy"));
                mapper.Add("{ENCARGADO_ITEM}", item.Encargado.FullNameUser);
                mapper.Add("{TEMA_ITEM}", item.Tema);
                builder.Append(EmailTemplateHelper.FillSimpleTemplate(
                                   ConfigurationHelper.DirectorioMailTemplateActualizacionEncargadosCultos_ITEM, mapper));
            }

            mapper = new Dictionary <string, string>();
            mapper.Add("{linkListado}", string.Format("{0}/Reunion/ProximasFechas", ConfigurationHelper.SiteRoot));
            mapper.Add("{items}", builder.ToString());
            string template = EmailTemplateHelper.FillTemplate("Próximas fechas y encargados de cultos",
                                                               ConfigurationHelper.DirectorioMailTemplateActualizacionEncargadosCultos, mapper);

            MailSender.Send(emailsTo, "Próximas fechas y encargados de cultos", template, true);
        }
        public async Task <ActionResult> SaveNewsLetterEmailAddress(string emailAddress)
        {
            DIBZDbContext context       = new DIBZDbContext();
            var           notifierEmail = (from NotifierEmails in context.NotifierEmails
                                           orderby NotifierEmails.CreatedTime descending
                                           select new
            {
                EmailAddress = NotifierEmails.EmailAddress
            }).ToList();


            if (notifierEmail.Count != 0)
            {
                // Email Sending to Specific Email address which is specified by DON.
                var notifierLastEmail                       = notifierEmail.FirstOrDefault().EmailAddress;
                EmailTemplateHelper   templates             = new EmailTemplateHelper();
                EmailTemplateResponse emailTemplateResponse = new EmailTemplateResponse();
                DIBZ.Common.Model.EmailNotification Email   = new DIBZ.Common.Model.EmailNotification();

                var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();
                emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.NewsletterSubscribe);

                templates.AddParam(DIBZ.Common.Model.Contants.EmailAddress, emailAddress);
                var emailBody = templates.FillTemplate(emailTemplateResponse.Body);
                await emailTemplateLogic.SaveEmailNotification(notifierLastEmail, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low);

                EmailHelper.Email(notifierLastEmail, emailTemplateResponse.Title, emailBody);
            }

            DIBZ.Common.Model.NewsLetter newsLetter = new DIBZ.Common.Model.NewsLetter();
            var newsLetterLogic = LogicContext.Create <NewsLetterLogic>();
            var result          = await newsLetterLogic.AddNewsLetter(emailAddress);

            if (result == true)
            {
                return(Json(new { IsSuccess = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { IsSuccess = false, fail = "some thing wrong" }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #7
0
        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"));
        }
예제 #8
0
        public async Task <ActionResult> AddPaymentTransaction(string offerId, string amount)
        {
            var transactionLogic   = LogicContext.Create <TransactionLogic>();
            var offerLogic         = LogicContext.Create <OfferLogic>();
            var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();

            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();
            try
            {
                var offer = await offerLogic.GetOfferById(ConversionHelper.SafeConvertToInt32(offerId));

                var transactionData = await transactionLogic.AddTransaction(ConversionHelper.SafeConvertToInt32(offerId), Convert.ToDecimal(amount), CurrentLoginSession.ApplicationUser.Id, offer.Swaps.FirstOrDefault().Id);

                if (offer.OfferStatus == OfferStatus.PaymentNeeded && offer.Transactions.Count() == 2)
                {
                    await offerLogic.UpdateOfferStatusToAccept(offer.Id);
                }

                if (transactionData > 0)
                {
                    string QRCodeImagePath = QRHelper.GenerateAndSaveQrCodeForOffer(CurrentLoginSession.ApplicationUser.Email, offer.Id, this.Url.Action("ReadQR", "Offer", new { id = offer.Id }, this.Request.Url.Scheme));
                    if (CurrentLoginSession.ApplicationUserId == offer.ApplicationUserId)
                    {
                        emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(DIBZ.Common.Model.EmailType.Email, DIBZ.Common.Model.EmailContentType.PaymentDone);

                        templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, offer.ApplicationUser.NickName);
                        templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName_Swapper, offer.Swaps.FirstOrDefault().GameSwapPserson.NickName);

                        templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, offer.GameCatalog.Name);
                        templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, offer.ReturnGameCatalog.Name);

                        templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, offer.GameCatalog.Format.Name);
                        templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, offer.ReturnGameCatalog.Format.Name);

                        templates.AddParam(DIBZ.Common.Model.Contants.DFOM_Code, offer.GameOffererDFOM);

                        templates.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs"));
                        var emailBodyOfferrer = templates.FillTemplate(emailTemplateResponse.Body);

                        //save email data in table
                        await emailTemplateLogic.SaveEmailNotification(CurrentLoginSession.ApplicationUser.Email, emailTemplateResponse.Title, emailBodyOfferrer, EmailType.Email, Priority.Low);

                        EmailHelper.EmailAttachement(CurrentLoginSession.ApplicationUser.Email, emailTemplateResponse.Title, emailBodyOfferrer, QRCodeImagePath);
                    }
                    else
                    {
                        EmailTemplateHelper   TemplatesSwapper             = new EmailTemplateHelper();
                        EmailTemplateResponse emailTemplateResponseSwapper = new EmailTemplateResponse();
                        //get email template
                        emailTemplateResponseSwapper = await emailTemplateLogic.GetEmailTemplate(DIBZ.Common.Model.EmailType.Email, DIBZ.Common.Model.EmailContentType.PaymentDone);

                        TemplatesSwapper.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, CurrentLoginSession.ApplicationUser.NickName);
                        TemplatesSwapper.AddParam(DIBZ.Common.Model.Contants.AppUserNickName_Swapper, offer.ApplicationUser.NickName);

                        TemplatesSwapper.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, offer.ReturnGameCatalog.Name);
                        TemplatesSwapper.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, offer.GameCatalog.Name);

                        TemplatesSwapper.AddParam(DIBZ.Common.Model.Contants.GameFormat, offer.ReturnGameCatalog.Format.Name);
                        TemplatesSwapper.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, offer.GameCatalog.Format.Name);

                        TemplatesSwapper.AddParam(DIBZ.Common.Model.Contants.DFOM_Code, offer.GameSwapperDFOM);

                        TemplatesSwapper.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs"));
                        var emailBody = TemplatesSwapper.FillTemplate(emailTemplateResponseSwapper.Body);

                        //save email data in table
                        await emailTemplateLogic.SaveEmailNotification(CurrentLoginSession.ApplicationUser.Email, emailTemplateResponseSwapper.Title, emailBody, EmailType.Email, Priority.Low);

                        EmailHelper.EmailAttachement(CurrentLoginSession.ApplicationUser.Email, emailTemplateResponseSwapper.Title, emailBody, QRCodeImagePath);
                    }

                    EmailHelper.EmailAttachement(CurrentLoginSession.ApplicationUser.Email, "Transaction From PayPal Account", SendEmailAfterTransaction(amount), string.Empty);

                    return(Json(new { IsSuccess = true }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { IsSuccess = false, fail = "Some Thing Wrong!" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception lex)
            {
                return(Json(new { IsSuccess = false, fail = lex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #9
0
        public async Task <ActionResult> AddGameIntoCollection(string gameIds, int currentPage, string searchGame, int formatId, int categoryId)
        {
            DIBZDbContext context   = new DIBZDbContext();
            var           authLogic = LogicContext.Create <AuthLogic>();

            try
            {
                var notifierEmail = (from NotifierEmails in context.NotifierEmails
                                     orderby NotifierEmails.CreatedTime descending
                                     select new
                {
                    EmailAddress = NotifierEmails.EmailAddress
                }).ToList();

                var userId             = CurrentLoginSession.ApplicationUserId.GetValueOrDefault();
                var usersFirstGameData = (from ApplicationUser in context.ApplicationUsers
                                          where ApplicationUser.Id == userId
                                          select new GameData
                {
                    GameName = ApplicationUser.GameCatalogs.FirstOrDefault().Name
                }).ToList();
                if (usersFirstGameData.First().GameName == null)
                {
                    // Get UserId, UserName, Game and Format
                    DIBZ.Common.Model.ApplicationUser user = authLogic.GetUserById(userId);
                    var nickName = user.NickName;

                    DIBZ.Common.Model.GameCatalog selectedGame = new DIBZ.Common.Model.GameCatalog();
                    var offerLogic = LogicContext.Create <OfferLogic>();
                    selectedGame = await offerLogic.GetSelectedGameById(Convert.ToInt32(gameIds));

                    var gameName   = selectedGame.Name;
                    var gameFormat = selectedGame.Format.Name;

                    if (notifierEmail.Count != 0)
                    {
                        // Email Sending to Specific Email address which is specified by DON.
                        var notifierLastEmail                       = notifierEmail.FirstOrDefault().EmailAddress;
                        EmailTemplateHelper   templates             = new EmailTemplateHelper();
                        EmailTemplateResponse emailTemplateResponse = new EmailTemplateResponse();
                        DIBZ.Common.Model.EmailNotification Email   = new DIBZ.Common.Model.EmailNotification();

                        var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();
                        emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.UserFirstGame);

                        templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, nickName);
                        templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, gameName);
                        templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, gameFormat);

                        var emailBody = templates.FillTemplate(emailTemplateResponse.Body);
                        await emailTemplateLogic.SaveEmailNotification(notifierLastEmail, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low);

                        EmailHelper.Email(notifierLastEmail, emailTemplateResponse.Title, emailBody);
                    }
                }

                authLogic.AddGameIntoCollection(userId, gameIds);
                return(RedirectToAction("MyGames", new { currentPage, searchGame, formatId, categoryId }));
            }
            catch (Exception lex)
            {
                return(Json(new { IsSuccess = false, fail = lex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #10
0
        public async Task SavePeriodictEmailNotificationsAndUpdateScoreCardAndOfferStatus()
        {
            Console.WriteLine("In SavePeriodictEmailNotificationsAndUpdateScoreCardAndOfferStatus method ....");
            LogHelper.LogInfo("In SavePeriodictEmailNotificationsAndUpdateScoreCardAndOfferStatus method ....");


            DIBZ.Common.DTO.EmailTemplateResponse emailTemplateReminder          = new Common.DTO.EmailTemplateResponse();
            DIBZ.Common.DTO.EmailTemplateResponse emailTemplatePaymentRunningOut = new Common.DTO.EmailTemplateResponse();

            try
            {
                //var emailTemplateLogic = Context.Create<EmailTemplateLogic>();

                LogicContext = new LogicContext();
                var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();

                Console.WriteLine("fetching all swaps with offer status payment needed....");
                LogHelper.LogInfo("fetching all swaps with offer status payment needed....");

                var swapsWithPaymentNeeded = await emailTemplateLogic.GetAllSwapsWithPaymentNeeded();


                Console.WriteLine("fetched payment needed email template....");
                LogHelper.LogInfo("fetched payment needed email template....");

                var scorecardLogic = LogicContext.Create <ScorecardLogic>();
                var offerLogic     = LogicContext.Create <OfferLogic>();
                foreach (var item in swapsWithPaymentNeeded)
                {
                    var timeElapsed = DateTime.Now.Subtract(DIBZ.Common.ConversionHelper.ConvertDateToTimeZone(item.CreatedTime)).TotalHours;
                    // saving for gamer offerer

                    /*if (!item.Offer.ApplicationUser.Transactions.Any(o => o.OfferId == item.OfferId)
                     *  && (timeElapsed > SystemSettings.PeriodicEmailHour && timeElapsed < (SystemSettings.PeriodicEmailHour * 3) - 12))
                     * {
                     *  EmailTemplateHelper templates = new EmailTemplateHelper();
                     *
                     *  templates.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                     *  templates.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                     *  templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.Offer.ApplicationUser.NickName);
                     *
                     *  var emailBody = templates.FillTemplate(emailTemplateReminder.Body);
                     *
                     *  Console.WriteLine("saving periodic reminder email notification for the offerer....");
                     *  LogHelper.LogInfo("saving periodic reminder email notification for the offerer....");
                     *
                     *  await emailTemplateLogic.SaveEmailNotification(item.Offer.ApplicationUser.Email, emailTemplateReminder.Title, emailBody, EmailType.Email, Priority.Medium);
                     * }
                     * else if (!item.Offer.ApplicationUser.Transactions.Any(o => o.OfferId == item.OfferId) && timeElapsed > SystemSettings.PaymentTimeInHours - 6)
                     * {
                     *  emailTemplateReminder = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.FinalPaymentReminder);
                     *  EmailTemplateHelper templates = new EmailTemplateHelper();
                     *
                     *  templates.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                     *  templates.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                     *  templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.Offer.ApplicationUser.NickName);
                     *
                     *  var emailBody = templates.FillTemplate(emailTemplateReminder.Body);
                     *
                     *  Console.WriteLine("saving final reminder email notification for the offerer....");
                     *  LogHelper.LogInfo("saving final reminder email notification for the offerer....");
                     *
                     *  await emailTemplateLogic.SaveEmailNotification(item.Offer.ApplicationUser.Email, emailTemplateReminder.Title, emailBody, EmailType.Email, Priority.High);
                     * }
                     *
                     * // saving for gamer swapper
                     * if (!item.GameSwapPserson.Transactions.Any(o => o.OfferId == item.OfferId)
                     *  && (timeElapsed > SystemSettings.PeriodicEmailHour && timeElapsed < (SystemSettings.PeriodicEmailHour * 3) - 12))
                     * {
                     *  EmailTemplateHelper templates = new EmailTemplateHelper();
                     *
                     *  templates.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                     *  templates.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                     *  templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.GameSwapPserson.NickName);
                     *
                     *  var emailBody = templates.FillTemplate(emailTemplateReminder.Body);
                     *
                     *  Console.WriteLine("saving periodic reminder email notification for the swapper....");
                     *  LogHelper.LogInfo("saving periodic reminder email notification for the swapper....");
                     *
                     *  await emailTemplateLogic.SaveEmailNotification(item.GameSwapPserson.Email, emailTemplateReminder.Title, emailBody, EmailType.Email, Priority.Medium);
                     * }
                     * else if (!item.GameSwapPserson.Transactions.Any(o => o.OfferId == item.OfferId) && timeElapsed > SystemSettings.PaymentTimeInHours - 6)
                     * {
                     *  emailTemplateReminder = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.FinalPaymentReminder);
                     *
                     *  EmailTemplateHelper templates = new EmailTemplateHelper();
                     *
                     *  templates.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                     *  templates.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                     *  templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.GameSwapPserson.NickName);
                     *
                     *  var emailBody = templates.FillTemplate(emailTemplateReminder.Body);
                     *
                     *  Console.WriteLine("saving final reminder email notification for the swapper....");
                     *  LogHelper.LogInfo("saving final reminder email notification for the swapper....");
                     *
                     *  await emailTemplateLogic.SaveEmailNotification(item.GameSwapPserson.Email, emailTemplateReminder.Title, emailBody, EmailType.Email, Priority.High);
                     *
                     * }*/


                    //Reminder email sent to the party who doesn't make the payment after 30 minutes
                    //sent to the party who has not paid
                    // saving for gamer offerer
                    if (!item.Offer.ApplicationUser.Transactions.Any(o => o.OfferId == item.OfferId) && (timeElapsed > SystemSettings.SrvcPaymentTimeInHours / 2 && timeElapsed < SystemSettings.SrvcPaymentTimeInHours))
                    {
                        emailTemplateReminder = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.FinalPaymentReminder);

                        EmailTemplateHelper templates = new EmailTemplateHelper();

                        templates.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                        templates.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                        templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.Offer.ApplicationUser.NickName);

                        var emailBody = templates.FillTemplate(emailTemplateReminder.Body);

                        Console.WriteLine("saving final reminder email notification for the offerer....");
                        LogHelper.LogInfo("saving final reminder email notification for the offerer....");

                        await emailTemplateLogic.SaveEmailNotification(item.Offer.ApplicationUser.Email, emailTemplateReminder.Title, emailBody, EmailType.Email, Priority.High);

                        EmailHelper.Email(item.Offer.ApplicationUser.Email, emailTemplateReminder.Title, emailBody);
                    }
                    // saving for gamer swapper
                    if (!item.GameSwapPserson.Transactions.Any(o => o.OfferId == item.OfferId) && (timeElapsed > SystemSettings.SrvcPaymentTimeInHours / 2 && timeElapsed < SystemSettings.SrvcPaymentTimeInHours))
                    {
                        emailTemplateReminder = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.FinalPaymentReminder);

                        EmailTemplateHelper templates = new EmailTemplateHelper();

                        templates.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                        templates.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                        templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.GameSwapPserson.NickName);

                        var emailBody = templates.FillTemplate(emailTemplateReminder.Body);

                        Console.WriteLine("saving final reminder email notification for the swapper....");
                        LogHelper.LogInfo("saving final reminder email notification for the swapper....");

                        await emailTemplateLogic.SaveEmailNotification(item.GameSwapPserson.Email, emailTemplateReminder.Title, emailBody, EmailType.Email, Priority.High);

                        EmailHelper.Email(item.GameSwapPserson.Email, emailTemplateReminder.Title, emailBody);
                    }

                    //When time has ran out : Sent to both parties in the swap
                    if (item.Offer.ApplicationUser.Transactions.Count() == 0 && timeElapsed > SystemSettings.SrvcPaymentTimeInHours)
                    {
                        await offerLogic.UpdateOfferStatusToPending(item.OfferId);

                        await scorecardLogic.UpdateScoreCardOfApplicationUserWithNoShow(item.Offer.ApplicationUserId);

                        await scorecardLogic.UpdateScoreCardOfApplicationUserWithNoShow(item.GameSwapPsersonId);

                        emailTemplatePaymentRunningOut = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.PaymentTimeRanOut);

                        // to offerer

                        EmailTemplateHelper templatesForOfferer = new EmailTemplateHelper();

                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.Offer.ApplicationUser.NickName);

                        var emailBody = templatesForOfferer.FillTemplate(emailTemplatePaymentRunningOut.Body);

                        Console.WriteLine("saving final reminder email notification for the Offerer....");
                        LogHelper.LogInfo("saving final reminder email notification for the Offerer....");

                        await emailTemplateLogic.SaveEmailNotification(item.Offer.ApplicationUser.Email, emailTemplatePaymentRunningOut.Title, emailBody, EmailType.Email, Priority.High);

                        EmailHelper.Email(item.Offer.ApplicationUser.Email, emailTemplatePaymentRunningOut.Title, emailBody);

                        // to swapper

                        EmailTemplateHelper templatesForSwapper = new EmailTemplateHelper();

                        templatesForSwapper.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                        templatesForSwapper.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                        templatesForSwapper.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.GameSwapPserson.NickName);

                        var emailBodyForSwapper = templatesForSwapper.FillTemplate(emailTemplatePaymentRunningOut.Body);

                        Console.WriteLine("saving final reminder email notification for the Offerer....");
                        LogHelper.LogInfo("saving final reminder email notification for the Offerer....");
                        await emailTemplateLogic.SaveEmailNotification(item.GameSwapPserson.Email, emailTemplatePaymentRunningOut.Title, emailBodyForSwapper, EmailType.Email, Priority.High);

                        EmailHelper.Email(item.GameSwapPserson.Email, emailTemplatePaymentRunningOut.Title, emailBodyForSwapper);
                    }
                }
                await Task.Delay((int)((SystemSettings.SrvcPaymentTimeInHours * 60) / 2) *60000);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.Message, ex);
            }
        }
예제 #11
0
        public async Task SaveExpiryDayRuleEmailNotificationsAndUpdateScoreCardAndOfferStatus()
        {
            Console.WriteLine("In SaveExpiryDayRuleEmailNotificationsAndUpdateScoreCardAndOfferStatus method ....");
            LogHelper.LogInfo("In SaveExpiryDayRuleEmailNotificationsAndUpdateScoreCardAndOfferStatus method ....");


            DIBZ.Common.DTO.EmailTemplateResponse emailTemplateExpiryDayRule = new Common.DTO.EmailTemplateResponse();

            try
            {
                //var emailTemplateLogic = Context.Create<EmailTemplateLogic>();

                LogicContext = new LogicContext();
                var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();

                Console.WriteLine("fetching all swaps with offer status payment done....");
                LogHelper.LogInfo("fetching all swaps with offer status payment done....");

                var swapsWithPaymentDone = await emailTemplateLogic.GetAllSwapsWithPaymentDone();


                Console.WriteLine("fetched expiry day rule email template....");
                LogHelper.LogInfo("fetched expiry day rule email template....");

                var scorecardLogic = LogicContext.Create <ScorecardLogic>();
                var offerLogic     = LogicContext.Create <OfferLogic>();
                var swapLogic      = LogicContext.Create <SwapLogic>();
                foreach (var item in swapsWithPaymentDone)
                {
                    emailTemplateExpiryDayRule = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.ExpiryDayRule);

                    var getWorkingDaysCount = swapLogic.GetWorkingDaysCount(ConversionHelper.ConvertDateToTimeZone(item.CreatedTime));

                    //Condition when both party hasn't sent game on time.
                    if (item.Offer.OfferStatus == OfferStatus.Accept &&
                        item.Offer.Transactions.Count() == 2 &&
                        (item.SwapStatus == SwapStatus.Payment_Done_By_Offerer || item.SwapStatus == SwapStatus.Payment_Done_By_Swapper) &&
                        getWorkingDaysCount > SystemSettings.SrvcDayRule)
                    {
                        await scorecardLogic.UpdateScoreCardOfApplicationUserWithNoShow(item.GameSwapPsersonId);

                        await scorecardLogic.UpdateScoreCardOfApplicationUserWithNoShow(item.Offer.ApplicationUserId);

                        await swapLogic.UpdateOfferStatusToPendingAndSetSwapToInActiveAndRemoveTransactionIfAny(item.OfferId, item.Id);



                        // to offerer

                        EmailTemplateHelper templatesForOfferer = new EmailTemplateHelper();

                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.Offer.ApplicationUser.NickName);
                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>link</a>", hostName + "/Dashboard/ContactUs"));

                        var emailBody = templatesForOfferer.FillTemplate(emailTemplateExpiryDayRule.Body);

                        Console.WriteLine("saving expiry dary rule email notification for the Offerer....");
                        LogHelper.LogInfo("saving expiry dary rule email notification for the Offerer....");

                        await emailTemplateLogic.SaveEmailNotification(item.Offer.ApplicationUser.Email, emailTemplateExpiryDayRule.Title, emailBody, EmailType.Email, Priority.High);

                        EmailHelper.Email(item.Offer.ApplicationUser.Email, emailTemplateExpiryDayRule.Title, emailBody);

                        // to swapper
                        EmailTemplateHelper templatesForSwapper = new EmailTemplateHelper();

                        templatesForSwapper.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                        templatesForSwapper.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                        templatesForSwapper.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.GameSwapPserson.NickName);
                        templatesForSwapper.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>link</a>", hostName + "/Dashboard/ContactUs"));

                        var emailBodyForSwapper = templatesForSwapper.FillTemplate(emailTemplateExpiryDayRule.Body);

                        Console.WriteLine("saving expiry dary rule email notification for the swapper....");
                        LogHelper.LogInfo("saving expiry dary rule email notification for the swapper....");
                        await emailTemplateLogic.SaveEmailNotification(item.GameSwapPserson.Email, emailTemplateExpiryDayRule.Title, emailBodyForSwapper, EmailType.Email, Priority.High);

                        EmailHelper.Email(item.GameSwapPserson.Email, emailTemplateExpiryDayRule.Title, emailBodyForSwapper);
                    }

                    //Condition when offerer party hasn't sent game on time.
                    if (item.Offer.OfferStatus == OfferStatus.Accept &&
                        item.Offer.Transactions.Count() == 2 &&
                        (item.SwapStatus != SwapStatus.Payment_Done_By_Offerer || item.SwapStatus != SwapStatus.Payment_Done_By_Swapper && item.SwapStatus == SwapStatus.Game2_Received) &&
                        getWorkingDaysCount > SystemSettings.SrvcDayRule)
                    {
                        await scorecardLogic.UpdateScoreCardOfApplicationUserWithNoShow(item.Offer.ApplicationUserId);

                        await swapLogic.UpdateOfferStatusToPendingAndSetSwapToInActiveAndRemoveTransactionIfAny(item.OfferId, item.Id);

                        EmailTemplateHelper templatesForOfferer = new EmailTemplateHelper();

                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.Offer.ApplicationUser.NickName);
                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>link</a>", hostName + "/Dashboard/ContactUs"));

                        var emailBody = templatesForOfferer.FillTemplate(emailTemplateExpiryDayRule.Body);

                        Console.WriteLine("saving expiry dary rule email notification for the Offerer....");
                        LogHelper.LogInfo("saving expiry dary rule email notification for the Offerer....");

                        await emailTemplateLogic.SaveEmailNotification(item.Offer.ApplicationUser.Email, emailTemplateExpiryDayRule.Title, emailBody, EmailType.Email, Priority.High);

                        EmailHelper.Email(item.Offer.ApplicationUser.Email, emailTemplateExpiryDayRule.Title, emailBody);
                    }

                    //Condition when swapper party hasn't sent game on time.
                    if (item.Offer.OfferStatus == OfferStatus.Accept &&
                        item.Offer.Transactions.Count() == 2 &&
                        (item.SwapStatus != SwapStatus.Payment_Done_By_Offerer || item.SwapStatus != SwapStatus.Payment_Done_By_Swapper && item.SwapStatus == SwapStatus.Game1_Received) &&
                        getWorkingDaysCount > SystemSettings.SrvcDayRule)
                    {
                        await scorecardLogic.UpdateScoreCardOfApplicationUserWithNoShow(item.GameSwapPsersonId);

                        await swapLogic.UpdateOfferStatusToPendingAndSetSwapToInActiveAndRemoveTransactionIfAny(item.OfferId, item.Id);

                        EmailTemplateHelper templatesForOfferer = new EmailTemplateHelper();

                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.OfferedGame, item.Offer.GameCatalog.Name);
                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.SwappedGame, item.GameSwapWith.Name);
                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, item.GameSwapPserson.NickName);
                        templatesForOfferer.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>link</a>", hostName + "/Dashboard/ContactUs"));

                        var emailBody = templatesForOfferer.FillTemplate(emailTemplateExpiryDayRule.Body);

                        Console.WriteLine("saving expiry dary rule email notification for the Offerer....");
                        LogHelper.LogInfo("saving expiry dary rule email notification for the Offerer....");

                        await emailTemplateLogic.SaveEmailNotification(item.GameSwapPserson.Email, emailTemplateExpiryDayRule.Title, emailBody, EmailType.Email, Priority.High);

                        EmailHelper.Email(item.GameSwapPserson.Email, emailTemplateExpiryDayRule.Title, emailBody);
                    }
                }

                await Task.Delay(SystemSettings.SrvcDayRuleRunningTimeInMS);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex.Message, ex);
            }
        }
        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));
            }
        }
예제 #13
0
        public async Task <ActionResult> DeleteCounterOffer(int id)
        {
            var counterOfferLogic  = LogicContext.Create <CounterOfferLogic>();
            var counterOfferDetail = await counterOfferLogic.GetCounterOfferById(id);


            var authLogic          = LogicContext.Create <AuthLogic>();
            var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();

            //DIBZ.Common.Model.ApplicationUser applicationUser = new DIBZ.Common.Model.ApplicationUser();

            //get ApplicationUser detail by appUserId
            //applicationUser = await authLogic.GetApplicationUserById(Convert.ToInt16(CurrentLoginSession.ApplicationUserId));

            DIBZ.Common.DTO.NotificationModel   notificationModel = new DIBZ.Common.DTO.NotificationModel();
            DIBZ.Common.Model.Notification      notification      = new DIBZ.Common.Model.Notification();
            DIBZ.Common.Model.EmailTemplate     emailTemplate     = new DIBZ.Common.Model.EmailTemplate();
            DIBZ.Common.Model.EmailNotification email             = new DIBZ.Common.Model.EmailNotification();
            EmailTemplateHelper   templates             = new EmailTemplateHelper();
            EmailTemplateResponse emailTemplateResponse = new EmailTemplateResponse();
            var notificationLogic = LogicContext.Create <NotificationLogic>();

            notificationModel.AppUserId   = counterOfferDetail.CounterOfferPersonId;
            notificationModel.Channel     = Convert.ToInt32(DIBZ.Common.Model.Channel.Web);
            notificationModel.Content     = counterOfferDetail.Offer.ApplicationUser.NickName + " has declined your offer for <b>" + counterOfferDetail.Offer.GameCatalog.Name + "</b>";//applicationUser.NickName + " has declide your offer you made for <b>" + offerDetail.GameCatalog.Name + "</b>";
            notificationModel.CreatedTime = DateTime.Now;
            notificationModel.IsActive    = true;
            notificationModel.IsDeleted   = false;
            notificationModel.LastError   = "";
            notificationModel.NotificationBusinessType = Convert.ToInt32(DIBZ.Common.Model.NotificationBusinessType.CounterOffer);
            notificationModel.NotificationType         = Convert.ToInt32(DIBZ.Common.Model.NotificationType.Desktop);
            notificationModel.OfferId = counterOfferDetail.OfferId;
            notificationModel.Status  = Convert.ToInt32(DIBZ.Common.Model.NotificationStatus.Unseen);
            notificationModel.Title   = "Counter Offer";

            //save notification in notification table
            // save additional data in the form of json string in notification table
            var additionalData = new { GameCatalogId = counterOfferDetail.Offer.GameCatalogId, GameCatalogImageId = counterOfferDetail.Offer.GameCatalog.GameImageId, ReturnGameCatalogId = counterOfferDetail.Offer.ReturnGameCatalogId.Value, CounterOfferId = id };

            notificationModel.AdditionalData = Helpers.GetJson(additionalData);
            notification = await notificationLogic.AddNotification(notificationModel);

            //sent notification to offer creater
            new DIBZ.Services.ServerNotificationService().CounterOffer(counterOfferDetail.CounterOfferPersonId, notification.Id, notificationModel.Content, notificationModel.CreatedTime, notificationModel.AdditionalData);

            //create email template
            emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.DeclineOffer);

            templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, counterOfferDetail.Offer.ApplicationUser.NickName);
            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(counterOfferDetail.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low);

            EmailHelper.Email(counterOfferDetail.Offer.ApplicationUser.Email, emailTemplateResponse.Title, emailBody);

            // and as well as, email sent to him
            EmailTemplateHelper templateForCounterOfferPerson = new EmailTemplateHelper();

            templateForCounterOfferPerson.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, counterOfferDetail.CounterOfferPerson.NickName);
            templateForCounterOfferPerson.AddParam(DIBZ.Common.Model.Contants.UrlContactUs, string.Format("<a href='{0}'>here</a>", hostName + "/Dashboard/ContactUs"));
            emailBody = templateForCounterOfferPerson.FillTemplate(emailTemplateResponse.Body);
            await emailTemplateLogic.SaveEmailNotification(counterOfferDetail.CounterOfferPerson.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low);

            EmailHelper.Email(counterOfferDetail.CounterOfferPerson.Email, emailTemplateResponse.Title, emailBody);

            //  add game into the collection again to the counter person.
            var gameLogic = LogicContext.Create <GameCatalogLogic>();
            await gameLogic.AddGameIntoCollection(counterOfferDetail.CounterOfferPersonId, counterOfferDetail.GameCounterOfferWithId);

            // Deleting counter offer.
            await counterOfferLogic.Delete(id);

            return(RedirectToAction("PossibleSwaps", "Offer"));
        }
예제 #14
0
        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"));
        }
예제 #15
0
        public async Task <ActionResult> AddCounterOffer(DIBZ.Common.Model.Offer offer, string gameInReturn)
        {
            //Variables declarations
            var    notificationLogic  = LogicContext.Create <NotificationLogic>();
            var    offerLogic         = LogicContext.Create <OfferLogic>();
            var    authLogic          = LogicContext.Create <AuthLogic>();
            var    counterOfferLogic  = LogicContext.Create <CounterOfferLogic>();
            var    emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();
            string returnGameCatalogId;

            DIBZ.Common.Model.Offer           offerDetail       = new DIBZ.Common.Model.Offer();
            DIBZ.Common.Model.ApplicationUser applicationUser   = new DIBZ.Common.Model.ApplicationUser();
            DIBZ.Common.DTO.NotificationModel notificationModel = new DIBZ.Common.DTO.NotificationModel();
            DIBZ.Common.Model.Notification    notification      = new DIBZ.Common.Model.Notification();
            DIBZ.Common.Model.CounterOffer    counterOffer      = new DIBZ.Common.Model.CounterOffer();
            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();

            //get offer by offerId
            offerDetail = await offerLogic.GetOfferById(offer.Id);

            //get ApplicationUser detail by appUserId
            applicationUser = await authLogic.GetApplicationUserById(Convert.ToInt16(CurrentLoginSession.ApplicationUserId));

            if (gameInReturn != null)
            {
                returnGameCatalogId = gameInReturn;
            }
            else
            {
                returnGameCatalogId = offer.ReturnGameCatalogId.ToString();
            }

            notificationModel.AppUserId   = offerDetail.ApplicationUserId;
            notificationModel.Channel     = Convert.ToInt32(DIBZ.Common.Model.Channel.Web);
            notificationModel.Content     = applicationUser.NickName + " is interested in <b>" + offer.GameCatalog.Name + "</b>";
            notificationModel.CreatedTime = DateTime.Now;
            notificationModel.IsActive    = true;
            notificationModel.IsDeleted   = false;
            notificationModel.LastError   = "";
            notificationModel.NotificationBusinessType = Convert.ToInt32(DIBZ.Common.Model.NotificationBusinessType.CounterOffer);
            notificationModel.NotificationType         = Convert.ToInt32(DIBZ.Common.Model.NotificationType.Desktop);
            notificationModel.OfferId = offer.Id;
            notificationModel.Status  = Convert.ToInt32(DIBZ.Common.Model.NotificationStatus.Unseen);
            notificationModel.Title   = "Counter Offer";

            //save counteroffer data in counteroffer table
            int gameCounterOfferId = ConversionHelper.SafeConvertToInt32(returnGameCatalogId);

            counterOffer = await counterOfferLogic.AddCounterOffer(offer.Id, gameCounterOfferId, Convert.ToInt16(CurrentLoginSession.ApplicationUser.Id));

            //save notification in notification table
            // save additional data in the form of json string in notification table
            var additionalData = new { GameCatalogId = offer.GameCatalogId, GameCatalogImageId = offerDetail.GameCatalog.GameImageId, ReturnGameCatalogId = returnGameCatalogId, CounterOfferId = counterOffer.Id };

            notificationModel.AdditionalData = Helpers.GetJson(additionalData);
            notification = await notificationLogic.AddNotification(notificationModel);

            //sent notification to offer creater
            new DIBZ.Services.ServerNotificationService().CounterOffer(offerDetail.ApplicationUserId, notification.Id, notificationModel.Content, notificationModel.CreatedTime, notificationModel.AdditionalData);

            //create email template
            emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.AddInterest);

            templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, offerDetail.ApplicationUser.NickName);
            templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName_Swapper, applicationUser.NickName);

            templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, offerDetail.GameCatalog.Name);
            templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, offerDetail.ReturnGameCatalog.Name);

            templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, offerDetail.GameCatalog.Format.Name);
            templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, offerDetail.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"));
            var emailBody = templates.FillTemplate(emailTemplateResponse.Body);

            //save email data in table
            await emailTemplateLogic.SaveEmailNotification(offerDetail.ApplicationUser.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low);

            EmailHelper.Email(offerDetail.ApplicationUser.Email, emailTemplateResponse.Title, emailBody);

            // and as well as, email sent to him
            //EmailHelper.Email(applicationUser.Email, emailTemplateResponse.Title, emailBody);
            return(RedirectToAction("Index", "Dashboard"));
        }
예제 #16
0
        /*[HttpGet]
         * [AuthOp(LoggedInUserOnly = true)]
         * [OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")]
         * public async Task<ActionResult> AddCounterOffer(int id)
         * {
         *  //this code is use when we get notificationid
         *
         *  //var notificationLogic = LogicContext.Create<NotificationLogic>();
         *  //var OfferLogic = LogicContext.Create<OfferLogic>();
         *  //DIBZ.Common.Model.Notification notification = new DIBZ.Common.Model.Notification();
         *  //DIBZ.Common.DTO.CounterOffer counterOffer = new DIBZ.Common.DTO.CounterOffer();
         *
         *  //DIBZ.Common.DTO.NotificationAdditionalData notificationAdditionalData = new DIBZ.Common.DTO.NotificationAdditionalData();
         *  //notification =  await notificationLogic.GetNotificationById(notificationId);
         *
         *  //if (notification != null)
         *  //{
         *  //    notificationAdditionalData = JsonConvert.DeserializeObject<DIBZ.Common.DTO.NotificationAdditionalData>(notification.AdditionalData);
         *  //    //await OfferLogic.GetOfferById(notificationAdditionalData.OfferId);
         *  //    counterOffer.GameCatalogId = notificationAdditionalData.GameCatalogId;
         *  //    counterOffer.ReturnGameCatalogId = notificationAdditionalData.ReturnGameCatalogId;
         *  //    counterOffer.Description = notificationAdditionalData.Description;
         *  //    counterOffer.OfferId = notification.OfferId;
         *  //    return View(counterOffer);
         *  //}
         *  //return View("Edit", notification);
         *
         *
         *  var offerLogic = LogicContext.Create<OfferLogic>();
         *  var gameCatalogLogic = LogicContext.Create<GameCatalogLogic>();
         *  ViewBag.MyGames = await gameCatalogLogic.GetAllGamesOfApplicationUser(CurrentLoginSession.ApplicationUserId.GetValueOrDefault());
         *  DIBZ.Common.Model.CounterOffer counterOffer = new DIBZ.Common.Model.CounterOffer();
         *  DIBZ.Common.Model.Offer offer = new DIBZ.Common.Model.Offer();
         *  offer = await offerLogic.GetOfferById(id);
         *
         *  if (offer != null)
         *  {
         *      return View(offer);
         *  }
         *  return View(offer);
         * }*/

        //[HttpGet]
        ////[AuthOp(LoggedInUserOnly = true)]
        //[OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")]
        public async Task <ActionResult> AddCounterOffer(int id)
        {
            try
            {
                //Variables declarations
                var notificationLogic  = LogicContext.Create <NotificationLogic>();
                var offerLogic         = LogicContext.Create <OfferLogic>();
                var authLogic          = LogicContext.Create <AuthLogic>();
                var counterOfferLogic  = LogicContext.Create <CounterOfferLogic>();
                var emailTemplateLogic = LogicContext.Create <EmailTemplateLogic>();

                DIBZ.Common.Model.Offer           offerDetail       = new DIBZ.Common.Model.Offer();
                DIBZ.Common.Model.ApplicationUser applicationUser   = new DIBZ.Common.Model.ApplicationUser();
                DIBZ.Common.DTO.NotificationModel notificationModel = new DIBZ.Common.DTO.NotificationModel();
                DIBZ.Common.Model.Notification    notification      = new DIBZ.Common.Model.Notification();
                DIBZ.Common.Model.CounterOffer    counterOffer      = new DIBZ.Common.Model.CounterOffer();
                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();

                //get offer by offerId
                offerDetail = await offerLogic.GetOfferById(id);

                //get ApplicationUser detail by appUserId
                applicationUser = await authLogic.GetApplicationUserById(Convert.ToInt16(CurrentLoginSession.ApplicationUserId));

                notificationModel.AppUserId   = offerDetail.ApplicationUserId;
                notificationModel.Channel     = Convert.ToInt32(DIBZ.Common.Model.Channel.Web);
                notificationModel.Content     = applicationUser.NickName + " is interested in <b>" + offerDetail.GameCatalog.Name + "</b>";
                notificationModel.CreatedTime = DateTime.Now;
                notificationModel.IsActive    = true;
                notificationModel.IsDeleted   = false;
                notificationModel.LastError   = "";
                notificationModel.NotificationBusinessType = Convert.ToInt32(DIBZ.Common.Model.NotificationBusinessType.CounterOffer);
                notificationModel.NotificationType         = Convert.ToInt32(DIBZ.Common.Model.NotificationType.Desktop);
                notificationModel.OfferId = offerDetail.Id;
                notificationModel.Status  = Convert.ToInt32(DIBZ.Common.Model.NotificationStatus.Unseen);
                notificationModel.Title   = "Counter Offer";

                //save counteroffer data in counteroffer table
                if (offerDetail.ReturnGameCatalogId == null)
                {
                    throw new Exception("Counter Offer cannot be created without game sought in return.");
                }
                int gameCounterOfferId = offerDetail.ReturnGameCatalogId.Value;

                //getting the list of games that counter person have
                var gameCatalogLogic = LogicContext.Create <GameCatalogLogic>();
                var myGames          = (await gameCatalogLogic.GetAllGamesOfApplicationUser(CurrentLoginSession.ApplicationUser.Id)).Where(o => o.IsValidForOffer).Select(o => o.GameId).ToList();
                if (!myGames.Contains(offerDetail.ReturnGameCatalogId.Value))
                {
                    throw new Exception("You do not possess the game sought in return.");
                }

                counterOffer = await counterOfferLogic.AddCounterOffer(offerDetail.Id, gameCounterOfferId, CurrentLoginSession.ApplicationUser.Id);

                //save notification in notification table
                // save additional data in the form of json string in notification table
                var additionalData = new { GameCatalogId = offerDetail.GameCatalogId, GameCatalogImageId = offerDetail.GameCatalog.GameImageId, ReturnGameCatalogId = offerDetail.ReturnGameCatalogId.Value, CounterOfferId = counterOffer.Id };
                notificationModel.AdditionalData = Helpers.GetJson(additionalData);
                notification = await notificationLogic.AddNotification(notificationModel);

                //sent notification to offer creater
                new DIBZ.Services.ServerNotificationService().CounterOffer(offerDetail.ApplicationUserId, notification.Id, notificationModel.Content, notificationModel.CreatedTime, notificationModel.AdditionalData);

                //Deleting all the offers of counter offer game.
                await offerLogic.GetAllOfferByGameAndApplicationUser(applicationUser.Id, gameCounterOfferId);

                // Deleting game of Counter person.
                var gameLogic = LogicContext.Create <GameCatalogLogic>();
                await gameLogic.RemoveGameFromCollection(CurrentLoginSession.ApplicationUser.Id, gameCounterOfferId);

                //create email template
                emailTemplateResponse = await emailTemplateLogic.GetEmailTemplate(EmailType.Email, EmailContentType.AddInterest);

                templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName, offerDetail.ApplicationUser.NickName);
                templates.AddParam(DIBZ.Common.Model.Contants.AppUserNickName_Swapper, applicationUser.NickName);

                templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name, offerDetail.GameCatalog.Name);
                templates.AddParam(DIBZ.Common.Model.Contants.GameCatalog_Name_Swapper, offerDetail.ReturnGameCatalog.Name);

                templates.AddParam(DIBZ.Common.Model.Contants.GameFormat, offerDetail.GameCatalog.Format.Name);
                templates.AddParam(DIBZ.Common.Model.Contants.GameFormatSwapper, offerDetail.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"));
                var emailBody = templates.FillTemplate(emailTemplateResponse.Body);

                //save email data in table
                await emailTemplateLogic.SaveEmailNotification(offerDetail.ApplicationUser.Email, emailTemplateResponse.Title, emailBody, EmailType.Email, Priority.Low);

                EmailHelper.Email(offerDetail.ApplicationUser.Email, emailTemplateResponse.Title, emailBody);

                // and as well as, email sent to him
                //EmailHelper.Email(applicationUser.Email,emailTemplateResponse.Title, emailBody);
                return(RedirectToAction("PossibleSwaps", "Offer"));
            }
            catch (Exception ex)
            {
                TempData["Error"] = ex.Message;//"Counter Offer cannot be created without game sought in return. ";
                //return RedirectToAction("ViewAllOffers", "Dashboard");
                return(Redirect(Request.UrlReferrer.ToString()));
            }
        }