public async Task <IActionResult> Save([Bind("TypeId,TypeName")] AddressTypePageViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var addressTypeViewModel = _iMapper.Map <AddressTypePageViewModel, AddressTypeViewModel>(viewModel);

                    //add
                    if (viewModel.TypeId == 0)
                    {
                        _result = await _iAddressTypeManager.InsertAddressTypeAsync(addressTypeViewModel);
                    }
                    else if (viewModel.TypeId > 0) //edit
                    {
                        _result = await _iAddressTypeManager.UpdateAddressTypeAsync(addressTypeViewModel);
                    }

                    return(JsonResult(_result));
                }
                else
                {
                    return(JsonResult(ModelState));
                }
            }
            catch (Exception ex)
            {
                return(JsonResult(ex));
            }
        }
        public async Task <IActionResult> Save(AddressTypeViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    //add
                    if (viewModel.TypeId == 0)
                    {
                        _result = await _iAddressTypeManager.InsertAddressTypeAsync(viewModel);
                    }
                    else if (viewModel.TypeId > 0) //edit
                    {
                        _result = await _iAddressTypeManager.UpdateAddressTypeAsync(viewModel);
                    }

                    if (_result.Success)
                    {
                        this.FlashSuccess(MessageHelper.Save, "AddressTypeMessage");
                        return(RedirectToAction("Index", "AddressType"));
                    }
                    else
                    {
                        this.FlashError(_result.Error, "AddressTypeMessage");
                        return(View(viewModel));
                    }
                }
                else
                {
                    this.FlashError(ExceptionHelper.ModelStateErrorFirstFormat(ModelState), "AddressTypeMessage");
                    return(View(viewModel));
                }
            }
            catch (Exception ex)
            {
                _log.Error(LogMessageHelper.FormateMessageForException(ex, "Save[POST]"));
            }

            this.FlashError(MessageHelper.UnhandelledError, "AddressTypeMessage");
            return(View(viewModel));
        }