Example #1
0
        /// <summary>
        /// Updates the information.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        /// <exception cref="EntityNotFoundException">User id {model.UserId} not found</exception>
        /// <exception cref="FormatException">
        /// Address not nullable
        /// </exception>
        public async Task <bool> UpdateInfo(UserEditInfoModel model)
        {
            // TODO handle update email in user account, if google or facebook account don't allow update
            var user = _userProfileRepository.GetById(model.UserId);

            if (user == null)
            {
                throw new EntityNotFoundException($"User id {model.UserId} not found");
            }
            if (!ValidateUtils.IsNumber(model.Phone) || model.Phone.ToCharArray().Length != 10)
            {
                throw new FormatException($"{model.Phone} is wrong format");
            }

            if (ValidateUtils.IsNullOrEmpty(model.Address))
            {
                throw new FormatException($"Address not nullable");
            }

            if (model.Address != null)
            {
                user.Address = model.Address;
            }
            if (model.Phone != null)
            {
                user.Phone = model.Phone;
            }
            _userProfileRepository.Update(user);
            await _unitOfWork.CommitAsync();

            return(true);
        }
Example #2
0
        public static IList <NodeInfo> GetCachedNodeListByIds(string strIDs)
        {
            IList <NodeInfo> cacheAllNodes = Node.GetCacheAllNodes();
            IList <NodeInfo> list          = new List <NodeInfo>();

            string[] array = strIDs.Split(new char[]
            {
                ','
            });
            if (cacheAllNodes != null && cacheAllNodes.Count > 0)
            {
                foreach (NodeInfo current in cacheAllNodes)
                {
                    string[] array2 = array;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        string text = array2[i];
                        if (ValidateUtils.IsNumber(text) && current.AutoID.Equals(int.Parse(text)))
                        {
                            list.Add(current);
                        }
                    }
                }
            }
            return(list);
        }
Example #3
0
        /// <summary>
        /// Updates the phone.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="phone">The phone.</param>
        /// <returns></returns>
        /// <exception cref="EntityNotFoundException">User id {id} not found</exception>
        /// <exception cref="FormatException"></exception>
        public async Task <UserProfile> UpdatePhone(Guid id, string phone)
        {
            var user = _userProfileRepository.GetById(id);

            if (user == null)
            {
                throw new EntityNotFoundException($"User id {id} not found");
            }
            if (!ValidateUtils.IsNumber(phone) || phone.ToCharArray().Length != 10)
            {
                throw new FormatException($"{phone} is wrong format");
            }

            user.Phone = phone;
            _userProfileRepository.Update(user);
            await _unitOfWork.CommitAsync();

            return(user);
        }