public void SetPendingApproval(string id, string decision, ApprovalReason reason) { try { ResourceManagementWebServicev2.ValidateID(id); ResourceObject approval = Global.Client.GetResourceByKey(ObjectTypeNames.Approval, AttributeNames.ObjectID, id); if (string.Equals(decision, "approve", StringComparison.OrdinalIgnoreCase)) { Global.Client.Approve(approval, true, reason?.Reason); } else if (string.Equals(decision, "reject", StringComparison.OrdinalIgnoreCase)) { Global.Client.Approve(approval, false, reason?.Reason); } else { throw new ArgumentException($"The value '{decision}' is not supported. Allowed values are 'Approve' or 'Reject'"); } } catch (WebFaultException) { throw; } catch (WebFaultException <Error> ) { throw; } catch (Exception ex) { ResourceManagementWebServicev2.HandleException(ex); throw; } }
public void SetPendingApproval(string id, string decision, ApprovalReason reason) { try { ResourceManagementWebServicev1.ValidateID(id); ResourceObject approval = Global.Client.GetResourceByKey(ObjectTypeNames.Approval, AttributeNames.ObjectID, id); if (string.Equals(decision, "approve", StringComparison.OrdinalIgnoreCase)) { Global.Client.Approve(approval, true, reason?.Reason); } else if (string.Equals(decision, "reject", StringComparison.OrdinalIgnoreCase)) { Global.Client.Approve(approval, false, reason?.Reason); } else { throw new ArgumentException($"The value '{decision}' is not supported. Allowed values are 'Approve' or 'Reject'"); } } catch (WebFaultException) { throw; } catch (WebFaultException <ExceptionData> ) { throw; } catch (AuthorizationRequiredException ex) { throw WebExceptionHelper.CreateWebException(ex); } catch (ResourceManagementException ex) { throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex); } catch (ArgumentException ex) { throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex); } catch (Exception ex) { throw WebExceptionHelper.CreateWebException(HttpStatusCode.InternalServerError, ex); } }
public void DeleteRecord(string index) { try { //Step 1 Code to delete the object from the database ApprovalReason s = new ApprovalReason(); s.recordId = index; //s.reference = ""; s.name = ""; PostRequest <ApprovalReason> req = new PostRequest <ApprovalReason>(); req.entity = s; PostResponse <ApprovalReason> r = _companyStructureRepository.ChildDelete <ApprovalReason>(req); if (!r.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { //Step 2 : remove the object from the store Store1.Remove(index); //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 SaveNewRecord(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"]; ApprovalReason b = JsonConvert.DeserializeObject <ApprovalReason>(obj); string id = e.ExtraParams["id"]; // Define the object to add or edit as null if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <ApprovalReason> request = new PostRequest <ApprovalReason>(); request.entity = b; PostResponse <ApprovalReason> r = _companyStructureRepository.ChildAddOrUpdate <ApprovalReason>(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 { b.recordId = r.recordId; //Add this record to the store this.Store1.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditRecordWindow.Close(); RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } 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 <ApprovalReason> request = new PostRequest <ApprovalReason>(); request.entity = b; PostResponse <ApprovalReason> r = _companyStructureRepository.ChildAddOrUpdate <ApprovalReason>(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 { ModelProxy record = this.Store1.GetById(id); BasicInfoTab.UpdateRecord(record); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }