public int AddToCart(int fileId, UserProfileInfo user) { DownloadCartItem item = new DownloadCartItem(); item.FileId = fileId; item.User = user; item = this.dbContext.DownloadCarts.Add(item); this.dbContext.SaveChanges(); return(item.Id); }
public void DownloadCart_02_GetCart() { UserProfileInfo user = serviceUser.GetCurrentUser(); IList <DownloadCartItem> downloadCart = serviceDownload.GetByUserId(user.Id); Assert.IsTrue(downloadCart.Count > 0); DownloadCartItem first = downloadCart[0]; Assert.IsNotNull(first); Assert.IsNotNull(first.File); Assert.IsFalse(String.IsNullOrEmpty(first.File.PublicUrl)); }
public bool Delete(int id, UserProfileInfo user) { if (id <= 0) { return(false); } DownloadCartItem item = this.repoDownloadCart.GetById(id); if (item.User.Id != user.Id) { return(false); } return(this.repoDownloadCart.Delete(item)); }
public bool Delete(DownloadCartItem item) { this.dbContext.DownloadCarts.Remove(item); this.dbContext.SaveChanges(); return(true); }