コード例 #1
0
ファイル: PlastDegreeService.cs プロジェクト: Toxa2202/plast
        private async Task SetDegreeAsCurrent(bool IsUserPlastDegreeCurrent)
        {
            if (IsUserPlastDegreeCurrent)
            {
                UserPlastDegree prevCurrentUserPlastDegree = await _repoWrapper.UserPlastDegrees.GetFirstOrDefaultAsync(upd => upd.IsCurrent);

                if (prevCurrentUserPlastDegree != null)
                {
                    prevCurrentUserPlastDegree.IsCurrent = false;
                    _repoWrapper.UserPlastDegrees.Update(prevCurrentUserPlastDegree);
                    await _repoWrapper.SaveAsync();
                }
            }
        }
コード例 #2
0
ファイル: PlastDegreeService.cs プロジェクト: Toxa2202/plast
        /// <inheritdoc />
        public async Task <bool> DeletePlastDegreeForUserAsync(string userId, int plastDegreeId)
        {
            bool            isDeleted       = false;
            UserPlastDegree userPlastDegree = await _repoWrapper.UserPlastDegrees
                                              .GetFirstOrDefaultAsync(upd => upd.PlastDegreeId == plastDegreeId && upd.UserId == userId);

            if (userPlastDegree != null)
            {
                _repoWrapper.UserPlastDegrees.Delete(userPlastDegree);
                await _repoWrapper.SaveAsync();

                isDeleted = true;
            }

            return(isDeleted);
        }
コード例 #3
0
ファイル: PlastDegreeService.cs プロジェクト: Toxa2202/plast
        /// <inheritdoc />
        public async Task <bool> AddEndDateForUserPlastDegreeAsync(UserPlastDegreePutDTO userPlastDegreePutDTO)
        {
            bool            isAdded         = false;
            UserPlastDegree userPlastDegree = await _repoWrapper.UserPlastDegrees
                                              .GetFirstOrDefaultAsync(upd => upd.PlastDegreeId == userPlastDegreePutDTO.PlastDegreeId && upd.UserId == userPlastDegreePutDTO.UserId);

            if (userPlastDegree != null)
            {
                userPlastDegree.DateFinish = userPlastDegreePutDTO.EndDate;
                _repoWrapper.UserPlastDegrees.Update(userPlastDegree);
                await _repoWrapper.SaveAsync();

                isAdded = true;
            }

            return(isAdded);
        }
コード例 #4
0
ファイル: PlastDegreeService.cs プロジェクト: Toxa2202/plast
        /// <inheritdoc />
        public async Task <bool> SetPlastDegreeForUserAsCurrentAsync(string userId, int plastDegreeId)
        {
            bool            isAdded         = false;
            UserPlastDegree userPlastDegree = await _repoWrapper.UserPlastDegrees
                                              .GetFirstOrDefaultAsync(upd => upd.PlastDegreeId == plastDegreeId && upd.UserId == userId);

            if (userPlastDegree != null)
            {
                await SetDegreeAsCurrent(true);

                userPlastDegree.IsCurrent = true;
                _repoWrapper.UserPlastDegrees.Update(userPlastDegree);
                await _repoWrapper.SaveAsync();

                isAdded = true;
            }

            return(isAdded);
        }