internal bool Insert(IConnectionHandler connectionHandler1, IConnectionHandler enterpriseNodeconnection, Referee referee, System.Web.HttpPostedFileBase fileBase = null, List <Guid> pivots = null) { var id = referee.Id; BOUtility.GetGuidForId(ref id); referee.Id = id; referee.EnterpriseNode.Id = referee.Id; if (Any(connectionHandler1, x => x.EnterpriseNode.Email == referee.EnterpriseNode.Email && x.CongressId == referee.CongressId)) { throw new Exception(Resources.Congress.RefereeEmailIsRepeat); } if (Any(connectionHandler1, x => x.Username == referee.Username.ToLower() && x.CongressId == referee.CongressId)) { throw new Exception(Resources.Congress.RefereeUserNameIsRepeat); } if (!EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(enterpriseNodeconnection).Insert(referee.EnterpriseNode, fileBase)) { throw new Exception(Resources.Congress.ErrorInSaveReferee); } if (!string.IsNullOrEmpty(referee.Password)) { referee.Password = StringUtils.HashPassword(referee.Password); } if (!base.Insert(connectionHandler1, referee)) { throw new Exception(Resources.Congress.ErrorInSaveReferee); } var refereePivotBo = new RefereePivotBO(); refereePivotBo.Insert(connectionHandler1, referee.Id, pivots); return(true); }
public Dictionary <Referee, bool> Search(IConnectionHandler connectionHandler, string txt, Guid pivotId, Guid congressId) { var predicateBuilder = new PredicateBuilder <Referee>(); predicateBuilder.And(x => x.CongressId == congressId); if (!string.IsNullOrEmpty(txt)) { var txtSearch = txt.ToLower(); predicateBuilder.And((x => x.Username.Contains(txtSearch) || x.EnterpriseNode.RealEnterpriseNode.FirstName.Contains(txtSearch) || x.EnterpriseNode.RealEnterpriseNode.LastName.Contains(txtSearch) || x.EnterpriseNode.RealEnterpriseNode.NationalCode.Contains(txtSearch) || x.EnterpriseNode.RealEnterpriseNode.IDNumber.Contains(txtSearch) || x.EnterpriseNode.Address.Contains(txtSearch) || x.EnterpriseNode.Website.Contains(txtSearch) || x.EnterpriseNode.Email.Contains(txtSearch) || x.EnterpriseNode.Tel.Contains(txtSearch))); } var dictionary = new Dictionary <Referee, bool>(); var byFilter = new RefereePivotBO().Select(connectionHandler, x => x.RefereeId, x => x.PivotId == pivotId); var list = new RefereeBO().Where(connectionHandler, predicateBuilder.GetExpression()); foreach (var referee in list) { if (dictionary.Any(x => x.Key.Id == referee.Id)) { continue; } var added = byFilter.Any(x => x.Equals(referee.Id)); dictionary.Add(referee, added); } return(dictionary); }
internal bool Update(IConnectionHandler connectionHandler1, IConnectionHandler enterpriseNodeconnection, Referee referee, System.Web.HttpPostedFileBase fileBase = null, List <Guid> pivots = null) { var enterpriseNodeTransactionalFacade = EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(enterpriseNodeconnection); var node = enterpriseNodeTransactionalFacade.Get(referee.Id); var referee1 = this.Get(connectionHandler1, referee.Id); if (node != null && node.Email.ToLower() != referee.EnterpriseNode.Email.ToLower() && Any(connectionHandler1, x => x.EnterpriseNode.Email == referee.EnterpriseNode.Email && x.CongressId == referee.CongressId && x.Id != referee1.Id)) { throw new Exception(Resources.Congress.YouhavealreadyregisteredCongress); } if (referee1 != null && referee1.Username.ToLower() != referee.Username.ToLower() && Any(connectionHandler1, x => x.Username == referee.Username.ToLower() && x.CongressId == referee.CongressId && x.Id != referee.Id)) { throw new Exception(Resources.Congress.UserNameIsRepeate); } if (!enterpriseNodeTransactionalFacade.Update(referee.EnterpriseNode, fileBase)) { throw new Exception(Resources.Congress.ErrorInEditReferee); } if (!base.Update(connectionHandler1, referee)) { throw new Exception(Resources.Congress.ErrorInEditReferee); } var refereePivotBo = new RefereePivotBO(); refereePivotBo.Update(connectionHandler1, referee.Id, pivots); return(true); }