Exemplo n.º 1
0
        private void InsertUpdateDataAndSendMail(UserTransaction usertransaction, SupportDetail supportdetail, IEmailQueueService _emailservice)
        {
            supportdetail.SupportRequest.OrderDetail.OrderStatusID = (int)OrderStatus.REFUNDED;

            var _usertransaction = DependencyResolver.Current.GetService <IRepository <UserTransaction> >();

            usertransaction.AuditDetails      = new Audit();
            usertransaction.AuditDetails      = supportdetail.AuditDetails;
            usertransaction.OrderDetail       = supportdetail.SupportRequest.OrderDetail;
            usertransaction.OrderDetailID     = supportdetail.SupportRequest.OrderDetail.ID;
            usertransaction.RefundRequest     = supportdetail.SupportRequest;
            usertransaction.RefundRequestID   = supportdetail.SupportRequest.ID;
            usertransaction.SiteID            = Site.ID;
            usertransaction.TransactionModeID = (int)TransactionMode.REFUND;
            usertransaction.UserID            = supportdetail.SupportRequest.UserID;

            _usertransaction.Add(usertransaction);
            _service.Add(supportdetail);
            _unitOfWork.Commit();


            usertransaction.OrderDetail.InvoiceNumber = InvoicePrefix + usertransaction.OrderDetail.OrderID;

            if (usertransaction.User.UserType == UserType.RESELLER)
            {
                _emailservice.PrepareEmailQueue(Site.ID, LangID, EmailType.RESELLER_REFUND_NOTIFICATION, SMTPID, usertransaction.User.Email, usertransaction);
            }
            else
            {
                _emailservice.PrepareEmailQueue(Site.ID, LangID, EmailType.CUSTOMER_REFUND_NOTIFICATION, SMTPID, usertransaction.User.Email, usertransaction);
            }

            _emailservice.PrepareEmailQueue(Site.ID, LangID, EmailType.ADMIN_REFUND_NOTIFICATION, SMTPID, SiteAdminEmail, supportdetail);
            _unitOfWork.Commit();
        }
Exemplo n.º 2
0
        public bool SaveReseller(ResellerContract resellercontract, int LangID, int SMTPID)
        {
            bool bIsNewCust = false, bResellerActivation = false;

            if (resellercontract.Reseller.ID > 0)
            {
                WBSSLStore.Domain.ResellerContract newrc = _resellercontract.Find(c => c.Reseller.ID == resellercontract.Reseller.ID && c.Reseller.SiteID == resellercontract.SiteID).EagerLoad(c => c.Reseller, c => c.Contract).FirstOrDefault();

                newrc.ContractID                 = resellercontract.ContractID;
                newrc.Reseller.CompanyName       = resellercontract.Reseller.CompanyName;
                newrc.Reseller.FirstName         = resellercontract.Reseller.FirstName;
                newrc.Reseller.LastName          = resellercontract.Reseller.LastName;
                newrc.Reseller.Email             = resellercontract.Reseller.Email;
                newrc.Reseller.AlternativeEmail  = resellercontract.Reseller.AlternativeEmail;
                newrc.Reseller.Address.Street    = resellercontract.Reseller.Address.Street;
                newrc.Reseller.Address.City      = resellercontract.Reseller.Address.City;
                newrc.Reseller.Address.State     = resellercontract.Reseller.Address.State;
                newrc.Reseller.Address.Zip       = resellercontract.Reseller.Address.Zip;
                newrc.Reseller.Address.CountryID = resellercontract.Reseller.Address.CountryID;
                newrc.Reseller.Address.Phone     = resellercontract.Reseller.Address.Phone;
                newrc.Reseller.Address.Fax       = resellercontract.Reseller.Address.Fax;
                newrc.Reseller.Address.Mobile    = resellercontract.Reseller.Address.Mobile;
                newrc.Reseller.HeardBy           = resellercontract.Reseller.HeardBy;
                newrc.Reseller.ConfirmPassword   = newrc.Reseller.PasswordHash;

                if (newrc.Reseller.RecordStatusID == (int)RecordStatus.INACTIVE && resellercontract.Reseller.RecordStatusID == (int)RecordStatus.ACTIVE)
                {
                    bResellerActivation           = true;
                    newrc.Reseller.RecordStatusID = resellercontract.Reseller.RecordStatusID;
                }
                //_useroptions.Add()
                _resellercontract.Update(newrc);
            }
            else
            {
                resellercontract.Reseller.AuditDetails.DateCreated = DateTimeWithZone.Now;
                _resellercontract.Add(resellercontract);
                bIsNewCust = true;
            }
            _unitOfWork.Commit();

            if (bIsNewCust) //Send customer welcome email
            {
                _EmailQueueService.PrepareEmailQueue(resellercontract.SiteID, LangID, EmailType.RESELLER_WELCOME_EMAIL, SMTPID, resellercontract.Reseller.Email, resellercontract.Reseller);
                _unitOfWork.Commit();
            }
            if (bResellerActivation) //Send customer welcome email
            {
                _EmailQueueService.PrepareEmailQueue(resellercontract.SiteID, LangID, EmailType.RESELLER_ACCOUNT_ACTIVATION_EMAIL, SMTPID, resellercontract.Reseller.Email, resellercontract.Reseller);
                _unitOfWork.Commit();
            }
            return(true);
        }
Exemplo n.º 3
0
        public int SaveReseller(User user, int SiteID, int LangID, int SMTPID, string SiteAdmin)
        {
            User dupplicate = _User.Find(u => u.Email.ToLower().Equals(user.Email) && u.SiteID == SiteID).FirstOrDefault();

            if (dupplicate == null)
            {
                user.AuditDetails                = new Audit();
                user.AuditDetails.DateCreated    = System.DateTimeWithZone.Now;
                user.AuditDetails.DateModified   = System.DateTimeWithZone.Now;
                user.AuditDetails.ByUserID       = user.ID;
                user.AuditDetails.HttpHeaderDump = HttpUtility.UrlDecode(System.Web.HttpContext.Current.Request.Headers.ToString());
                user.AuditDetails.IP             = System.Web.HttpContext.Current.Request.UserHostAddress;

                user.UserTypeID          = (int)UserType.RESELLER;
                user.Address.CompanyName = user.CompanyName;
                user.Address.Email       = user.Email;
                user.ConfirmPassword     = user.PasswordHash;

                user.SiteID = SiteID;

                Contract contrat = _Contract.Find(C => C.ContractLevel > 0 && C.isAutoCalculation == true && C.isForReseller == true && C.SiteID == SiteID && C.RecordStatusID == (int)RecordStatus.ACTIVE).OrderBy(C => C.ContractLevel).FirstOrDefault();
                if (contrat == null)
                {
                    contrat = _Contract.Find(C => C.isAutoCalculation == false && C.isForReseller == true && C.SiteID == SiteID && C.RecordStatusID == (int)RecordStatus.ACTIVE).OrderBy(C => C.ID).FirstOrDefault();
                }

                if (contrat == null)
                {
                    contrat = new Contract();
                    contrat.ContractLevel     = 0;
                    contrat.ContractName      = "Reseller Default Contract";
                    contrat.isAutoCalculation = false;
                    contrat.isForReseller     = true;
                    contrat.RecordStatusID    = (int)RecordStatus.ACTIVE;
                    contrat.SiteID            = SiteID;

                    _Contract.Add(contrat);
                    _unitOfWork.Commit();
                }

                ResellerContract rc = new ResellerContract();
                rc.AuditDetails = user.AuditDetails;
                rc.ContractID   = contrat.ID;
                rc.Reseller     = user;
                rc.SiteID       = SiteID;

                _ResellerContract.Add(rc);
                _unitOfWork.Commit();

                //Add EmailQueue
                User _newuser = _User.Find(u => u.ID == user.ID).EagerLoad(u => u.Address, u => u.Address.Country).FirstOrDefault();
                _EmailQueueService.PrepareEmailQueue(SiteID, LangID, EmailType.RESELLER_WELCOME_EMAIL, SMTPID, _newuser.Email, _newuser);

                //TO DO: set admin email address
                _EmailQueueService.PrepareEmailQueue(SiteID, LangID, EmailType.ADMIN_NEW_RESELLER, SMTPID, SiteAdmin, _newuser);
                _unitOfWork.Commit();
                // End
            }
            else
            {
                return(-1);
            }

            return(1);
        }