public void DeleteMessageRecord(string languageIdParamter) { try { //Step 1 Code to delete the object from the database Model.Company.Structure.RuleMessage s = new Model.Company.Structure.RuleMessage(); s.languageId = languageIdParamter; s.ruleId = currentRuId.Text; PostRequest <Model.Company.Structure.RuleMessage> req = new PostRequest <Model.Company.Structure.RuleMessage>(); req.entity = s; PostResponse <Model.Company.Structure.RuleMessage> r = _companyStructureService.ChildDelete <Model.Company.Structure.RuleMessage>(req); if (!r.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { //Step 2 : remove the object from the store FillMessageStore(); //Step 3 : Showing a notification for the user Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordDeletedSucc }); } } catch (Exception ex) { //In case of error, showing a message box to the user X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show(); } }
protected void SaveNewMessageRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; Model.Company.Structure.RuleMessage b = JsonConvert.DeserializeObject <Model.Company.Structure.RuleMessage>(obj); // Define the object to add or edit as null if (string.IsNullOrEmpty(b.languageId) && string.IsNullOrEmpty(b.message)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <Model.Company.Structure.RuleMessage> request = new PostRequest <Model.Company.Structure.RuleMessage>(); request.entity = b; request.entity.ruleId = currentRuId.Text; PostResponse <Model.Company.Structure.RuleMessage> r = _companyStructureService.ChildAddOrUpdate <Model.Company.Structure.RuleMessage>(request); //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { //Add this record to the store FillMessageStore(); this.messageWindow.Close(); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { //getting the id of the record PostRequest <Model.Company.Structure.RuleMessage> request = new PostRequest <Model.Company.Structure.RuleMessage>(); request.entity = b; request.entity.ruleId = currentRuId.Text; PostResponse <Model.Company.Structure.RuleMessage> r = _companyStructureService.ChildAddOrUpdate <Model.Company.Structure.RuleMessage>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { FillMessageStore(); this.messageWindow.Close(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }