Ejemplo n.º 1
0
 public WebPortalVM()
 {
     IsModify      = true;
     IsButtonPanel = Resources.MsgHidden;
     isVisibleInfo = Resources.MsgHidden;
     LoadUsers(null);
     View_Click(null);
     RegisterDelegates();
     currentView = new WebPortalUsersView();
     AcceptChanges();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Function to cancel an action.
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>NA</returns>
 /// <createdBy></createdBy>
 /// <createdOn>May-27,2016</createdOn>
 public void Cancel_Click(object obj)
 {
     try
     {
         CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
         IsModify        = true;
         UserInfoEnabled = false;
         IsButtonPanel   = Resources.MsgHidden;
         IsVisibleInfo   = Resources.MsgHidden;
         if (ListCustomer == null)
         {
             FillCustomers(0);
         }
         if (ListModule == null)
         {
             FillModules(0);
         }
         if (ListRole == null)
         {
             FillRoles(0);
         }
         if (ListGroup == null)
         {
             FillGroups(0);
         }
         ClearUserInfo();
         View_Click(null);
         CurrentView = new WebPortalUsersView();
         AcceptChanges();
     }
     catch (Exception ex)
     {
         CommonSettings.logger.LogError(this.GetType(), ex);
     }
     finally
     {
         CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Function to Save/Update a particular user.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>NA</returns>
        /// <createdBy></createdBy>
        /// <createdOn>May-27,2016</createdOn>
        public void Save_Click(object obj)
        {
            try
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                WebPortalUserList objUserProp = new WebPortalUserList();

                if (UserID != null && UserID > 0)
                {
                    objUserProp.userID = (int)UserID;
                }

                objUserProp.username    = UserName;
                objUserProp.password    = Password;
                objUserProp.firstname   = FirstName;
                objUserProp.lastname    = LastName;
                objUserProp.email       = Email;
                objUserProp.phone       = Phone;
                objUserProp.isActive    = IsActive;
                objUserProp.isSuperUser = 0;
                objUserProp.lastLogin   = DateTime.Now;
                if (IsAction == Resources.ActionSave)
                {
                    objUserProp.whoCreated  = Application.Current.Properties["LoggedInUserName"].ToString();
                    objUserProp.dateCreated = DateTime.Now;
                }
                else if (IsAction == Resources.ActionUpdate)
                {
                    objUserProp.whoModified  = Application.Current.Properties["LoggedInUserName"].ToString();
                    objUserProp.dateModified = DateTime.Now;
                }

                if (!string.IsNullOrEmpty(UserName))
                {
                    if (!string.IsNullOrEmpty(Password))
                    {
                        if (!string.IsNullOrEmpty(Email))
                        {
                            ValidateEmail emailValidation = new ValidateEmail();
                            bool          isValid         = emailValidation.IsValidEmail(Email);
                            if (isValid)
                            {
                                bool checkDuplicateUserName = _serviceInstance.CheckDuplicateEmail(Email);
                                bool checkDuplicateEmailID  = _serviceInstance.CheckDuplicatePortalUserName(UserName);
                                bool isSuccessfull          = false;
                                if (IsAction == Resources.ActionSave)
                                {
                                    if (!checkDuplicateUserName)
                                    {
                                        if (!checkDuplicateEmailID)
                                        {
                                            isSuccessfull = _serviceInstance.InsertUpdateUser(objUserProp, ListCustomer.ToArray(), ListModule.ToArray(), ListRole.ToArray(), ListGroup.ToArray());
                                        }
                                        else
                                        {
                                            MessageBox.Show(Resources.MsgDuplicateUserName);
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show(Resources.MsgDuplicateEmailID);
                                    }
                                }
                                else if (IsAction == Resources.ActionUpdate)
                                {
                                    isSuccessfull = _serviceInstance.InsertUpdateUser(objUserProp, ListCustomer.ToArray(), ListModule.ToArray(), ListRole.ToArray(), ListGroup.ToArray());
                                }

                                if (isSuccessfull)
                                {
                                    if (IsAction == Resources.ActionUpdate)
                                    {
                                        MessageBox.Show(Resources.msgUpdatedSuccessfully);
                                    }
                                    else if (IsAction == Resources.ActionSave)
                                    {
                                        MessageBox.Show(Resources.msgInsertedSuccessfully);
                                    }
                                    ClearUserInfo();
                                    CurrentView   = new WebPortalUsersView();
                                    IsVisibleInfo = Resources.MsgHidden;
                                    IsModify      = true;
                                    IsButtonPanel = Resources.MsgHidden;
                                    IsAction      = Resources.ActionSave;
                                    LoadUsers(null);
                                    View_Click(null);
                                    AcceptChanges();
                                }
                            }
                            else
                            {
                                MessageBox.Show(Resources.ErrorEmail);
                            }
                        }
                        else
                        {
                            MessageBox.Show(Resources.ReqEmail);
                        }
                    }
                    else
                    {
                        MessageBox.Show(Resources.ReqPassword);
                    }
                }
                else
                {
                    MessageBox.Show(Resources.ReqrUserName);
                }
            }
            catch (Exception ex)
            {
                CommonSettings.logger.LogError(this.GetType(), ex);
            }
            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }