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); }
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); }
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); }
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); }