コード例 #1
0
        public async Task <OperationReturnModel <ListImportModel> > List()
        {
            OperationReturnModel <ListImportModel> ret = new OperationReturnModel <ListImportModel>();

            try
            {
                var importReturn = new ListImportModel();

                ListImportFileModel fileModel = await ImportHelper.GetFileFromContent(Request.Content);

                ListModel newList     = _importService.BuildList(this.AuthenticatedUser, this.SelectedUserContext, fileModel);
                ListModel createdList = _listService.CreateList(AuthenticatedUser, SelectedUserContext, ListType.Custom, newList);

                importReturn.List = _listService.ReadList(this.AuthenticatedUser, this.SelectedUserContext, createdList.Type, createdList.ListId, true);

                _cacheListLogic.RemoveSpecificCachedList(new ListModel()
                {
                    BranchId       = SelectedUserContext.BranchId,
                    CustomerNumber = SelectedUserContext.CustomerId,
                    ListId         = createdList.ListId,
                    Type           = createdList.Type
                });

                _cacheListLogic.ClearCustomersListCaches(this.AuthenticatedUser, this.SelectedUserContext, _listService.ReadUserList(this.AuthenticatedUser, this.SelectedUserContext, true));

                importReturn.List = _listService.ReadList(this.AuthenticatedUser, this.SelectedUserContext, createdList.Type, createdList.ListId, true);

                importReturn.Success        = true;
                importReturn.WarningMessage = _importService.Warnings;
                importReturn.ErrorMessage   = _importService.Errors;
                ret.SuccessResponse         = importReturn;
                ret.IsSuccess = true;
            }
            catch (Exception ex)
            {
                ret.IsSuccess    = false;
                ret.ErrorMessage = ex.Message;
                _log.WriteErrorLog("Import List", ex);
            }
            return(ret);
        }