public async Task <IActionResult> UpdateAdminAgentUsersAsync(
            [FromBody, SwaggerParameter("Model containing the details of the User to update", Required = true)] AdminAgentUserViewModel users)
        {
            int result = await _userBusiness.UpdateAdminAgentUsersAsync(users);

            return(commonMethods.GetResultMessages(result, MethodType.Update));
        }
        /// <summary>
        /// add the admin or agent user
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public async Task <int> AddAdminAgentUsersAsync(AdminAgentUserViewModel user)
        {
            if (string.IsNullOrEmpty(user.UserName) || user.Password == null || user.Name == null || user.MobileNo == null)
            {
                return((int)StatusCode.ExpectationFailed);
            }

            var existingTemplate = await _userRepository.SelectAsync(u => u.UserName == user.UserName || u.MobileNo == user.MobileNo);

            if (existingTemplate.Any())
            {
                return((int)StatusCode.ConflictStatusCode);
            }

            var userTypes = new List <UserTypes>();

            if (user.IsAdmin == false && user.IsAgent == true && user.IsOperator == false)
            {
                userTypes = (await _userTypesRepository.SelectAsync(u => u.UserType == UserTypesConstants.Agent)).ToList();
            }
            else if (user.IsAdmin == true && user.IsAgent == false && user.IsOperator == false)
            {
                userTypes = (await _userTypesRepository.SelectAsync(u => u.UserType == UserTypesConstants.Admin)).ToList();
            }
            else if (user.IsAdmin == false && user.IsAgent == false && user.IsOperator == true)
            {
                userTypes = (await _userTypesRepository.SelectAsync(u => u.UserType == UserTypesConstants.Operator)).ToList();
            }

            var newuser = new Users();

            newuser.UserId           = Guid.NewGuid();
            newuser.UserName         = user.UserName;
            newuser.Password         = Convert.ToString(EncryptionandDecryption.Encrypt(user.Password));
            newuser.Name             = user.Name;
            newuser.MobileNo         = user.MobileNo;
            newuser.Address          = user.Address;
            newuser.Email            = user.Email;
            newuser.CreatedAt        = DateTime.UtcNow;
            newuser.UserTypeId       = userTypes[0].UserTypeId;
            newuser.DateOfBirth      = user.DateOfBirth;
            newuser.AadharNo         = user.AadharNo;
            newuser.DrivingLicenceNo = user.DrivingLicenceNo;


            await _userRepository.AddAsync(newuser);

            await _userRepository.Uow.SaveChangesAsync();

            return((int)StatusCode.SuccessfulStatusCode);
        }
        /// <summary>
        /// update admin and agent users
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public async Task <int> UpdateAdminAgentUsersAsync(AdminAgentUserViewModel user)
        {
            if (string.IsNullOrEmpty(user.UserName) || user.Password == null || user.Name == null || user.MobileNo == null)
            {
                return((int)StatusCode.ExpectationFailed);
            }

            var existingTemplate = await _userRepository.SelectAsync(u => u.UserId == user.UserId);

            if (existingTemplate.Any())
            {
                var existingMobile = await _userRepository.SelectAsync(u => u.MobileNo == user.MobileNo && u.UserId != user.UserId);

                if (existingMobile.Any())
                {
                    return((int)StatusCode.ConflictStatusCode);
                }

                existingTemplate[0].Password  = Convert.ToString(EncryptionandDecryption.Encrypt(user.Password));
                existingTemplate[0].Name      = user.Name;
                existingTemplate[0].MobileNo  = user.MobileNo;
                existingTemplate[0].Address   = user.Address;
                existingTemplate[0].Email     = user.Email;
                existingTemplate[0].CreatedAt = DateTime.UtcNow;

                await _userRepository.UpdateAsync(existingTemplate[0]);

                await _userRepository.Uow.SaveChangesAsync();

                return((int)StatusCode.SuccessfulStatusCode);
            }
            else
            {
                return((int)StatusCode.NoContent);
            }
        }