private void NetworkActions() { NetworkDelegates.Add(delegate(MResponse ServerResponse) { var WebRequestDirectory = Package.Unpacking <WebRequestDir>(ServerResponse.DataBytes); new AlertWindow("Оповещение", "Запись успешно сохранена", () => { this.Close(); }); }, Dispatcher, -1, "WebRequestDir.Save.Confirm", "EditorRequestSaverWindow"); NetworkDelegates.Add(delegate(MResponse ServerResponse) { var WebRequestBinding = Package.Unpacking <MBinding_WebRequestSaver>(ServerResponse.DataBytes); var WebRequestDirectory = new WebRequestDir { Title = DC_EditorRequestSaver.RequestDirectoryName, WebRequestItemId = WebRequestBinding.Item.Id }; if (!Sender.SendToServer("WebRequestDir.Save", WebRequestDirectory, 1337)) { new AlertWindow("Ошибка", AlertWindow.AlertCode.SendToServer); } }, Dispatcher, -1, "WebRequestItem.MBinding_WebRequestSaver.Save.Confirm", "EditorRequestSaverWindow"); }
private void WebRequestDirHistoryEdit(MResponse ClientResponse, MNetworkClient NetworkClient) { var RequestHistory = Package.Unpacking <WebRequestHistory>(ClientResponse.DataBytes); using (var db = new DatabaseContext()) { ModelRequestDirectory RequestDir = new ModelRequestDirectory(); RequestDir.RequestMethod = RequestHistory.Method; RequestDir.RequestTitle = RequestHistory.Title; RequestDir.WebRequestId = RequestHistory.WebRequestItemId; WebRequestDir WebDir = db.WebRequestDirs.FirstOrDefault(x => x.WebRequestItemId == RequestHistory.WebRequestItemId); RequestDir.Id = WebDir.Id; RequestDir.Title = WebDir.Title; Debug.Log($"\r\nId - {RequestDir.Id}\n" + $"RequestMethod - {RequestDir.RequestMethod}\n" + $"RequestTitle - {RequestDir.RequestTitle}\n" + $"Title - {RequestDir.Title}\n" + $"WebRequestId - {RequestDir.WebRequestId}\r\n"); Sender.Broadcast("WebRequestDir.History.Edit.Confirm", RequestDir, ClientResponse.WindowUid); } }
private void WebRequestDirUpdate(MResponse ClientResponse, MNetworkClient NetworkClient) { if (!AccessController.IsPrivilege(NetworkClient, "requests.edit")) { return; } var RequestDirectory = Package.Unpacking <ModelRequestDirectory>(ClientResponse.DataBytes); using (var db = new DatabaseContext()) { WebRequestDir WebDir = db.WebRequestDirs.FirstOrDefault(x => x.Id == RequestDirectory.Id); WebDir.Title = RequestDirectory.Title; WebRequestItem RequestItem = db.WebRequestItems.FirstOrDefault(x => x.Id == WebDir.WebRequestItemId); RequestItem.Title = RequestDirectory.RequestTitle; db.SaveChanges(); Sender.Broadcast("WebRequestDir.RequestDirectory.Update.Confirm", RequestDirectory, ClientResponse.WindowUid); } }