public bool Insert(User user1, HttpPostedFileBase file, List <Guid> list) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.SecurityConnection.StartTransaction(IsolationLevel.ReadUncommitted); if (!new SecurityUserBO().Insert(this.ConnectionHandler, this.SecurityConnection, user1, file, list)) { throw new Exception("خطایی در ذخیره کاربر وجود دارد"); } this.ConnectionHandler.CommitTransaction(); this.SecurityConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.SecurityConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.SecurityConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public ActionResult Create(FormCollection collection) { try { var user = new User() { EnterpriseNode = new Radyn.EnterpriseNode.DataStructure.EnterpriseNode { RealEnterpriseNode = new RealEnterpriseNode() } }; this.RadynTryUpdateModel(user); this.RadynTryUpdateModel(user.EnterpriseNode); this.RadynTryUpdateModel(user.EnterpriseNode.RealEnterpriseNode); HttpPostedFileBase file = null; if (Session["Image"] != null) { file = (HttpPostedFileBase)Session["Image"]; Session.Remove("Image"); } var list = new List <Guid>(); var firstOrDefault = collection.AllKeys.FirstOrDefault(s => s.Equals("SelectedCongress")); if (!string.IsNullOrEmpty(firstOrDefault)) { var strings = collection[firstOrDefault].Split(','); foreach (var s in strings) { if (string.IsNullOrEmpty(s)) { continue; } list.Add(s.ToGuid()); } } if (CongressComponent.Instance.BaseInfoComponents.SecurityUserFacade.Insert(user, file, list)) { ShowMessage(Resources.Common.InsertSuccessMessage, Resources.Common.MessaageTitle, new[] { Resources.Common.Ok, " window.location='" + Radyn.Web.Mvc.UI.Application.CurrentApplicationPath + "/Congress/SecurityUser/Index';" }, messageIcon: MessageIcon.Succeed); return(Content("true")); } ShowMessage(Resources.Common.ErrorInInsert, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Error); return(Content("false")); } catch (Exception exception) { ShowExceptionMessage(exception); return(Content("false")); } }
public ActionResult Validate(FormCollection collection) { var messageStack = new List <string>(); var Id = collection["Id"].ToGuid(); var user = new User(); var enterpriseNode = new Radyn.EnterpriseNode.DataStructure.EnterpriseNode { RealEnterpriseNode = new RealEnterpriseNode() }; this.RadynTryUpdateModel(user); this.RadynTryUpdateModel(enterpriseNode); this.RadynTryUpdateModel(enterpriseNode.RealEnterpriseNode); if (string.IsNullOrEmpty(user.Username)) { messageStack.Add(Resources.Congress.PleaseInsertUserName); } if (Id == Guid.Empty) { if (string.IsNullOrEmpty(user.Password)) { messageStack.Add(Resources.Congress.Please_Enter_Password); } if (string.IsNullOrEmpty(collection["RepeatPassword"])) { messageStack.Add(Resources.Congress.Please_Enter_Password_Repeat); } else if (!string.IsNullOrEmpty(user.Password) && !string.IsNullOrEmpty(collection["RepeatPassword"])) { if (user.Password != collection["RepeatPassword"]) { messageStack.Add(Resources.Congress.Password_and_Repeat_Not_Equal); } } } else { if (!string.IsNullOrEmpty(user.Password)) { if (string.IsNullOrEmpty(collection["RepeatPassword"])) { messageStack.Add(Resources.Congress.Please_Enter_Password_Repeat); } else if (!string.IsNullOrEmpty(user.Password) && !string.IsNullOrEmpty(collection["RepeatPassword"])) { if (user.Password != collection["RepeatPassword"]) { messageStack.Add(Resources.Congress.Password_and_Repeat_Not_Equal); } } } } if (user.Password != null && !string.IsNullOrEmpty(user.Password) && user.Password.Length < 6) { messageStack.Add(Resources.Congress.MinimumPasswordCharacter); } var list = new List <Guid>(); var firstOrDefault = collection.AllKeys.FirstOrDefault(s => s.Equals("SelectedCongress")); if (!string.IsNullOrEmpty(firstOrDefault)) { var strings = collection[firstOrDefault].Split(','); foreach (var s in strings) { if (string.IsNullOrEmpty(s)) { continue; } list.Add(s.ToGuid()); } } if (!list.Any()) { messageStack.Add("لطفا همایشی را انتخاب کنید"); } var messageBody = messageStack.Aggregate("", (current, item) => current + Tag.Li(item)); if (messageBody != "") { ShowMessage(messageBody, Resources.Common.Attantion, messageIcon: MessageIcon.Warning); return(Content("false")); } return(Content("true")); }