public static string UpdatePassword(string passwordData) { int updateCustomerId = 0; Hashtable cusHash = EncryptionHelper.Unpack(EncryptionHelper.Decrypt(passwordData, cryptKey)); GCDCustomer retCus = new GCDCustomer(cusHash); retCus.Success = false; if (cusHash.ContainsKey("CustomerID") && int.TryParse(cusHash["CustomerID"].ToString(), out updateCustomerId)) { if (cusHash.ContainsKey("NewPassword")) { string newPassword = cusHash["NewPassword"].ToString(); using (CastleClubEntities entities = new CastleClubEntities()) { Customer customer = entities.Customers.Where(c => c.Id == updateCustomerId).FirstOrDefault(); Password password = new Password(newPassword); customer.Password = password.SaltedPassword; customer.SaltKey = password.SaltKey; customer.UnEncryptPass = "";// newPassword; entities.SaveChanges(); retCus.Success = true; } } } return(EncryptionHelper.Encrypt(retCus.ToString(), cryptKey)); }
public ActionResult WelcomeEmail(CastleClub.BackEnd.Models.WelcomeEmailVM model) { if (!ModelState.IsValid) { return(View(model)); } //bool sel = model.sites[0].SendWelcomeEmail; using (CastleClubEntities entities = new CastleClubEntities()) { foreach (var item in model.sites) { var site = entities.Sites.Where(x => x.Id == item.Id).FirstOrDefault(); site.SendWelcomeEmail = item.SendWelcomeEmail; site.WelcomeEmailDelay = item.WelcomeEmailDelay; site.Email = item.Email; site.SmtpAddress = item.SmtpAddress; if (!string.IsNullOrEmpty(item.PasswordEmail)) { site.PasswordEmail = item.PasswordEmail; } } var parameter = entities.Parameters.FirstOrDefault(); parameter.CapEmail = model.CapEmail; entities.SaveChanges(); } return(View(model)); }
public void SendEmail(TestVM model) { if (ModelState.IsValid && !string.IsNullOrEmpty(model.EmailToSend) && !string.IsNullOrEmpty(model.Name)) { string body = ""; #region Generate random string (result in result variable) // var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; //var random = new Random(); var result = "";// new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(s.Length)]).ToArray()); #endregion SiteDT siteDT = SitesManager.GetSite(model.SiteID); using (CastleClubEntities entities = new CastleClubEntities()) { Customer customer = entities.Customers.Where(c => c.Email == model.EmailToSend && c.SiteId == siteDT.Id).FirstOrDefault(); if (customer != null) { result = customer.UnEncryptPass; if (result == null) { var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; var random = new Random(); result = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(s.Length)]).ToArray()); Password p = new Password(result); customer.Password = p.SaltedPassword; customer.UnEncryptPass = p.ClearPassword; //customer. customer.SaltKey = p.SaltKey; entities.SaveChanges(); } } } body = string.Format(Email.WelcomeBodyEmail(), model.Name, model.EmailToSend, result, siteDT.Name, siteDT.Name, "PartsGeek", siteDT.Price, siteDT.PricePerQuarter, siteDT.Phone, siteDT.Email, siteDT.OfferDomain); string subject = string.Format(Email.WelcomeSubjectEmail(), siteDT.Name); CastleClub.BusinessLogic.Utils.Email.SendEmailWithBCC(siteDT.Email, siteDT.PasswordEmail, siteDT.SmtpAddress, subject, body , new List <string>() { model.EmailToSend }, new List <string>() { siteDT.WelcomeEmailBCC }, true); } }
public static void DeleteUser(int id) { using (CastleClubEntities entities = new CastleClubEntities()) { User user = entities.Users.Where(u => u.Id == id).FirstOrDefault(); if (user == null) { throw new InvalidUserException(); } user.Active = false; entities.SaveChanges(); } }
public static UserDT CreateUser(UserDT user) { using (CastleClubEntities entities = new CastleClubEntities()) { User newUser = new User(); newUser.Email = user.Email; newUser.FirstName = user.FirstName; newUser.LastName = user.LastName; newUser.Role = user.Role; newUser.AspNetId = user.AspNetId; newUser.Active = true; entities.Users.Add(newUser); entities.SaveChanges(); return(newUser.GetDT()); } }
public static void CreateInvoices() { using (CastleClubEntities entities = new CastleClubEntities()) { if (CastleClub.BusinessLogic.Data.GlobalParameters.Create) { int yearMin = CastleClub.BusinessLogic.Data.GlobalParameters.YearMin; DateTime min = new DateTime(yearMin, 1, 1); DateTime max = DateTime.Now.Date.AddDays(1).AddMinutes(-1); List <Customer> list = entities.Customers.Where(c => c.NextBillDate >= min && c.NextBillDate < max && c.StatusId == CustomerStatus.ACTIVE.ToString()).ToList(); foreach (Customer c in list) { try { while (c.NextBillDate <= DateTime.Now) { Invoice invoice = new Invoice(); invoice.CustomerId = c.Id; invoice.Amount = c.Site.PricePerQuarter; invoice.Status = InvoiceStatus.NEW; invoice.CreatedAt = DateTime.Now; c.LastBillDate = DateTime.Now; c.NextBillDate = c.NextBillDate.AddMonths(3); entities.Invoices.Add(invoice); entities.SaveChanges(); } } catch (Exception ex) { Utils.EventViewer.Writte("CastleClub", "PaymentTask - Creations", ex.ToString(), System.Diagnostics.EventLogEntryType.Error); } } } } }
public static bool CancelCustomer(string customerData) { bool ret = false; int cancelCustomerId = 0; Hashtable cusHash = EncryptionHelper.Unpack(EncryptionHelper.Decrypt(customerData, cryptKey)); if (cusHash.ContainsKey("CustomerID") && int.TryParse(cusHash["CustomerID"].ToString(), out cancelCustomerId)) { using (CastleClubEntities entities = new CastleClubEntities()) { Customer customer = entities.Customers.FirstOrDefault(x => x.Id == cancelCustomerId); if (customer != null) { customer.Status = CustomerStatus.CANCELLED; customer.CancelledDate = DateTime.Now; entities.SaveChanges(); ret = true; } } } return(ret); }
/// <summary> /// Read all transaction from authorize report file. /// </summary> /// <param name="path">Authorize report file path.</param> /// <param name="onlyRefund">Indicate if only include refund transactions.</param> /// <returns>Indicate if all ok or was any error.</returns> public static bool ReadReportFile(string path, bool onlyRefund) { try { var reports = ReadFile(path, true, onlyRefund); Dictionary <int, int> map = new Dictionary <int, int>(); using (CastleClubEntities entities = new CastleClubEntities()) { bool cancellCustomer = false; foreach (var report in reports) { int invoiceID = map.ContainsKey(report.InvoiceID) ? map[report.InvoiceID] : report.InvoiceID; if (report.SubmitDate >= new DateTime(2014, 11, 04)) { var aux = report.CustomerID; var customer = entities.Customers.FirstOrDefault(x => x.Id == aux); if (customer != null) { #region aux = report.CustomerID; var invoice = entities.Invoices.FirstOrDefault(x => x.Id == invoiceID && x.CustomerId == aux); if (invoice != null) { var auxLong = report.TranscactionID; var transaction = entities.Transactions.FirstOrDefault(x => x.AuthorizeTransactionId == auxLong); if (transaction == null) { transaction = new Transaction() { AuthorizeTransactionId = report.TranscactionID, CreditCard = customer.CreditCards.FirstOrDefault(), //Invoice = invoice, Message = string.Empty, StatusId = report.Status, SubmitDate = report.SubmitDate, TypeId = report.TransactionType }; entities.Transactions.Add(transaction); if ((report.Status == "SUCCESFULL") && (report.TransactionType == "SALE")) { invoice.BilledDate = report.SettlementDate; invoice.StatusId = "BILLED"; invoice.Transactions.Add(transaction); transaction.Invoice = invoice; } else if ((report.Status == "SUCCESFULL") && (report.TransactionType == "REFUND")) { if (customer.Invoices.Any()) { var invoiceAux = customer.Invoices.Where(x => x.Transactions.Any(y => y.StatusId == "SUCCESFULL" && y.AuthorizeTransactionId == report.RefererTransactionID)).OrderByDescending(x => x.CreatedAt).FirstOrDefault(); if (invoiceAux != null) { invoice = invoiceAux; transaction.RefundedTransactionId = invoice.Transactions.FirstOrDefault(x => x.AuthorizeTransactionId == report.RefererTransactionID).Id; } } invoice.RefundedDate = report.SettlementDate; invoice.StatusId = "REFUNDED"; invoice.Amount = report.Amount; cancellCustomer = true; transaction.Invoice = invoice; invoice.Transactions.Add(transaction); } else if ((report.Status == "FAILED") && (report.TransactionType == "SALE")) { invoice.StatusId = "BILLEDFAIL"; invoice.BilledDate = report.SettlementDate; invoice.Transactions.Add(transaction); transaction.Invoice = invoice; } else if ((report.Status == "FAILED") && (report.TransactionType == "REFUND")) { if (customer.Invoices.Any()) { var invoiceAux = customer.Invoices.Where(x => x.Transactions.Any(y => y.StatusId == "SUCCESFULL" && y.AuthorizeTransactionId == report.RefererTransactionID)).OrderByDescending(x => x.CreatedAt).FirstOrDefault(); if (invoiceAux != null) { invoice = invoiceAux; transaction.RefundedTransactionId = invoice.Transactions.FirstOrDefault(x => x.AuthorizeTransactionId == report.RefererTransactionID).Id; } } invoice.RefundedDate = report.SettlementDate; invoice.StatusId = "REFUNDEDFAIL"; invoice.Amount = report.Amount; cancellCustomer = true; invoice.Transactions.Add(transaction); transaction.Invoice = invoice; invoice.Transactions.Add(transaction); } if (cancellCustomer) { customer.CancelledDate = report.SubmitDate; customer.StatusId = "CANCELLED"; } try { entities.SaveChanges(); } catch (Exception) { Utils.EventViewer.Writte("Castle Club Admin", "Authorize Synchronize", "The synchronize for customer: \"" + report.CustomerID + "\", with the transaction: \"" + report.TranscactionID + "\", and this date: \"" + report.SubmitDate + "\", failed.", System.Diagnostics.EventLogEntryType.Error); } if (!map.ContainsKey(report.InvoiceID)) { map.Add(report.InvoiceID, invoice.Id); } } } else { var auxlong = report.TranscactionID; var transaction = entities.Transactions.FirstOrDefault(x => x.AuthorizeTransactionId == auxlong); if (transaction == null) { if (customer.Invoices.Count == 0) { invoice = new Invoice() { Amount = report.Amount, BilledDate = report.SubmitDate, CreatedAt = report.SubmitDate, Customer = customer, CustomerId = report.CustomerID, FailCount = 0, Transactions = new List <Transaction>(), Id = invoiceID }; customer.Invoices.Add(invoice); entities.Invoices.Add(invoice); } else { if (report.RefererTransactionID > 0 && customer.Invoices.Any(x => x.Transactions.Any(y => y.StatusId == "SUCCESFULL" && y.AuthorizeTransactionId == report.RefererTransactionID))) { invoice = customer.Invoices.Where(x => x.Transactions.Any(y => y.StatusId == "SUCCESFULL" && y.AuthorizeTransactionId == report.RefererTransactionID)).OrderByDescending(x => x.CreatedAt).FirstOrDefault(); } else { invoice = new Invoice() { Amount = report.Amount, BilledDate = report.SubmitDate, CreatedAt = report.SubmitDate, Customer = customer, CustomerId = report.CustomerID, FailCount = 0, Transactions = new List <Transaction>(), Id = invoiceID }; customer.Invoices.Add(invoice); entities.Invoices.Add(invoice); } } transaction = new Transaction() { AuthorizeTransactionId = report.TranscactionID, CreditCard = customer.CreditCards.FirstOrDefault(), Invoice = invoice, Message = string.Empty, StatusId = report.Status, SubmitDate = report.SubmitDate, TypeId = report.TransactionType }; invoice.Transactions.Add(transaction); entities.Transactions.Add(transaction); if (report.TransactionType == "SALE") { if (report.Status == "SUCCESFULL") { invoice.StatusId = "BILLED"; } else if (report.Status == "FAILED") { invoice.StatusId = "BILLEDFAIL"; } } else if (report.TransactionType == "REFUND") { if (report.Status == "SUCCESFULL") { invoice.StatusId = "REFUNDED"; } else if (report.Status == "FAILED") { invoice.StatusId = "REFUNDEDFAIL"; } cancellCustomer = true; var transactionRefund = invoice.Transactions.FirstOrDefault(x => x.AuthorizeTransactionId == report.RefererTransactionID); if (transactionRefund != null) { transaction.RefundedTransactionId = transactionRefund.Id; } } if (cancellCustomer) { customer.CancelledDate = report.SubmitDate; customer.StatusId = "CANCELLED"; } try { entities.SaveChanges(); } catch (Exception) { Utils.EventViewer.Writte("Castle Club Admin", "Authorize Synchronize", "The synchronize for customer: \"" + report.CustomerID + "\", with the transaction: \"" + report.TranscactionID + "\", and this date: \"" + report.SubmitDate + "\", failed.", System.Diagnostics.EventLogEntryType.Error); } if (!map.ContainsKey(report.InvoiceID)) { map.Add(report.InvoiceID, invoice.Id); } } } #endregion } } } } return(true); } catch (Exception) { return(false); } }
public static void ProcessInvoices() { using (CastleClubEntities entities = new CastleClubEntities()) { if (CastleClub.BusinessLogic.Data.GlobalParameters.Procces) { int maxFailCount = CastleClub.BusinessLogic.Data.GlobalParameters.FailCount; int yearMin = CastleClub.BusinessLogic.Data.GlobalParameters.YearMin; DateTime min = new DateTime(yearMin, 1, 1); List <Invoice> list = entities.Invoices.Where(i => (i.Customer.CancelledDate == null) && (i.CreatedAt >= min) && (!i.FailCount.HasValue || i.FailCount.Value < maxFailCount) && (i.StatusId == InvoiceStatus.NEW.ToString() || i.StatusId == InvoiceStatus.BILLEDFAIL.ToString())).ToList(); foreach (Invoice invoice in list) { try { SiteDT siteDT = invoice.Customer.Site.GetDT(); InvoiceDT invoiceDT = invoice.GetDT(); CustomerDT customerDT = invoice.Customer.GetDT(false); CreditCardDT creditCardDT = invoice.Customer.CreditCards.FirstOrDefault().GetDT(); Transaction transaction = new Transaction(); transaction.InvoiceId = invoiceDT.Id; transaction.CreditCardId = creditCardDT.Id; transaction.AuthorizeTransactionId = 0; transaction.TypeId = TransactionType.SALE.ToString(); transaction.StatusId = TransactionStatus.FAILED.ToString(); transaction.SubmitDate = DateTime.Now; entities.Transactions.Add(transaction); entities.SaveChanges(); long transactionId = 0; string message = ""; string code = string.Empty; bool succesfull = CIM.CreateCustomerProfileTransactionAuthCapture(siteDT, invoiceDT, customerDT, creditCardDT, out transactionId, out message, out code); if (succesfull) { invoice.Status = InvoiceStatus.BILLED; invoice.BilledDate = DateTime.Now; transaction.Status = TransactionStatus.SUCCESFULL; transaction.AuthorizeTransactionId = transactionId; invoice.Customer.Referrer.BilledTotal++; invoice.Customer.Referrer.RevenueAmount += invoice.Amount; entities.SaveChanges(); } else { invoice.FailCount = invoice.FailCount.HasValue ? invoice.FailCount.Value + 1 : 1; transaction.Message = message + code; invoice.Status = InvoiceStatus.BILLEDFAIL; entities.SaveChanges(); if (invoice.FailCount >= maxFailCount && entities.NotificationProcess.Any()) { //To do some. //Send email for notification. string smtpAddress = CastleClub.BusinessLogic.Data.GlobalParameters.Smtp; int portNumber = 587; bool enableSSL = true; string emailFrom = CastleClub.BusinessLogic.Data.GlobalParameters.EmailAccount; string password = CastleClub.BusinessLogic.Data.GlobalParameters.EmailPassword; string subject = "Error an ocurred with invoice: " + invoiceDT.Id; string body = "Error ocurred at " + maxFailCount + " time with invoice: " + invoiceDT.Id + ", customerId: " + invoice.CustomerId + ", and with credit card: " + invoice.Customer.CreditCards.FirstOrDefault().Id; using (System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage()) { mail.From = new MailAddress(emailFrom); foreach (var emailTo in entities.NotificationProcess) { mail.To.Add(emailTo.To); } mail.Subject = subject; mail.Body = body; mail.IsBodyHtml = false; using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber)) { smtp.Credentials = new NetworkCredential(emailFrom, password); smtp.EnableSsl = enableSSL; smtp.Send(mail); } } } } } catch (Exception ex) { Utils.EventViewer.Writte("CastleClubAdmin", "PaymentTask - Process", ex.ToString(), System.Diagnostics.EventLogEntryType.Error); } } } } }
public static string LogonSecureByGroup(string logonData, string groupId) { GCDCustomer retCus = new GCDCustomer(); retCus.Success = false; retCus.AccountLocked = false; if (string.IsNullOrEmpty(groupId)) { groupId = "1181"; } using (CastleClubEntities entities = new CastleClubEntities()) { Site site = entities.Sites.Where(s => s.GroupId == groupId).FirstOrDefault(); if (site != null) { string li = EncryptionHelper.Decrypt(logonData, cryptKey); string[] linf = li.Split('&'); if (linf.Length == 2) { string[] cinf = linf[0].Split('='); string[] pinf = linf[1].Split('='); string email = cinf[1]; if (cinf.Length == 2 && pinf.Length == 2) { Customer customer = entities.Customers.Where(c => c.SiteId == site.Id && c.Email == email).FirstOrDefault(); if (customer != null) { string chkPass = pinf[1]; Password pwd = new Password(chkPass, customer.SaltKey); if (customer.BadLoginCount < 5 && customer.Password == pwd.SaltedPassword) { if (customer.Status != CustomerStatus.ACTIVE) { retCus.Messages = "Customer Account Not Found, Invalid or Cancelled"; } else { retCus.FirstName = customer.FirstName; retCus.LastName = customer.LastName; retCus.Address1 = customer.Address; retCus.Address2 = String.Empty; retCus.City = customer.City; retCus.State = entities.States.Where(s => s.Id == customer.StateId).FirstOrDefault().Name; retCus.Country = "USA"; retCus.Email = customer.Email; retCus.Phone = customer.Phone; retCus.CustomerID = customer.Id; retCus.RegisterDate = customer.CreatedAt; retCus.MemberID = "M" + site.GroupId + "-" + customer.Id; retCus.Validator = logonData; retCus.Success = true; retCus.Zip = customer.ZipCode; retCus.CreatedAt = customer.CreatedAt; var creditCard = customer.CreditCards.FirstOrDefault(); if (creditCard != null) { retCus.CreditCardNumber = creditCard.LastFourDigit; retCus.CreditCardType = creditCard.Type; retCus.CreditCardMonthExpired = 1; retCus.CreditCardYearExpired = DateTime.Now.Year; } customer.BadLoginCount = 0; entities.SaveChanges(); } } else { retCus.Messages = "Logon Failed"; if (customer.BadLoginCount > 4) { retCus.AccountLocked = true; } else { customer.BadLoginCount = customer.BadLoginCount + 1; entities.SaveChanges(); retCus.AccountLocked = false; } } } } } else { retCus.Messages = "Missing or Null Data Field"; } if (retCus.Success == false && retCus.Messages.Length == 0) { retCus.Messages = "Logon Failed"; } return(EncryptionHelper.Encrypt(retCus.ToString(), cryptKey)); } else { return(String.Empty); } } }
public static string UpdateCustomer(string customerData, bool sendEmail) { int updateCustomerId = 0; Hashtable cusHash = EncryptionHelper.Unpack(EncryptionHelper.Decrypt(customerData, cryptKey)); GCDCustomer retCus = new GCDCustomer(cusHash); GCDCreditCard retCreditCard = new GCDCreditCard(cusHash); retCus.Success = false; if (cusHash.ContainsKey("CustomerID") && int.TryParse(cusHash["CustomerID"].ToString(), out updateCustomerId)) { using (CastleClubEntities entities = new CastleClubEntities()) { Customer customer = entities.Customers.Where(c => c.Id == updateCustomerId).FirstOrDefault(); if (customer != null) { Password passwordHash = new Password(cusHash["PasswordOld"].ToString(), customer.SaltKey); if (customer.Password == passwordHash.SaltedPassword) { customer.FirstName = retCus.FirstName; customer.LastName = retCus.LastName; customer.Address = retCus.Address1; customer.City = retCus.City; State state = entities.States.FirstOrDefault(s => s.Name.ToLower() == retCus.State.ToLower()); customer.StateId = state != null?state.Id.ToString() : string.Empty; customer.Email = retCus.Email; customer.Phone = retCus.Phone; customer.ZipCode = retCus.Zip; var creditCard = customer.CreditCards.FirstOrDefault(); if (creditCard != null && !string.IsNullOrEmpty(retCreditCard.CreditCard) && Utils.CreditCardHelper.Valid(retCreditCard.CreditCard, false)) { var today = DateTime.Now; if (today.Year > retCus.CreditCardYearExpired || (today.Year == retCus.CreditCardYearExpired && today.Month >= retCreditCard.Month)) { throw new Exception("The credit card is invalid."); } var encryptData = CastleClub.BusinessLogic.Utils.EncryptionHelper.EncryptRSACertificate("ccNum:" + retCreditCard.CreditCard + ";cVV:;ccExp:" + Utils.CreditCardHelper.GetExpDate(retCreditCard.Month, retCreditCard.Year)); string lastFourDigit = retCreditCard.CreditCard.Substring(retCreditCard.CreditCard.Length - 4, 4); string type = Utils.CreditCardHelper.GetCardType(retCreditCard.CreditCard); creditCard.CreatedAt = DateTime.Now; creditCard.Data = encryptData; creditCard.LastFourDigit = lastFourDigit; creditCard.Type = type; long newPaymentProfile; string message = string.Empty; if (CastleClub.BusinessLogic.AuthorizeAPI.CIM.CreateNewCustomerPaymentProfile(customer.Site.GetDT(), customer.GetDT(false), retCreditCard.CreditCard, Utils.CreditCardHelper.GetExpDate(retCreditCard.Month, retCreditCard.Year), out newPaymentProfile, out message)) { creditCard.AuthorizePaymentProfileId = newPaymentProfile; } else { throw new Exception(message); } } bool setPassword = false; if (!string.IsNullOrEmpty(retCus.PasswordNow)) { Password password = new Password(retCus.PasswordNow); customer.Password = password.SaltedPassword; customer.SaltKey = password.SaltKey; setPassword = true; } retCus.Success = true; entities.SaveChanges(); if (sendEmail && setPassword) { string smtpAddress = CastleClub.BusinessLogic.Data.GlobalParameters.Smtp; string emailFrom = customer.Site.Email; string passwordEmail = customer.Site.PasswordEmail; //CastleClub.BusinessLogic.Data.GlobalParameters.EmailPassword; string subject = string.Format(Properties.Resources.SetPasswordSubjectEmail, customer.Site.Name); string body = string.Format(Properties.Resources.SetPasswordBodyEmail, customer.Site.Name, retCus.PasswordNow); Utils.Email.SendEmail(emailFrom, passwordEmail, smtpAddress, subject, body, new List <string>() { customer.Email }, false); } } else { retCus.Success = false; retCus.Messages = "The password for the customer not match."; } } else { retCus.Messages = "Error custmer ID."; } } } return(EncryptionHelper.Encrypt(retCus.ToString(), cryptKey)); }
public static string ResetPasswordByGroup(string resetData, string groupId, bool sendMail) { int siteId = 0; Hashtable cusHash = EncryptionHelper.Unpack(EncryptionHelper.Decrypt(resetData, cryptKey)); GCDCustomer retCus = new GCDCustomer(cusHash); retCus.Success = false; if (cusHash.ContainsKey("Email") && int.TryParse(groupId, out siteId)) { using (CastleClubEntities entities = new CastleClubEntities()) { Site site = entities.Sites.FirstOrDefault(x => x.GroupId == siteId.ToString()); if (site != null) { siteId = site.Id; string email = cusHash["Email"].ToString(); Customer customer = entities.Customers.FirstOrDefault(c => c.SiteId == siteId && c.Email == email); if (customer != null) { /*Password password = new Password(); * customer.Password = password.SaltedPassword; * customer.SaltKey = password.SaltKey; * entities.SaveChanges(); * retCus.Success = true;*/ if (sendMail && !string.IsNullOrEmpty(retCus.Password)) { string smtpAddress = CastleClub.BusinessLogic.Data.GlobalParameters.Smtp; string emailFrom = site.Email; string passwordEmail = site.PasswordEmail; //CastleClub.BusinessLogic.Data.GlobalParameters.EmailPassword; string subject = string.Format(Properties.Resources.SetPasswordSubjectEmail, site.Name); var url = string.Format(GlobalParameters.UrlResetPassword, retCus.Password, retCus.Validator); //pasamos el dominio en password y el guid en validator string body = string.Format(Properties.Resources.SetPasswordBodyEmail, url, site.Name); Utils.Email.SendEmail(emailFrom, passwordEmail, smtpAddress, subject, body, new List <string>() { customer.Email }, true); retCus.Success = true; } else if (!sendMail && !string.IsNullOrEmpty(retCus.Password)) { Password password = new Password(retCus.Password); customer.Password = password.SaltedPassword; customer.SaltKey = password.SaltKey; entities.SaveChanges(); retCus.Success = true; } } else { retCus.Messages = "Invalid Email"; } } else { retCus.Messages = "Invalid GroupId"; } } } else { retCus.Messages = "Invalid Email"; } CastleClub.BusinessLogic.Utils.EventViewer.WriteToFile("Log Web Service", retCus.Messages, "c:\\users\\administrator\\desktop\\log.txt"); return(EncryptionHelper.Encrypt(retCus.ToString(), cryptKey)); }