public async Task <IEnumerable <LicenceItem> > getLicencesAsync(string user) { var item1 = new LicenceItem() { Id = Guid.NewGuid(), User = "******", Key = "123", ExpiresOn = DateTimeOffset.Now.AddDays(50) }; var item2 = new LicenceItem() { Id = Guid.NewGuid(), User = "******", Key = "abc", ExpiresOn = DateTimeOffset.Now.AddDays(60) }; IEnumerable <LicenceItem> list = new List <LicenceItem>() { item1, item2 }; return(await Task.FromResult(list)); }
public async Task <bool> addLicenceItemAsync(LicenceItem licenceItem, string user) { licenceItem.Id = Guid.NewGuid(); licenceItem.ExpiresOn = DateTimeOffset.Now.AddDays(365); licenceItem.AdminUser = user; _context.LicenceItems.Add(licenceItem); return(await _context.SaveChangesAsync() == 1); }
public async Task <IActionResult> AddLicenceItem(LicenceItem licenceItem) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } var currentUser = await _userManager.GetUserAsync(User); if (currentUser == null) { return(Challenge()); } var success = await _licenceService.addLicenceItemAsync(licenceItem, currentUser.UserName); if (!success) { return(BadRequest("Item could not be added!")); } return(RedirectToAction("Index")); }
public async Task <bool> addLicenceItemAsync(LicenceItem licenceItem, string user) { return(await Task.FromResult <bool>(true)); }