Пример #1
0
        /// <summary>
        /// Adds a New UserType
        /// Level: Logic
        /// </summary>
        /// <param name="UserType">The UserType</param>
        /// <returns>True if Successful, False if Not</returns>
        public bool AddUserType(string UserType)
        {
            try
            {
                UserTypesRepository myRepository = new UserTypesRepository();

                if (!myRepository.UserTypeExists(UserType))
                {
                    Common.UserType myUserType = new UserType();

                    myUserType.Type = UserType;

                    myRepository.AddUserType(myUserType);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
Пример #2
0
        /// <summary>
        /// Updates a UserType
        /// Level: Logic
        /// </summary>
        /// <param name="UserTypeID">The UserTypeID</param>
        /// <param name="UserType">The UserType</param>
        /// <returns>UserTypeUpdate Enum</returns>
        public UserTypeUpdate UpdateUserType(int UserTypeID, string UserType)
        {
            try
            {
                UserTypesRepository myRepository = new UserTypesRepository();

                if (myRepository.UserTypeIsRetailerOrWholesaler(UserTypeID))
                {
                    return(UserTypeUpdate.LockedUserType);
                }
                else if (myRepository.UserTypeExists(UserType))
                {
                    return(UserTypeUpdate.SameUserType);
                }
                else
                {
                    myRepository.UpdateUserType(UserTypeID, UserType);
                    return(UserTypeUpdate.Successful);
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }