Hi
Let me paint the picture. I am trying to build an application for the medical domain. Basically creating accounts which are responsible for paying the account. Then dependants linked to an account. And each account has transactions linked to it. That is the basic domain. I am trying to display a grid showing the account information. My architecture is as follows. Using entity framework 6 as my ORM. I have built some DTO's inside a model project that hold all my models which I intend to carry over the wire. I have a seperate asp mvc api project which will act as my data hub for different types of front ends, browser or mobile. At the moment I'm trying to build a front end using MVC 5 using the telerik kendo ui controls to make the ui nice. I'm struggling even after reading various articles on trying to achieve this. I have a method in my web api project which returns a list of accounts which I pasted below. After reading some new articles I've realised that it be better to refactor this method to return the kendo DataSourceResult and accept the modelbinder as a parameter. My question is. How do I pass the practiceid parameter into this method so that it only returns me a list of accounts that belong to the practice the user has logged into. I have also pasted my grid definition below.
[Route("api/Accounts")]public HttpResponseMessage GetAccountsByPractice(int practiceId){ IAccountRepository accountRepository = new AccountRepository(""); try { var results = accountRepository.GetAccountsByPractice(new Practice { PracticeId = practiceId }); return Request.CreateResponse(HttpStatusCode.OK, results); } catch (Exception) { throw; }}
@(Html.Kendo().Grid<Medistat.MedistatWeb.Domain.Model.AccountDTO>() .Name("accountGrid") .Columns(columns => { columns.Bound(p => p.AccountNumber); columns.Bound(p => p.AccountHolderName).Width(100); columns.Bound(p => p.IdNumber).Width(100); columns.Bound(p => p.MedicalAidName).Width(100); columns.Bound(p => p.MedicalAidNumber).Width(100); }) .ToolBar(tools => { tools.Create(); }) .Sortable() .Pageable() .Filterable() .DataSource(dataSource => dataSource .WebApi() .Model(model => { model.Id(p => p.AccountId); }) .Events(events => events.Error("error_handler")) .Read(read => read.Url("http://localhost:54510/api/accounts")) .Create(create => create.Url("http://localhost:54510/api/accounts")) ))