/// <summary> /// Copies the current object to a new instance /// </summary> /// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param> /// <param name="copiedObjects">Objects that should be reused</param> /// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param> /// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param> /// <param name="copy">Optional - An existing [IntermediaryUser] instance to use as the destination.</param> /// <returns>A copy of the object</returns> public virtual IntermediaryUser Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, IntermediaryUser copy = null) { if (copiedObjects == null) { copiedObjects = new Hashtable(); } if (copy == null && copiedObjects.Contains(this)) { return((IntermediaryUser)copiedObjects[this]); } copy = copy ?? new IntermediaryUser(); if (!asNew) { copy.TransientId = this.TransientId; } if (!copiedObjects.Contains(this)) { copiedObjects.Add(this, copy); } if (deep && this.intermediary != null) { if (!copiedObjects.Contains(this.intermediary)) { if (asNew && reuseNestedObjects) { copy.Intermediary = this.Intermediary; } else if (asNew) { copy.Intermediary = this.Intermediary.Copy(deep, copiedObjects, true); } else { copy.intermediary = this.intermediary.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.Intermediary = (Intermediary)copiedObjects[this.Intermediary]; } else { copy.intermediary = (Intermediary)copiedObjects[this.Intermediary]; } } } base.Copy(deep, copiedObjects, asNew, reuseNestedObjects, copy); return(copy); }
public static void CreateImplementation(DSS5_SupplyChainFinancialsOptimisation.BO.IntermediaryUser newIntermediaryUser) { newIntermediaryUser.UserName = ""; new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Save <DSS5_SupplyChainFinancialsOptimisation.BO.IntermediaryUser>(newIntermediaryUser); }
public static void SaveImplementation(DSS5_SupplyChainFinancialsOptimisation.BO.IntermediaryUser IntermediaryUser) { new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Save <DSS5_SupplyChainFinancialsOptimisation.BO.IntermediaryUser>(IntermediaryUser); }
/*<ControllerActionImplementation:SignUp:1/>*/ public ActionResult ExecuteSignUp() { ActionResult _result = null; if ((@model.PasswordTextBox != @model.RetypePass)) { ClientCommand(ClientCommands.SHOW_MESSAGE, "Passwords do not match", MessageType.Warning); return(null); } zAppDev.DotNet.Framework.Identity.Model.ApplicationUser userToRegister = new zAppDev.DotNet.Framework.Identity.Model.ApplicationUser(); System.Collections.Generic.List <zAppDev.DotNet.Framework.Identity.Model.ApplicationRole> roleToAdd = new System.Collections.Generic.List <zAppDev.DotNet.Framework.Identity.Model.ApplicationRole>(); if ((@model.ChoosenRole == null)) { zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Warning, "SignUp", DSS5_SupplyChainFinancialsOptimisation.Hubs.EventsHub.RaiseDebugMessage, "User did not select a Role."); ClientCommand(ClientCommands.SHOW_MESSAGE, "Please choose a role you wish to sign up as.", MessageType.Warning); return(null); } if (@model.ChoosenRole == "Supplier") { DSS5_SupplyChainFinancialsOptimisation.BO.Supplier newSupplier = new DSS5_SupplyChainFinancialsOptimisation.BO.Supplier(); newSupplier.UserName = @model.UserName; newSupplier.Email = @model.Email; if ((((((newSupplier?.Email ?? "") == null ? false : CSharpVerbalExpressions.VerbalExpressions.DefaultExpression.Add(CSharpVerbalExpressions.CommonRegex.Email).Test((newSupplier?.Email ?? "")))) == false))) { ClientCommand(ClientCommands.SHOW_MESSAGE, "Please enter a valid e-mail address", MessageType.Warning); return(null); } newSupplier.Company = @model.CompanyName; userToRegister = newSupplier; roleToAdd = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <zAppDev.DotNet.Framework.Identity.Model.ApplicationRole>((a) => a.Name == "GuestSupplier").ToList(); } if (@model.ChoosenRole == "Buyer") { DSS5_SupplyChainFinancialsOptimisation.BO.Buyer newBuyer = new DSS5_SupplyChainFinancialsOptimisation.BO.Buyer(); newBuyer.UserName = @model.UserName; newBuyer.Email = @model.Email; if ((((((newBuyer?.Email ?? "") == null ? false : CSharpVerbalExpressions.VerbalExpressions.DefaultExpression.Add(CSharpVerbalExpressions.CommonRegex.Email).Test((newBuyer?.Email ?? "")))) == false))) { ClientCommand(ClientCommands.SHOW_MESSAGE, "Please enter a valid e-mail address", MessageType.Warning); return(null); } newBuyer.Company = @model.CompanyName; userToRegister = newBuyer; roleToAdd = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <zAppDev.DotNet.Framework.Identity.Model.ApplicationRole>((a) => a.Name == "Buyer").ToList(); } if (@model.ChoosenRole == "Investor") { DSS5_SupplyChainFinancialsOptimisation.BO.Investor newInvestor = new DSS5_SupplyChainFinancialsOptimisation.BO.Investor(); newInvestor.UserName = @model.UserName; newInvestor.Email = @model.Email; if ((((((newInvestor?.Email ?? "") == null ? false : CSharpVerbalExpressions.VerbalExpressions.DefaultExpression.Add(CSharpVerbalExpressions.CommonRegex.Email).Test((newInvestor?.Email ?? "")))) == false))) { ClientCommand(ClientCommands.SHOW_MESSAGE, "Please enter a valid e-mail address", MessageType.Warning); return(null); } newInvestor.Company = @model.CompanyName; newInvestor.InvestorStatus = "GuestInvestor"; userToRegister = newInvestor; roleToAdd = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <zAppDev.DotNet.Framework.Identity.Model.ApplicationRole>((a) => a.Name == "GuestInvestor").ToList(); } if ((@model.ChoosenRole == "Intermediary")) { DSS5_SupplyChainFinancialsOptimisation.BO.IntermediaryUser newIntermediaryUser = new DSS5_SupplyChainFinancialsOptimisation.BO.IntermediaryUser(); newIntermediaryUser.UserName = @model.UserName; newIntermediaryUser.Email = @model.Email; if ((((((newIntermediaryUser?.Email ?? "") == null ? false : CSharpVerbalExpressions.VerbalExpressions.DefaultExpression.Add(CSharpVerbalExpressions.CommonRegex.Email).Test((newIntermediaryUser?.Email ?? "")))) == false))) { ClientCommand(ClientCommands.SHOW_MESSAGE, "Please enter a valid e-mail address", MessageType.Warning); return(null); } newIntermediaryUser.Intermediary = @model.Intermediary; userToRegister = newIntermediaryUser; roleToAdd = new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <zAppDev.DotNet.Framework.Identity.Model.ApplicationRole>((a) => a.Name == "Intermediary").ToList(); } if ((new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Get <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>((a) => a.UserName == @model.UserName)).Count() > 0) { ClientCommand(ClientCommands.SHOW_MESSAGE, "Please choose a different Username", MessageType.Warning); return(null); } string error = zAppDev.DotNet.Framework.Identity.IdentityHelper.CreateUser(userToRegister, @model.PasswordTextBox); if ((((error == null || error == "")) == false)) { ClientCommand(ClientCommands.SHOW_MESSAGE, error, MessageType.Warning); return(null); } string code = zAppDev.DotNet.Framework.Identity.IdentityHelper.GetUserManager().GenerateEmailConfirmationTokenAsync(userToRegister.UserName).Result; string link = (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"]) ? System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"] : zAppDev.DotNet.Framework.Utilities.Web.GetApplicationPathUri(false)) + "/EmailConfirmation/Confirm" + "?email=" + System.Web.HttpUtility.UrlEncode((userToRegister?.Email ?? "")) + "&code=" + System.Web.HttpUtility.UrlEncode(code); zAppDev.DotNet.Framework.Utilities.EMailMessage emailMessage = new zAppDev.DotNet.Framework.Utilities.EMailMessage(); emailMessage.To = new List <string> { (userToRegister?.Email ?? "") }.ToList(); emailMessage.Subject = "Account Activation"; emailMessage.Body = "Please click <a href='" + link + "'>here</a> to activate your account"; emailMessage.IsBodyHtml = true; zAppDev.DotNet.Framework.Utilities.Email.SendMail(emailMessage, true); userToRegister.Roles = roleToAdd.ToList(); new DSS5_SupplyChainFinancialsOptimisation.DAL.Repository().Save <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>(userToRegister); ClientCommand(ClientCommands.SHOW_MESSAGE, "Please activate your account using the link sent to your email.", MessageType.Success, (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"]) ? System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"] : zAppDev.DotNet.Framework.Utilities.Web.GetApplicationPathUri(false)) + "/HomePage/Render"); return(_result); }