Example #1
0
        public async Task BlackListMember(int MemberId, int Days)
        {
            if (_DiscoContext != null)
            {
                try
                {
                    Member member = await _DiscoContext.Members.Where(e => e.MemberId == MemberId).FirstOrDefaultAsync();

                    BlackListLog blackListLog = new BlackListLog();

                    blackListLog.BlackListDate = DateTime.Now.AddDays(Days);

                    List <BlackListLog> _lb = new List <BlackListLog>();
                    _lb.Add(blackListLog);

                    member.BlackListLogs = _lb;

                    _DiscoContext.Update(member);

                    await _DiscoContext.SaveChangesAsync();
                }
                catch (Exception e)
                {
                    // return null;
                }
            }
        }
Example #2
0
        public async Task <BlackListLog> BlacklistCheck(int MemberId)
        {
            try
            {
                BlackListLog BlacLlog = await _DiscoContext.BlackListLogs.Where(e => e.Member.MemberId == MemberId && e.BlackListDate > DateTime.Now).OrderByDescending(e => e.BlackId).FirstOrDefaultAsync(); //.OrderByDescending(e=>e.BlackId).FirstOrDefaultAsync();

                if (BlacLlog != null)
                {
                    if (BlacLlog.BlackListDate > DateTime.Now)
                    {
                        return(BlacLlog);
                    }
                }
                return(null);
            }
            catch (Exception ex)
            {
                //log exception
                return(null);
            }
        }
Example #3
0
        public async Task <IActionResult> BlacklistCheck(int MemberId)
        {
            try
            {
                BlackListLog mem = await _discoRepository.BlacklistCheck(MemberId);

                if (mem != null)
                {
                    return(Ok("Member blacklisted"));
                }
                else
                {
                    return(Ok("Member allowed"));
                }
            }
            catch (Exception ex)
            {
                //log exception
                return(BadRequest());
            }
        }