Beispiel #1
0
        public Task <int> GetDefaultMpId()
        {
            var currUserId = _abpSession.UserId;

            if (currUserId != null)
            {
                return(_cacheManager.GetCache(AppConsts.Cache_CurrentUserMp).GetAsync(currUserId, async() =>
                {
                    int i = 0;

                    var model = await Repository.FirstOrDefaultAsync(c => c.UserId == currUserId);
                    if (model == null)
                    {
                        var account = _mpAccountAppService.GetFirstOrDefault();
                        var resultModel = new UserMpDto {
                            UserId = currUserId, CurrentMpID = account.Id
                        };
                        var result = await base.Create(resultModel);
                        i = result.CurrentMpID;
                    }
                    else
                    {
                        i = model.CurrentMpID;
                    }


                    return i;
                }));
            }
            else
            {
                return(null);
            }
        }