public ActionResult CreateUser(FormCollection form)
        {
            var firstNameList = form[nameof(UserDTO.FirstName)].Split(char.Parse(","));
            var lastNameList  = form[nameof(UserDTO.LastName)].Split(char.Parse(","));
            var cellphoneList = form[nameof(UserDTO.Cellphone)].Split(char.Parse(","));
            var lstUserDTO    = new List <UserDTO>();

            for (int i = 0; i < firstNameList.Length; i++)
            {
                lstUserDTO.Add(new UserDTO
                {
                    FirstName = firstNameList[i].Trim(),
                    LastName  = lastNameList[i].Trim(),
                    Cellphone = cellphoneList[i].Trim()
                });
            }
            var addUserResponse = ServiceWrapperHelper.AddUsers(lstUserDTO);

            if (!addUserResponse.HasExceptions)
            {
                TempData.ToastSuccess("User(s) Added Successfully!");
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData.ToastError(addUserResponse.ExceptionMessage);
                ModelState.AddModelError("CreateUserError", addUserResponse.ExceptionMessage);
                return(View(lstUserDTO));
            }
        }
        public ActionResult EditUser(string userId)
        {
            var convertedUserId            = Convert.ToInt32(Security.Decrypt(userId));
            var getUserByIdServiceResponse = ServiceWrapperHelper.GetUserById(convertedUserId);
            var userDTODeserializeObject   = JsonConvert.DeserializeObject <UserDTO>(getUserByIdServiceResponse.Data.ToString());

            if (!getUserByIdServiceResponse.HasExceptions)
            {
                return(PartialView("~/Views/Users/_EditUserDetails.cshtml", userDTODeserializeObject));
            }
            else
            {
                return(PartialView("~/Views/Users/_ExceptionView.cshtml", getUserByIdServiceResponse.ExceptionMessage));
            }
        }
        public ActionResult DeleteUser(UserDTO userDto)
        {
            var getUserByIdServiceResponse = ServiceWrapperHelper.DeleteUser(userDto.UserId);

            if (getUserByIdServiceResponse.HasExceptions)
            {
                TempData.ToastError(getUserByIdServiceResponse.ExceptionMessage);
                ModelState.AddModelError("UpdateUser", getUserByIdServiceResponse.ExceptionMessage);
            }
            else
            {
                TempData.ToastSuccess("User Deleted Successfully.");
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult EditUser(UserDTO userDto)
        {
            var updateUserResponse = ServiceWrapperHelper.UpdateUser(new UserDTO
            {
                Cellphone = userDto.Cellphone.Trim(),
                FirstName = userDto.FirstName.Trim(),
                LastName  = userDto.LastName.Trim(),
                UserId    = userDto.UserId
            });

            if (updateUserResponse.HasExceptions)
            {
                TempData.ToastError(updateUserResponse.ExceptionMessage);
                ModelState.AddModelError("UpdateUser", updateUserResponse.ExceptionMessage);
            }
            else
            {
                TempData.ToastSuccess("User Details Updated Successfully!");
            }
            return(RedirectToAction("Index"));
        }