This is a migrated thread and some comments may be shown as answers.

calling the get method of my controller

2 Answers 188 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Julien
Top achievements
Rank 1
Julien asked on 07 May 2018, 04:53 AM

Hello,

How can i call the Get method of my controller ? When i load my page, it's only calling the Post Method. I followed the web api events exemple. Thank you.

 

[Produces("application/json")]
[Route("api/[controller]")]
public class AstreintesController : Controller
{
    private readonly PlanningContext _context;
    private readonly IAgentService _agentService;
 
    public AstreintesController(PlanningContext context, IAgentService agentService)
        {
            _context = context;
            _agentService = agentService;
        }
 
    //GET api/Astreintes
    [HttpGet]
    public DataSourceResult Get([DataSourceRequest]DataSourceRequest request)
    {
        return _context.Astreintes.ToDataSourceResult(request);
    }
 
    [HttpPost]
    public DataSourceResult Post([DataSourceRequest]DataSourceRequest request)
    {
        if (!ModelState.IsValid)
        {
           //todo: handle error
        }
 
        return _context.Astreintes.ToDataSourceResult(request);
    }

 

@(Html.Kendo().Scheduler<NC.Enercal.PlanningPE.Web.Areas.Planification.ViewModels.TaskViewModel>()
    .Name("scheduler")
    .Date(new DateTime(2013, 6, 13))
    .StartTime(new DateTime(2013, 6, 13, 7, 00, 00))
    .Selectable(true)
        .Editable(editable =>
        {
            editable.Resize(false);
        })
    .Height(650)
    .Views(views =>
    {
        views.MonthView(month => month.Selected(true));
 
    })
    .Timezone("Etc/UTC")
    .Resources(resource =>
    {
 
    })
    .DataSource(d => d
        .Events(e => e.Error("onError"))
        .Model(m =>
        {
            m.Id(f => f.Id);
            m.Field(f => f.Title).DefaultValue("No title");
            m.Field(f => f.AgentId).DefaultValue(1);
        })
    .Read("Get", "Astreintes")
    .Create("Create", "Astreintes")
)

2 Answers, 1 is accepted

Sort by
0
Accepted
Neli
Telerik team
answered on 09 May 2018, 11:18 AM
Hello Julien,

Could you please add the WebApi() method to your configuration and test the behavior?
.DataSource(d => d
       .WebApi()
       .Model(m =>
       {
           m.Id(f => f.EventId);
           m.Field(f => f.Title).DefaultValue("No title");
           m.RecurrenceId(f => f.RecurrenceId);
       })
       .Read(read => read.Action("Schedules_Read", "Scheduler"))
   )
Attached you will find a sample project where the Get method is called correctly. If the issue continue to persist please modify the sample project in order to replicate the issue and send it back to us. This way we could troubleshoot the problem locally and advise you further. 

Regards,
Neli
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Julien
Top achievements
Rank 1
answered on 09 May 2018, 08:13 PM
It works ! Thank you very much 
Tags
Scheduler
Asked by
Julien
Top achievements
Rank 1
Answers by
Neli
Telerik team
Julien
Top achievements
Rank 1
Share this question
or