Example #1
0
        public async Task <IHttpActionResult> Get(Guid Userinroleid)
        {
            Usersinrole item = await _bl.GetByKeyAsync(Userinroleid);

            if (item.Userinroleid == Userinroleid)
            {
                return(Ok(item));
            }
            return(NotFound());
        }
Example #2
0
        public async Task <IHttpActionResult> Put(Guid Userinroleid, [FromBody] Usersinrole model)
        {
            //   if (model.Userinroleid != Userinroleid) return BadRequest("Resource Userinroleid's do not match.");
            //var transactionHeader = Request.Headers.GetValues("TransactionContext");
            //var transactionContext_str = transactionHeader.FirstOrDefault();
            //TransactionContext client_context = JsonConvert.DeserializeObject<TransactionContext>(transactionContext_str);

            //model.TransContext = client_context;
            model.AppendTransactionContext(Request);
            return(await Save(model));
        }
Example #3
0
        private async Task <IHttpActionResult> Save(Usersinrole model)
        {
            model = await _bl.SaveAsync(model);

            if (model.Validation.IsValid)
            {
                return(Ok(model));
            }
            CreateModelState(model.Validation);
            return(BadRequest(ModelState));
        }
Example #4
0
 public async Task <IHttpActionResult> List([FromUri] Usersinrole filter, [FromUri] PageConfig pageConfig)
 {
     if (pageConfig == null)
     {
         pageConfig = new PageConfig();
     }
     if (filter == null)
     {
         filter = new Usersinrole();
     }
     return(Ok(await _bl.List(filter, pageConfig)));
 }
Example #5
0
        public async Task <IHttpActionResult> Delete(Guid Userinroleid, [FromBody] Usersinrole model)
        {
            // if (model.Userinroleid != Userinroleid) return BadRequest("Resource Userinroleid's do not match.");

            model = await _bl.GetByUserIdRoleId(model.Roleid, model.Userid);

            model.AppendTransactionContext(Request);
            model = await _bl.DeleteAsync(model);

            if (model.Validation.IsValid)
            {
                return(Ok(model));
            }
            CreateModelState(model.Validation);
            return(BadRequest(ModelState));
        }
Example #6
0
        public async Task <IHttpActionResult> Putwithcontext(Guid Userinroleid, [FromUri] TransactionContext context, [FromBody] Usersinrole model)
        {
            var identity = HttpContext.Current.User as ClaimsIdentity;

            if (identity != null)
            {
                IEnumerable <Claim> claims = identity.Claims;
                var x = identity.FindFirst("ClaimName").Value;
            }
            if (model.Userinroleid != Userinroleid)
            {
                return(BadRequest("Resource Userinroleid's do not match."));
            }
            model.TransContext = context;
            return(await Save(model));
        }
Example #7
0
 public async Task <IHttpActionResult> Post([FromBody] Usersinrole model)
 {
     model.AppendTransactionContext(Request);
     return(await Save(model));
 }