public IHttpActionResult Post(AssetWriteModel model) { if (model == null) { return(BadRequest(Constants.MISSING_MESSAGE_BODY)); } var dto = MapToDto(model, createdBy: _shibbolethAttribs.GetUid()); long id = _repo.Insert(dto); // Refetch the data. dto = _repo.GetById(id); var readModel = MapToModel(dto); return(CreatedAtRoute("GetAssetById", new { id = readModel.Id }, readModel)); }
public void ThenTheAttributeIsFound() { string uid = _sut.Get(ShibbolethAttributes.UID_KEY); Assert.AreEqual("u0000001", uid); uid = _sut.GetUid(); Assert.AreEqual("u0000001", uid); var result = _sut.GetAll(); Assert.AreEqual(1, result.Count); Assert.AreEqual("u0000001", result[ShibbolethAttributes.UID_KEY]); }
public IHttpActionResult GetForCurrentUser() { // User is already authenticated and authorized for the read role. var uid = _shibbolethAttribs.GetUid(); var userRoles = _repo.GetAll(); var actualRoles = userRoles.GetRolesFor(uid); var readModel = new UserRoleReadModel { UserName = uid, Roles = actualRoles.ToArray() }; return(Ok(readModel)); }