Hi @Aliaksandr !
I’m using the library from Nuget in asp.net.
So my app is something like this: the user is logging in, and i’m saving his id in a Session variable (Session[“UserID”]. He has some functionalities in this one, and one of them is this dhtmlx Scheduler, where the user adds some new events. This Events are saved in a table in my Database.
What I wanna basically do is to show to the user A, let’s say, only the events added by him, not the events added by user B. That’s the code for my Evets table:
CREATE TABLE [dbo].[Events] (
[id] INT IDENTITY (1, 1) NOT NULL,
[text] NVARCHAR (256) NULL,
[start_date] DATETIME NOT NULL,
[end_date] DATETIME NOT NULL,
PRIMARY KEY CLUSTERED ([id] ASC)
);
What I want to do is to add a new column in this table, let’s say UserID, which should be a foreign key to the table where I’m saving my users.
The problem is that I don’t know where in the generated files by the DHTMLX Scheduler I can find the query that selects this events from my table. I have a Schedule.dbml that looks like this, but I don’t thinks that this is the right place to make my changes:
<?xml version="1.0" encoding="utf-8"?>
Also I have a file named Data.ashx.cs where I have this function which is extracting my events I guess
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = “text/json”;// the data comes in JSON format
context.Response.Write(
new SchedulerAjaxData(new SchedulerDataContext().Events) //events for loading to scheduler
);
}
And I have this class in which I save my data
public class Save : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/xml";// the data is passed in XML format
var action = new DataAction(context.Request.Form);
var data = new SchedulerDataContext();
try
{
var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), context.Request.Form);//see details below
switch (action.Type)
{
case DataActionTypes.Insert: // your Insert logic
data.Events.InsertOnSubmit(changedEvent);
break;
case DataActionTypes.Delete: // your Delete logic
changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
data.Events.DeleteOnSubmit(changedEvent);
break;
default:// "update" // your Update logic
var updated = data.Events.SingleOrDefault(ev => ev.id == action.SourceId);
DHXEventsHelper.Update(updated, changedEvent, new List<string>() { "id" });// see details below
break;
}
data.SubmitChanges();
action.TargetId = changedEvent.id;
}
catch (Exception a)
{
action.Type = DataActionTypes.Error;
}
context.Response.Write(new AjaxSaveResponse(action));
}
public bool IsReusable
{
get
{
return false;
}
}
}
Maybe you can understand now better what I want to do. I just basically want to change in some way the code to save my session variable in the Events table and show in my Scheduler only the events added by the logged in user.
Thank you for your time!