Example #1
0
        /// <summary>
        /// Level: Logic
        /// </summary>
        /// <param name="UserTypeID">The UserTypeID</param>
        /// <returns>UserTypeDelete Enum</returns>
        public UserTypeDelete DeleteUserType(int UserTypeID)
        {
            try
            {
                UserTypesRepository myRepository = new UserTypesRepository();

                if (myRepository.UserTypeIsRetailerOrWholesaler(UserTypeID))
                {
                    return(UserTypeDelete.LockedUserType);
                }
                else if (myRepository.UserTypeHasUsers(UserTypeID))
                {
                    return(UserTypeDelete.HasUsers);
                }
                else
                {
                    myRepository.DeleteUserType(UserTypeID);
                    return(UserTypeDelete.Successful);
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
Example #2
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;
            }
        }
Example #3
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;
            }
        }
Example #4
0
 public SelectList GetUserTypesAndSelect(string currentType)
 {
     using (var userTypesRepository = new UserTypesRepository(new MyTubeDBEntities()))
     {
         var userType = userTypesRepository.GetUserTypes();
         return(new SelectList(userType, "TypeName", "TypeName", currentType));
     }
 }
Example #5
0
        public IHttpActionResult UpdateUserTypeStatus([FromBody] UserTypes usertype)
        {
            var usertypeRepo = new UserTypesRepository();
            var result       = usertypeRepo.UpdateUserTypeStatus(usertype);

            if (result <= 0)
            {
                return(Ok("Error occurred while updating the user type status"));
            }
            return(Ok("User Type Status updated"));
        }
Example #6
0
        public IHttpActionResult GetUserType([FromBody] UserTypes usertype)
        {
            var usertypeRepo = new UserTypesRepository();
            var getusertype  = usertypeRepo.GetUserType(usertype);

            if (getusertype == null)
            {
                return(NotFound());
            }
            return(Ok(getusertype));
        }
Example #7
0
        // GET: api/UserType
        public IHttpActionResult GetAllUserTypes()
        {
            var usertypeRepo  = new UserTypesRepository();
            var usertypesList = usertypeRepo.GetAllUserTypes();

            if (usertypesList == null || usertypesList.Count == 0)
            {
                return(NotFound());
            }

            return(Ok(usertypesList));
        }