public long CreateUserName(CreateUserObject createUserObject) { LogBook.LogBook.TextLog.Info(string.Format("Request {0}", Request.RequestUri.GetLeftPart(UriPartial.Authority))); LogBook.LogBook.TextLog.Info(string.Format("User Name {0}", createUserObject.username)); LogBook.LogBook.TextLog.Info(string.Format("Company Name {0}", createUserObject.companyname)); LogBook.LogBook.TextLog.Info(string.Format("Zip Code {0}", createUserObject.zipcode)); LogBook.LogBook.TextLog.Info(string.Format("Id Country {0}", createUserObject.idCountry)); LogBook.LogBook.TextLog.Info(string.Format("US State {0}", createUserObject.usstate)); LogBook.LogBook.TextLog.Info(string.Format("Canada State {0}", createUserObject.canadaprovince)); LogBook.LogBook.TextLog.Info(string.Format("Out Side US and Canada {0}", createUserObject.outsideus)); LogBook.LogBook.TextLog.Info(string.Format("Membership {0}", createUserObject.membership)); var repository = new INSecurityImplementation(); var result = repository.CreateUser(createUserObject, Request.RequestUri.GetLeftPart(UriPartial.Authority)); return(result >= 1 ? (long)1 : (long)0); }
public decimal CreateUser(CreateUserObject createUserObject, string baseURI) { var stopwatch = new Stopwatch(); stopwatch.Start(); var returnValue = (decimal)0; var passwd = string.Empty; using (var dbTran = _transshipEntities.Database.BeginTransaction()) { try { var newCustomer = new customers { company_name = createUserObject.companyname, countryId = createUserObject.idCountry, city = createUserObject.city, estimated_membership = createUserObject.membership, address1 = createUserObject.addr1, address2 = createUserObject.addr2, zipcode = createUserObject.zipcode, status = "P", register_date = DateTime.Today, state = createUserObject.usstate }; _transshipEntities.customers.Add(newCustomer); passwd = TransShip.Security.Security.Encrypt(DateTime.Now.ToString(), new RijndaelManaged(), TransShip.Security.Security.GenerateKey(new RijndaelManaged(), 256)); var newUser = new users { customerId = newCustomer.customerId, full_name = createUserObject.fullname, email = createUserObject.email, password = TransShip.Security.Security.Encrypt(createUserObject.keyinformation, new RijndaelManaged(), KEY), user_type = "C", status = "I", role = "A", confirmationKey = passwd }; _transshipEntities.users.Add(newUser); var newContact = new customer_contacts { customerId = newCustomer.customerId, full_name = createUserObject.fullname, title = createUserObject.title, phone_number = createUserObject.phonenumber, email = createUserObject.email }; _transshipEntities.customer_contacts.Add(newContact); _transshipEntities.SaveChanges(); returnValue = newUser.userId; dbTran.Commit(); } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); } finally { stopwatch.Stop(); LogBook.TextLog.Info(string.Format("Ellapsed time {0} milli seconds", stopwatch.ElapsedMilliseconds)); var emailhandler = new TransShip.EMailHandler.EMailHandler(); emailhandler.SendConfirmationEmail(string.Format("your registration has been successful, TranShip will contact you "), string.Format("{0}?apiInformation={1}", baseURI, HttpUtility.UrlEncode(passwd)), createUserObject.email); } } return(returnValue); }