public bool AddDownloadHistory(Downloadhistory downloadHistory) { try { _db.Downloadhistories.Add(downloadHistory); _db.SaveChanges(); return true; } catch (Exception ex) { return false; } }
// POST api/<controller> public bool Post(Downloadhistory downloadhistory) { Guid userId = _fileManagerAuth.GetCurrentUserId(); downloadhistory.UserId = userId; downloadhistory.DownloadDateTime = DateTime.Now; if (!_facade.AddDownloadHistory(downloadhistory)) return false; ResourceInfo resourceInfo = _facade.GetResourceById(downloadhistory.ResourceId); if (resourceInfo != null) { resourceInfo.DownloadCount++; _facade.UpdateResource(resourceInfo); } return true; }