public async Task <OperationResult <bool> > CreateAsync(ReservedQueue item)
        {
            try
            {
                var reserveList = await _dao.ListAsync();

                var reserveCountToday    = reserveList.Count(x => x.ProfileId == item.ProfileId && x.CreatedAt.Day == DateTime.UtcNow.Day && !x.IsDeleted && x.CreatedAt.AddHours(2) > DateTime.UtcNow);
                var reserveCancelledList = await _dao.ListAsync();

                var reserveCancelationCountToday = reserveCancelledList.Count(x => x.ProfileId == item.ProfileId && x.CreatedAt.Day == DateTime.UtcNow.Day && x.IsDeleted);
                if (reserveCountToday > 0 || reserveCancelationCountToday == 2)
                {
                    return new OperationResult <bool>()
                           {
                               Success = true, Result = false, Message = "Daily limit reached"
                           }
                }
                ;
                await _dao.CreateAsync(item);

                return(new OperationResult <bool>()
                {
                    Success = true, Result = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult <bool>()
                {
                    Success = false, Exception = e
                });
            }
        }
Пример #2
0
        public async Task <OperationResult> CreateAsync(ReservedQueue item)
        {
            try
            {
                await _dao.CreateAsync(item);

                return(new OperationResult()
                {
                    Success = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult()
                {
                    Success = false, Exception = e
                });
            }
        }