예제 #1
0
        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
        /// <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
        /// <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
        /// <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);
        }