public async Task <PostResponseModel> RegisterVendor(RegisterVendorRequestModel vendorDetailsRequestModel)
        {
            PostResponseModel postResponseModel = new PostResponseModel();

            RegisterVendor registerUser = new RegisterVendor()
            {
                VendorName     = vendorDetailsRequestModel.VendorName,
                VendorEmail    = vendorDetailsRequestModel.VendorEmail,
                VendorMobile   = vendorDetailsRequestModel.VendorMobile,
                VendorLandline = vendorDetailsRequestModel.VendorLandline,
                AddressLine    = vendorDetailsRequestModel.AddressLine,
                City           = vendorDetailsRequestModel.City,
                State          = vendorDetailsRequestModel.State,
                PinCode        = vendorDetailsRequestModel.PinCode
            };

            var registerVendorResponse = await _vendorAuthenticationRepository.RegisterVendor(registerUser);

            postResponseModel.IsAlreadyExists = registerVendorResponse.IsUserExists;

            if (!postResponseModel.IsAlreadyExists && registerVendorResponse.Success)
            {
                var emailBody    = "Hello !!!";
                var emailSubject = "Vendor Register";

                var emailResponse = await _messageSenderUtility.SendEmail(emailBody, emailSubject, vendorDetailsRequestModel.VendorEmail);

                postResponseModel.Success = emailResponse.IsEmailSend;

                //Log email
                EmailLogs emailLogDetails = new EmailLogs()
                {
                    FromEmailAddress = emailResponse.FromEmailAddress,
                    ToEmailAddress   = emailResponse.ToEmailAddress,
                    Subject          = emailSubject,
                    Body             = emailBody,
                    IsProduction     = emailResponse.IsProductionEnvironment,
                    IsSend           = emailResponse.IsEmailSend,
                    ApplicationId    = (int)ApplicationType.Vendor,
                    FromUserType     = "System",
                    ToUserType       = "Vendor",
                    ToUserId         = registerVendorResponse.Content.VendorId
                };

                await _loggingRepository.LogEmailTransaction(emailLogDetails);
            }
            else
            {
                postResponseModel.Success = registerVendorResponse.Success;
            }

            return(postResponseModel);
        }
Esempio n. 2
0
        public async Task <PostResponseModel> ConfirmRegistration(int vendorId)
        {
            PostResponseModel postResponseModel = new PostResponseModel();

            var passwordSalt      = AuthenticateUtility.CreatePasswordSalt();
            var password          = AuthenticateUtility.GetRandomAlphanumericString(12);
            var encryptedPassword = AuthenticateUtility.GeneratePassword(password, passwordSalt);

            var registerVendorResponse = await _vendorRepository.ConfirmRegistration(vendorId, encryptedPassword, passwordSalt);

            postResponseModel.IsAlreadyExists = registerVendorResponse.IsUserExists;
            if (!postResponseModel.IsAlreadyExists && registerVendorResponse.Success)
            {
                var emailBody    = "Your password: "******"Confirm Your Registration";

                var emailResponse = await _messageSenderUtility.SendEmail(emailBody, emailSubject, registerVendorResponse.Content.VendorEmail);

                postResponseModel.Success = emailResponse.IsEmailSend;

                //Log email
                EmailLogs emailLogDetails = new EmailLogs()
                {
                    FromEmailAddress = emailResponse.FromEmailAddress,
                    ToEmailAddress   = emailResponse.ToEmailAddress,
                    Subject          = emailSubject,
                    Body             = emailBody,
                    IsProduction     = emailResponse.IsProductionEnvironment,
                    IsSend           = emailResponse.IsEmailSend,
                    ApplicationId    = (int)ApplicationType.Admin,
                    FromUserType     = "System",
                    ToUserType       = "Vendor",
                    ToUserId         = registerVendorResponse.Content.VendorId,
                    CreatedDate      = DateTime.Now
                };

                await _loggingRepository.LogEmailTransaction(emailLogDetails);
            }
            else
            {
                postResponseModel.Success = registerVendorResponse.Success;
            }

            return(postResponseModel);
        }