Esempio n. 1
0
        private async Task <bool> SendOTPEmailAsync(OTPTracker person)
        {
            try
            {
                var builder = new BodyBuilder();

                var emailMessage = new MailObj();
                emailMessage.toAddresses   = new List <ToAddress>();
                emailMessage.subject       = "OTP Verification";
                emailMessage.content       = person.OTP.Insert(2, "-").Insert(5, "-");
                emailMessage.sendIt        = true;
                emailMessage.fromAddresses = new List <FromAddress>();
                emailMessage.toAddresses.Add(new ToAddress {
                    address = person.Email
                });
                emailMessage.template = 5;
                await _identityServer.SendMail(emailMessage);

                return(await Task.Run(() => true));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.ToString());
                return(true);
            }
        }
Esempio n. 2
0
File: Test.cs Progetto: wpmyj/OF2.0
        //public void todo()
        //{
        //    MAIL mtd = new MAIL();

        //    for (int i = 0; i < 5; i++)
        //    {

        //        MAIL.MailObj mail = getmail();
        //        mail.Subject = "Normal" + i.ToString();
        //        mtd.fillqueue(mail, 1);
        //    }
        //    for (int i = 0; i < 5; i++)
        //    {
        //        MAIL.MailObj mail = getmail();
        //        mail.Subject = "High" + i.ToString();
        //        mtd.fillqueue(mail, 2);
        //    }
        //}
        private static MailObj getmail()
        {
            MailObj mail = new MailObj();

            mail.From = "*****@*****.**";
            mail.CC.Add("*****@*****.**");
            mail.CC.Add("*****@*****.**");
            mail.To.Add("*****@*****.**");
            mail.Subject = "normal";
            mail.Body    = "hhhu";
            return(mail);
        }
            private async Task RecoveryMail(string email, string token)
            {
                var path = $"{_uRIs.MainClient}#/auth/change/password?email={email}&token={token}";
                var sm   = new MailObj();

                sm.subject       = $"Account Recovery";
                sm.content       = $"Please click <a href='{path}'> here </a> to change password";
                sm.sendIt        = true;
                sm.saveIt        = true;
                sm.template      = (int)EmailTemplate.LoginDetails;
                sm.toAddresses   = new List <ToAddress>();
                sm.fromAddresses = new List <FromAddress>();
                sm.toAddresses.Add(new ToAddress {
                    address = email, name = email
                });
                await _identityServer.SendMail(sm);
            }
Esempio n. 4
0
            private async Task RecoveryMail(string email)
            {
                var path = $"{_uRIs.MainClient}#/auth/login";
                var sm   = new MailObj();

                sm.subject       = $"Account Recovery";
                sm.content       = $"Account recovery was successful. <br> click <a href='{path}'> here </a> to login into your account";
                sm.sendIt        = true;
                sm.saveIt        = true;
                sm.template      = (int)EmailTemplate.LoginDetails;
                sm.toAddresses   = new List <ToAddress>();
                sm.fromAddresses = new List <FromAddress>();
                sm.toAddresses.Add(new ToAddress {
                    address = email, name = email
                });
                await _identityServer.SendMail(sm);
            }
        public int sendnotification(BookingStatus bookingStatus, string BN, string Sid, string Status, string message, MailObj mail)
        {
            HotelBookingDAl hotelBooking = new HotelBookingDAl();
            var             Bookingdata  = hotelBooking.ChangeBookingstatusAndGetNotificationData(bookingStatus, BN, Sid, mail);

            if (Bookingdata?.Sales_Channel?.ToLower() != "direct")
            {
                //Direct
                NotificationData notificationData = new NotificationData();
                notificationData.BookingNumber      = BN;
                notificationData.ConfirmationStatus = Status;
                notificationData.Language           = "en";
                notificationData.Message            = message;
                notificationData.NotificationToken  = Bookingdata?.NotificationKey;

                notificationData.PDFURL = mail.confirmationPDF;
                notificationData.SId    = bookingStatus.Sid;
                notificationData.Type   = "hotel";
                NotificationHelper.SendPushNotification(notificationData);
                return(10);
            }
            return(11);
        }
        public IHttpActionResult HotelsConformation(string sid, string bookingNum, string tok)
        {
            ValidatingPaymentModel validating;

            validating = null;
            NotificationCls notification = new NotificationCls();
            BookingStatus   value = new BookingStatus();
            MailObj         mailVal = new MailObj();
            string          Notstatus = ""; string Mess = "";

            //[FromBody] BookingStatus value
            try
            {
                HotelBookingCls hotelBooking = new HotelBookingCls();
                value.BookingNum = bookingNum;
                value.Sid        = sid;
                value.Status     = "";
                LoggingHelper.WriteToFile("SaveBookingConfirmationController/ConfirmHotelStatusapi/", "ConfirmedstatusController" + "INController" + value.Sid, "InComingData", "sid" + value.Sid + " , BookingNum" + value.BookingNum);
                // call payment Transaction
                var payResult = Pay.GetPaymentTransactionAsync(tok, bookingNum, sid).Result;
                if (payResult != null)
                {
                    if (payResult.HGResponseCode == "100" || payResult.HGResponseCode == "000")
                    {
                        validating   = new ValidatingPaymentModel();
                        value.Status = payResult.FraudStatus;
                        if (payResult.FraudStatus.ToLower() == "approved")
                        {
                            hotelBooking.addBookingStatus("Payment Done", bookingNum);
                            validating.Status = 0;
                        }
                        else if (payResult.FraudStatus.ToLower() == "refused")
                        {
                            hotelBooking.addBookingStatus("Payment Refused", bookingNum);
                            validating.Status = 2;
                        }
                        else if (payResult.FraudStatus.ToLower() == "suspected")
                        {
                            hotelBooking.addBookingStatus("Payment Suspected", bookingNum);
                            validating.Status = 2;
                        }
                    }
                    else
                    {
                        hotelBooking.addBookingStatus("Payment Failed", bookingNum);
                        validating        = new ValidatingPaymentModel();
                        validating.Status = 1;
                        Mess = "Some thing wrong Please Search again";

                        notification.sendnotification(value, bookingNum, validating.Status.ToString(), sid, Mess, mailVal);
                        return(Ok(validating));
                    }
                    // add status
                    if (validating.Status == 0)
                    {
                        var Confirm = ConfirmationBooking.GetConfirmationBooking(sid, bookingNum);
                        // if(Confirm)
                        if (Confirm.status == 0)
                        {
                            validating.Status = 0;
                            value.Status      = "Booking Confirmed";
                            hotelBooking.addBookingStatus("Booking Confirmed", bookingNum);
                            ConfirmationBLL confirmation = new ConfirmationBLL();
                            var             data         = confirmation.GetConfirmationData(sid, bookingNum);
                            LoggingHelper.WriteToFile("SendMailobject/", "INController" + value.Sid, "InComingData", JsonConvert.SerializeObject(data));

                            MailCLS mail = new MailCLS();
                            mailVal = mail.SendMail(data).Result;
                        }
                        else if (Confirm.status == 1)
                        {
                            validating.Status = 2;
                            value.Status      = "Missing";
                            hotelBooking.addBookingStatus("Missing", bookingNum);
                            Mess = "Some thing wrong Please Call Our Call Center";
                        }
                        else if (Confirm.status == 2)
                        {
                            validating.Status = 2;
                            value.Status      = "Booking Not Confirmed";
                            hotelBooking.addBookingStatus("Booking Not Confirmed", bookingNum);
                            Mess = "Some thing wrong Please Call Our Call Center";
                        }
                        else if (Confirm.status == 3)
                        {
                            validating.Status = 0;
                            value.Status      = "Booking Confirmed";
                        }
                        // var result = hotelBooking.ChangeBookingstatus(value);

                        notification.sendnotification(value, bookingNum, sid, validating.Status.ToString(), Mess, mailVal);
                        //validating.Status = 0;
                        return(Ok(validating));
                    }
                    Mess = "Some thing wrong Please Search again";
                    notification.sendnotification(value, bookingNum, validating.Status.ToString(), sid, Mess, mailVal);

                    return(Ok(validating));
                }
                validating.Status = 1;
                Mess = "Some thing wrong Please Search again";

                notification.sendnotification(value, bookingNum, validating.Status.ToString(), sid, Mess, mailVal);

                return(Ok(validating));
            }
            catch (Exception ex)
            {
                LoggingHelper.WriteToFile("SaveBookingConfirmationController/Errors/", "ConfirmedStautsController" + "INController" + value.Sid, ex.InnerException?.Message, ex.Message + ex.StackTrace);
                if (validating == null)
                {
                    Mess = "Some thing wrong Please Search again";
                    notification.sendnotification(value, bookingNum, "3", sid, Mess, mailVal);

                    return(BadRequest(ex.Message));
                }
                else
                {
                    if (validating.Status == 1)
                    {
                        Mess = "Some thing wrong Please Search again";

                        notification.sendnotification(value, bookingNum, validating.Status.ToString(), sid, Mess, mailVal);
                        return(Ok(validating));
                    }
                    validating.Status = 2;
                    Mess = "Some thing wrong Please call our Call center";

                    notification.sendnotification(value, bookingNum, validating.Status.ToString(), sid, Mess, mailVal);
                    return(Ok(validating));
                }
            }
        }
Esempio n. 7
0
        public bool PostEmail(MailObj id)
        {
            UserManager userManager = new UserManager();

            return(userManager.ContanctUs(id));
        }
Esempio n. 8
0
        public async Task <AuthenticationResult> CustomerRegisterAsync(CustomUserRegistrationReqObj userRegistration)
        {
            try
            {
                var accountNumber = GeneralHelpers.GenerateRandomDigitCode(10);
                var existingUser  = await _userManager.FindByEmailAsync(userRegistration.Email);

                if (existingUser != null)
                {
                    return(new AuthenticationResult
                    {
                        Status = new APIResponseStatus
                        {
                            IsSuccessful = false,
                            Message = new APIResponseMessage
                            {
                                FriendlyMessage = "User with this email address already exist"
                            }
                        }
                    });
                }


                var user = new ApplicationUser
                {
                    Email            = userRegistration.Email,
                    UserName         = userRegistration.Email,
                    PhoneNumber      = userRegistration.PhoneNo,
                    FirstName        = userRegistration.FirstName,
                    LastName         = userRegistration.LastName,
                    Address          = userRegistration.Address,
                    CustomerTypeId   = userRegistration.CustomerTypeId,
                    ApprovalStatusId = 1,
                    SecurityAnswered = userRegistration.SecurityAnswered,
                    QuestionId       = userRegistration.QuestionId
                };

                var createdUser = await _userManager.CreateAsync(user, userRegistration.Password);

                var customer = new credit_loancustomer
                {
                    Email              = userRegistration.Email,
                    UserIdentity       = user.Id,
                    PhoneNo            = userRegistration.PhoneNo,
                    FirstName          = userRegistration.FirstName,
                    LastName           = userRegistration.LastName,
                    Address            = userRegistration.Address,
                    CustomerTypeId     = userRegistration.CustomerTypeId,
                    CASAAccountNumber  = accountNumber,
                    ApprovalStatusId   = 1,
                    ProfileStatus      = 0,
                    Active             = true,
                    Deleted            = false,
                    CreatedBy          = user.Email,
                    CreatedOn          = DateTime.Now,
                    RegistrationSource = "Website"
                };
                _dataContext.credit_loancustomer.Add(customer);
                _dataContext.SaveChanges();

                if (!createdUser.Succeeded)
                {
                    return(new AuthenticationResult
                    {
                        Status = new APIResponseStatus
                        {
                            IsSuccessful = false,
                            Message = new APIResponseMessage
                            {
                                FriendlyMessage = createdUser.Errors.Select(x => x.Description).FirstOrDefault(),
                            }
                        }
                    });
                }

                var custCode   = ConfirmationCode.Generate();
                var successful = await CustomerSendAndStoreConfirmationCode(custCode, user.Email);

                var accountId = user.Id;
                var name      = user.FirstName;
                var baseUrl   = _configuration.GetValue <string>("FrontEndUrl:webUrl");

                var url      = baseUrl + "/#/auth/activate-account/" + accountId + "";
                var content1 = "Welcome to GOS Credit! There's just one step before you get to complete your customer account registration. Verify you have the right email address by clicking on the button below.";
                var content2 = "Once your account creation is completed, your can explore our services and have a seamless experience.";
                var body     = GeneralHelpers.MailBody(name, url, content1, content2);

                var addresses = new ToAddress
                {
                    name    = user.FirstName + " " + user.LastName,
                    address = user.Email
                };
                var addressList = new List <ToAddress> {
                    addresses
                };
                var mailObj = new MailObj
                {
                    subject       = "Email Verification",
                    content       = body,
                    toAddresses   = addressList,
                    fromAddresses = new List <FromAddress> {
                    },
                    sendIt        = true,
                    saveIt        = false
                };

                var res = _identityServer.SendMail(mailObj);

                return(new AuthenticationResult
                {
                    Status = new APIResponseStatus
                    {
                        IsSuccessful = true,
                        CustomToken = custCode,
                    }
                });
            }
            catch (Exception ex)
            {
                #region Log error
                var errorCode = ErrorID.Generate(4);
                _logger.Error($"ErrorID :  {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                return(new AuthenticationResult
                {
                    Status = new APIResponseStatus
                    {
                        Message = new APIResponseMessage
                        {
                            FriendlyMessage = "Error occured!! Please try again later",
                            MessageId = errorCode,
                            TechnicalMessage = $"ErrorID :  {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}"
                        }
                    }
                });

                #endregion
            }
        }
Esempio n. 9
0
        public HotelsBooking ChangeBookingstatusAndGetNotificationData(BookingStatus bookingStatus, string BN, string Sid, MailObj mail)
        {
            HotelBookingDBEntities db = new HotelBookingDBEntities();
            var BookingData           = db.HotelsBookings.FirstOrDefault(x => x.Booking_No == bookingStatus.BookingNum && x.SessionId == bookingStatus.Sid);

            BookingData.Booking_Status = bookingStatus.Status;
            BookingData.voucherPdf     = mail.confirmationPDF;
            BookingData.InvoicePdf     = mail.salesInvoicePDF;
            db.SaveChanges();
            return(BookingData);
        }
Esempio n. 10
0
 public HotelsBooking ChangeBookingstatusAndSendNotification(BookingStatus bookingStatus, string BN, string Sid, MailObj mail)
 {
     throw new NotImplementedException();
 }