public void SaveCart(Cart cart) { if (cart.MemberId > 0) { var repository = new MongoRepository<Cart>(); if (string.IsNullOrEmpty(cart.Id)) { repository.Add(cart); } else { repository.Update(cart); } } }
public Cart GetCart(int memberId) { var repository = new MongoRepository<Cart>(); var cart = repository.FirstOrDefault(c => c.MemberId == memberId); return cart ?? new Cart { MemberId = memberId }; }