示例#1
0
        //public void Update(int userId, ConferenceDto conferenceDto)
        //{
        //    if (CheckUserPermission(userId))
        //    {
        //        var conference = _mapper.Map<Conference>(conferenceDto);

        //        _conferenceRepository.Update(conference);
        //    }
        //    else
        //        throw new NotEnoughRightsException();
        //}

        /// <summary>
        /// Only creator, section's expert, conf's admin
        /// </summary>
        private bool CheckUserPermission(int userId, Application app, Conference conf)
        {
            if (app.UserId == userId)
            {
                return(true);
            }

            if (_sectionExpertRepository.GetFirstOrDefault(e => e.UserId == userId && e.SectionId == app.SectionId) != null)
            {
                return(true);
            }

            if (conf.Sections.Any(s => s.Id == app.SectionId) &&
                _adminOfConferenceRepository
                .GetFirstOrDefault(a => a.UserId == userId && a.ConferenceId == conf.Id) != null)
            {
                return(true);
            }

            return(false);
        }
 private bool CheckUserUpdatePermission(int userId, int conferenceId)
 {
     //todo rewrite Any
     return(_adminOfConferenceRepository.GetFirstOrDefault(a => a.UserId == userId && a.ConferenceId == conferenceId) !=
            null);
 }