public async Task <IActionResult> AddCollection(DAMSViewModel inputData) { try { var collection = inputData.NewCollection; collection.Id = Guid.NewGuid(); collection.CreatedOn = DateTimeOffset.Now.ToString(); collection.CreatedBy = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value.ToString(); var success = await _damsClient.AddCollection(collection); if (success) { _damsRepository.AddCollection(new CollectionEntity { Id = collection.Id, Name = collection.Name, OwnerId = new Guid(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value) }); return(RedirectToAction("Index", "DAMS")); } return(RedirectToAction("Index", "Error")); } catch (Exception e) { return(RedirectToAction("Index", "Error")); } }
public IActionResult Index() { try { var id = new Guid(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value); var collectionEntities = _damsRepository.GetCollectionsByOwnerId(id); var model = new DAMSViewModel { Collections = collectionEntities }; return(View(model)); } catch (Exception e) { return(RedirectToAction("Index", "Error")); } }