var CourseSessionForm = function(){};

/***
 * Init the form
 * @returns {undefined}
 */
CourseSessionForm.Init = function(){
    Event.AddById("btnSave", "click", CourseSessionForm.SaveElement);
};

/***
* Get the Id of element 
*/
CourseSessionForm.GetId = function(){
    return Form.GetId("CourseSessionFormForm");
};

/*
* Save the Element
*/
CourseSessionForm.SaveElement = function(e){
   
    if(Form.IsValid("CourseSessionFormForm"))
    {
    let request = new Http("CourseSessionForm", "SaveElement");
        request.SetData(Form.Serialize("CourseSessionFormForm"));

        request.Post(data => {

            data = JSON.parse(data);

            if(data.status == "error"){
                Form.RenderError("CourseSessionFormForm", data.data.message);
            } else{

                Form.SetId("CourseSessionFormForm", data.data.Id);
            }
        });
    }
};

