public XCart(long id, long userID, EXCartStatus status, List <XCartItem> cartItems) { ID = id; UserID = userID; Status = status; CartItems = cartItems; }
public static ECartStatus ToEntity(this EXCartStatus status) { switch (status) { case EXCartStatus.Active: return(ECartStatus.Active); case EXCartStatus.Deleted: return(ECartStatus.Deleted); case EXCartStatus.Ordered: return(ECartStatus.Ordered); default: throw new ArgumentOutOfRangeException($"Unknown status value: {status}"); } }
public async Task <bool> UpdateCartStatus(long userID, EXCartStatus status) { var cart = await mDbContext.Carts .Include(c => c.CartItems) .FirstOrDefaultAsync(c => c.UserID.Value == userID && c.Status == Models.Entity.ECartStatus.Active); if (cart == null) { return(false); } var newStatus = status.ToEntity(); if (cart.Status == newStatus) { return(true); } cart.Status = newStatus; await mDbContext.SaveChangesAsync(); return(true); }