public virtual void OrganisationPendingUserDelete(OrganisationPendingUser entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdOrganisationPendingUserDelete(entity.ID);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
        protected void btnGetRight_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
              {
            return;
              }

              string selectedOrgId = Request["selectedOrgId"];

              //elmentjük a kérést ...
              IOrganisationPendingUserService srvOrgPendingUser = ServiceFactory.GetOrganisationPendingUserService();
              OrganisationPendingUser item = new OrganisationPendingUser(Guid.NewGuid());

              item.Right = "W"; //Írási jog kérése
              item.SentDate = DateTime.Now;
              item.Status = RegistrationStatus.New;
              item.LoginNameRef = Context.User.Identity.Name;
              item.OrganisationRef = new Guid(selectedOrgId);

              srvOrgPendingUser.OrganisationPendingUserInsert(item);

              Response.Redirect("RegisterFinish.aspx?from=getWriteRight");
        }
        public OrganisationPendingUserContainer OrganisationPendingUserSelectFiltered(OrganisationPendingUser filter)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            OrganisationPendingUserContainer result;
            DataSet entitySet = new DataSet();

            entitySet = m_DataContext.ndihdOrganisationPendingUserSelectFiltered(
              filter.OrganisationRef, filter.LoginNameRef, filter.Right, filter.Status);

            result = new OrganisationPendingUserContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public bool OrganisationPendingUserReject(OrganisationPendingUser entity)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            if (entity.RejectComment.Length == 0)
              throw new ArgumentNullException("OrganisationPendingUser.RejectComment",
                                          "Az elutasítás indoklása nincs megadva.");

            // Logical checks
            OrganisationPendingUser selected = base.OrganisationPendingUserSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóhoznemtartozik igénylés.");
            if (! selected.Status.Equals(RegistrationStatus.New))
              throw new ApplicationException("Csak új státuszú regisztráció bírálható el.");

            // Set properties
            selected.DecidedBy = Thread.CurrentPrincipal.Identity.Name;
            selected.DecidedDate = DBDateTime.Now;
            selected.Status = RegistrationStatus.Rejected;
            selected.RejectComment = entity.RejectComment;

            //Emailben szereplõ adatok lekkérdezése
            string userEmail = "";
            string userFullName = "";
            string organisationName = "";
            IOrganisationPendingUserService srvOpu = new OrganisationPendingUserService();
            OrganisationPendingUser opu = srvOpu.OrganisationPendingUserSelect(entity.ID);
            IOrganisationService srvOrg = new OrganisationService();
            IUserService srvUser = new UserService();
            Organisation org = srvOrg.OrganisationSelect(opu.OrganisationRef);
            User u = srvUser.UserSelect(opu.LoginNameRef);

            userEmail = u.Email;
            userFullName = u.Name;
            organisationName = org.Name;

            //set mail:
            Email mail = new Email(Guid.NewGuid());
            mail.Category = EmailCategory.OrganisationRegistrationReject;
            mail.To = userEmail;

            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            IEmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.OrganisationRegistrationReject);

            mail.Subject = subject;

            body = body.Replace("<FULL_USER_NAME>", userFullName);
            body = body.Replace("<LOGIN_NAME>", u.LoginName);
            body = body.Replace("<ORGANISATION>", organisationName);
            body = body.Replace("<REJECT_COMMENT>", entity.RejectComment);
            mail.MailBody = body;

            // Save data to database
            EmailService emailSrv = new EmailService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              base.OrganisationPendingUserUpdate(selected);
              emailSrv.EmailInsert(mail);
              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            // Sending mail:
            try
            {
              emailSrv.EmailSend(mail.ID);
            }
            catch (Exception ex)
            {
              ExceptionManager.Publish(ex);
              return false;
            }

            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("RegisterOrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", organisationName),
              new EventParameter("LoginName", u.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return true;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("RegisterOrganisationID", entity.ID.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Fill datagrid with data
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void FillDatagrid(DBGuid ID)
        {
            try
              {
            string sortColumn = "SentDate";
            int selectedRow = -1;

            // storing the previous sort order
            if (dtgMain.DataSource != null)
            {
              sortColumn = ((DataTable) dtgMain.DataSource).DefaultView.Sort;
            }

            // retrieving data from BusinessServices
            IOrganisationPendingUserService srv = ServiceFactory.GetOrganisationPendingUserService();
            OrganisationPendingUser filter = new OrganisationPendingUser(Guid.Empty);

            if (cmbStatusFilter.SelectedIndex > 0)
            {
              filter.Status = cmbStatusFilter.SelectedValue.ToString();
            }

            OrganisationPendingUserContainer allData = srv.OrganisationPendingUserSelectFiltered(filter);
            DataTable dt = allData.AllAsDatatable;
            dt.DefaultView.Sort = sortColumn;
            dtgMain.DataSource = dt;

            // locates the row specified by ID param
            if (!ID.IsNull)
            {
              BindingManagerBase bm = dtgMain.BindingContext[dtgMain.DataSource, dtgMain.DataMember];
              DataRow dr;
              for (int i = 0; i < bm.Count; i++)
              {
            dr = ((DataRowView) bm.Current).Row;
            //if (  ((DBGuid)dr["ID"]).Value.Equals(ID) )
            if (ID.Value.Equals(dr["ID"]))
            {
              selectedRow = i;
              break;
            }
            bm.Position += 1;
              }
            }

            // makes the row selected
            if (selectedRow <= ((DataTable) dtgMain.DataSource).DefaultView.Count && selectedRow > -1)
            {
              dtgMain.Select(selectedRow);
              dtgMain.CurrentRowIndex = selectedRow;
            }
            else if (((DataTable) dtgMain.DataSource).DefaultView.Count != 0)
            {
              dtgMain.Select(0);
            }

            // enabling or disabling the buttons according to record count. And is because of previous disable state.
            tbbDecide.Enabled = (((DataTable) dtgMain.DataSource).DefaultView.Count != 0);
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba a lista frissítése során.", ex);
              }
        }
 public virtual void OrganisationPendingUserUpdate(OrganisationPendingUser entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       int count;
       m_DataContext.ndihdOrganisationPendingUserUpdate(entity.ID,
                                                    entity.OrganisationRef,
                                                    entity.LoginNameRef,
                                                    entity.Right,
                                                    entity.Status,
                                                    entity.SentDate,
                                                    entity.DecidedBy,
                                                    entity.DecidedDate,
                                                    entity.RejectComment, out count);
       if (count == 0) throw new ServiceUpdateException();
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
 public virtual OrganisationPendingUser OrganisationPendingUserSelect(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     OrganisationPendingUser result = null;
     DataSet entitySet = m_DataContext.ndihdOrganisationPendingUserSelect(IDVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new OrganisationPendingUser(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
        private void RejectRegistrationOrgPendingUser()
        {
            IOrganisationPendingUserService regSrv = ServiceFactory.GetOrganisationPendingUserService();
              OrganisationPendingUser opu = new OrganisationPendingUser(m_OrgPendingUserID);

              opu.RejectComment = txtRejectComment.Text;

              if (!regSrv.OrganisationPendingUserReject(opu))
              {
            MessageBox.Show("Az elutasítás megtörtént, de az értesítõ levél kiküldése nem sikerült.",
                        "NDI HelpDesk Administrator", MessageBoxButtons.OK, MessageBoxIcon.Warning);
              }
        }
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public OrganisationPendingUser(OrganisationPendingUser origInstance)
     : base(origInstance)
 {
 }
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="IDVal">Value of 'uID' field</param>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public OrganisationPendingUser(DBGuid IDVal,
                            OrganisationPendingUser origInstance)
     : base(IDVal, origInstance)
 {
 }