public HttpResponseMessage PostinquiryDdlUserRole(OwnerRole ownerRole) { try { var result = ddlSvc.GetDdlUserRole(ownerRole); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.ToString())); } }
public List <Dropdownlist> GetDdlUserRole(OwnerRole ownerRole) { using (var ctx = new ConXContext()) { List <Dropdownlist> ddl = ctx.UserRoles .Where( z => z.isPC == ownerRole.isPc && (z.createUser == ownerRole.createUser || ownerRole.createUser.ToLower() == "admin") && z.status == "A" ) .OrderBy(o => o.userRoleId) .Select(x => new Dropdownlist() { key = x.userRoleId, value = x.roleName }) .ToList(); return(ddl); } }