Пример #1
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                if (id > 0)
                {
                    _result = await _iAddressManager.DeleteAddressEntityAsync(id);
                }
                else
                {
                    _result = Result.Fail(MessageHelper.DeleteFail);
                }

                if (_result.Success)
                {
                    this.FlashSuccess(MessageHelper.Delete, "AddressMessage");
                }
                else
                {
                    this.FlashError(_result.Error, "AddressMessage");
                }
                return(JsonResult(_result));
            }
            catch (Exception ex)
            {
                _log.Error(LogMessageHelper.FormateMessageForException(ex, "Delete[POST]"));
                _result = Result.Fail(MessageHelper.UnhandelledError);
                return(JsonResult(_result));
            }
        }
        public async Task <IActionResult> DeleteAddress(int id)
        {
            Result result = new Result();

            try
            {
                _log.Info(LogMessageHelper.FormateMessageForStart("DeleteAddress[POST]"));

                if (id > 0)
                {
                    result = await _iAddressManager.DeleteAddressEntityAsync(id);
                }
                else
                {
                    result = Result.Fail(MessageHelper.DeleteFail);
                }

                if (result.Success)
                {
                    return(Ok(result));
                }
                else
                {
                    return(BadRequest(result));
                }
            }
            catch (Exception ex)
            {
                _log.Error(LogMessageHelper.FormateMessageForException(ex, "DeleteAddress[POST]"));
                result = Result.Fail(MessageHelper.UnhandelledError);
                return(BadRequest(result));
            }

            return(BadRequest(MessageHelper.NullReferenceExceptionError));
        }