Ejemplo n.º 1
0
        public async Task <bool> ActiveCode(BlockInputDto input)
        {
            var redeemCode = await _context.RedeemCodes.FindAsync(input.Id);

            if (redeemCode == null)
            {
                return(false);
            }
            var type = await _context.ProductTypes.FindAsync(redeemCode.TypeId);

            type.ActivatedCount             += 1;
            redeemCode.Status                = Domain.Enums.Status.Activated;
            redeemCode.UpdatedUserId         = input.UserId;
            redeemCode.UpdatedDate           = DateTime.Now;
            _context.Entry(type).State       = EntityState.Modified;
            _context.Entry(redeemCode).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RedeemCodeExists(input.Id))
                {
                    return(false);
                }
                else
                {
                    throw;
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <bool> > DeleteRedeemCode(BlockInputDto input)
        {
            var redeemCode = await _context.RedeemCodes.FindAsync(input.Id);

            if (redeemCode == null)
            {
                return(false);
            }
            redeemCode.DeletedDate           = DateTime.Now;
            redeemCode.DeletedUserId         = input.UserId;
            redeemCode.VirtualDeleted        = true;
            _context.Entry(redeemCode).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RedeemCodeExists(input.Id))
                {
                    return(false);
                }
                else
                {
                    throw;
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        public async Task <int> UnBlock(BlockInputDto input)
        {
            var customer = await _context.Customers.FindAsync(input.Id);

            if (customer == null)
            {
                return(0);
            }
            customer.Blocked               = false;
            customer.UpdatedUserId         = input.UserId;
            customer.UpdatedDate           = DateTime.Now;
            _context.Entry(customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(-1);
            }

            return(1);
        }
Ejemplo n.º 4
0
        public async Task <int> UnBlockCode(BlockInputDto input)
        {
            var redeemCode = await _context.RedeemCodes.FindAsync(input.Id);

            if (redeemCode == null)
            {
                return(0);
            }
            redeemCode.Status                = Domain.Enums.Status.NotActivated;
            redeemCode.UpdatedUserId         = input.UserId;
            redeemCode.UpdatedDate           = DateTime.Now;
            _context.Entry(redeemCode).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(-1);
            }

            return(1);
        }