Exemplo n.º 1
0
        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]);
        }
Exemplo n.º 3
0
        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));
        }