protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { if (ObjectName == "") { validationErrors.Add("Please select an object to audit."); } }
/// <summary> /// This method will connect to the database and start a transaction. /// </summary> public bool Delete(ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Delete) { // Begin database transaction using (var ts = new TransactionScope()) { // Create connection using (var db = new HRPaidTimeOffDataContext(DBHelper.GetHRPaidTimeOffConnectionString())) { //Delete the user this.Delete(db, ref validationErrors, userAccountId); if (validationErrors.Count == 0) { //Commit transaction since the delete was successful ts.Complete(); return(true); } //Rollback since the delete was not successful return(false); } } } throw new Exception("DBAction not delete."); }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { if (IsNewRecord()) { //Add ID = new ENTUserAccountData().Insert(db, WindowsAccountName, FirstName, LastName, Email, IsActive, userAccountId); } else { //Update if (!new ENTUserAccountData().Update(db, ID, WindowsAccountName, FirstName, LastName, Email, IsActive, userAccountId, Version)) { UpdateFailed(ref validationErrors); return(false); } } return(true); } //Didn't pass validation. return(false); } throw new Exception("DBAction not save."); }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { if (IsNewRecord()) { //Add ID = new ENTAuditData().Insert(db, ObjectName, RecordId, PropertyName, OldValue, NewValue, Convert.ToByte(AuditType), userAccountId); } else { //Update if (!new ENTAuditData().Update(db, ID, ObjectName, RecordId, PropertyName, OldValue, NewValue, Convert.ToByte(AuditType), userAccountId, Version)) { UpdateFailed(ref validationErrors); return(false); } } return(true); } //Didn't pass validation. return(false); } throw new Exception("DBAction not Save."); }
protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { if (WorkflowName.Trim() == "") { validationErrors.Add("The workflow name is required."); } else { //The name must be unique. if (new ENTWorkflowData().IsDuplicateWorkflowName(db, ID, WorkflowName)) { validationErrors.Add("The name must be unique."); } } //The object name is required if (ENTWorkflowObjectName.Trim() == "") { validationErrors.Add("The class name is required."); } else { //The object name must be unique if (new ENTWorkflowData().IsDuplicateObjectName(db, ID, ENTWorkflowObjectName)) { validationErrors.Add("This class already has a workflow associated with it."); } } }
protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { var entUserAccountData = new ENTUserAccountData(); //Windows Account Name is required. if (WindowsAccountName.Trim().Length == 0) { validationErrors.Add("The windows account name is required."); } ////The windows account name must be unique. if (entUserAccountData.IsDuplicateWindowsAccountName(db, ID, WindowsAccountName)) { validationErrors.Add("The windows account name must be unique."); } //TODO: VV Validate agains AD //First name, last name, and email are required. if (FirstName.Trim().Length == 0) { validationErrors.Add("The first name is required."); } //Last Name is required if (LastName.Trim().Length == 0) { validationErrors.Add("The last name is required."); } //Email is required if (Email.Trim().Length == 0) { validationErrors.Add("The email address is required."); } else { if (entUserAccountData.IsDuplicateEmail(db, ID, Email)) { validationErrors.Add("The email address must be unique."); } else { if (Email.IndexOf("@") < 0) { validationErrors.Add("The email address must contain the @ sign."); } else { string[] emailParts = Email.Split(new char[] { '@' }); if ((emailParts.Length != 2) || (emailParts[0].Length < 2) || (emailParts[1].ToUpper() != "POWEREDBYV2.COM")) { validationErrors.Add("The email address must be in the format [email protected]"); } } } } }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { if (ID <= 0) { //Add ID = new ENTRoleUserAccountData().Insert(db, ENTRoleId, ENTUserAccountId, userAccountId); } else { //Update if (!new ENTRoleUserAccountData().Update(db, ID, ENTRoleId, ENTUserAccountId, userAccountId, Version)) { UpdateFailed(ref validationErrors); return(false); } } return(true); } //Didn't pass validation. return(false); } throw new Exception("DBAction not delete."); }
protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { if (SubmitterENTUserAccountId == 0) { throw new Exception("The submitter is required."); } }
/// <summary> /// This method will save all the edit objects in the collection. The transaction must be started before /// calling this method. /// </summary> /// <param name="db"></param> /// <param name="validationErrors"></param> /// <param name="userAccountId"></param> /// <returns></returns> public bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { foreach (ENTBaseEO genericEO in this) { if (genericEO.DBAction == ENTBaseEO.DBActionEnum.Save) { if (!genericEO.Save(db, ref validationErrors, userAccountId)) { return(false); } } else { if (genericEO.DBAction == ENTBaseEO.DBActionEnum.Delete) { if (!genericEO.Delete(db, ref validationErrors, userAccountId)) { return(false); } } else { throw new Exception("Unknown DBAction"); } } } return(true); }
protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { if (StateName.Trim() == "") { validationErrors.Add("The state name is required."); } else { ////The windows account name must be unique. if (new ENTWFStateData().IsDuplicateStateName(db, ID, StateName)) { validationErrors.Add("The state name must be unique."); } } if (ENTWorkflowId == 0) { validationErrors.Add("Please select a workflow to associate with this state."); } if ((ENTWFOwnerGroupId == 0) && (IsOwnerSubmitter == false)) { validationErrors.Add("Please select the group that owns the issue while in this state."); } }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { if (IsNewRecord()) { //Add ID = new ENTWFTransitionData().Insert(db, ENTWorkflowId, TransitionName, FromENTWFStateId, ToENTWFStateId, PostTransitionMethodName, userAccountId); } else { //Update if (!new ENTWFTransitionData().Update(db, ID, ENTWorkflowId, TransitionName, FromENTWFStateId, ToENTWFStateId, PostTransitionMethodName, userAccountId, Version)) { UpdateFailed(ref validationErrors); return(false); } } return(true); } //Didn't pass validation. return(false); } throw new Exception("DBAction not Save."); }
protected override void ValidateDelete(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { //Nothing to validate. if (new ENTWorkflowData().IsWorkflowAssociatedWithItem(db, ID)) { validationErrors.Add("The workflow can not be deleted because there are items associated with this workflow."); } }
protected override void ValidateDelete(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { //Do not allow delete if they are associated with a state. if (new ENTWFOwnerGroupData().IsAssociatedWithState(db, ID)) { validationErrors.Add("This group is the default owner for one or more Workflow States and can not be deleted."); } }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { if (IsNewRecord()) { //Add ID = new ENTWFStateData().Insert(db, ENTWorkflowId, StateName, Description, ENTWFOwnerGroupId, IsOwnerSubmitter, userAccountId); //Update the ID on all the ENTWFStateProperty objects foreach (ENTWFStatePropertyEO stateProperty in ENTWFStateProperties) { stateProperty.ENTWFStateId = ID; } } else { //Update if (!new ENTWFStateData().Update(db, ID, ENTWorkflowId, StateName, Description, ENTWFOwnerGroupId, IsOwnerSubmitter, userAccountId, Version)) { UpdateFailed(ref validationErrors); return(false); } } //Delete all the existing ENTWFStateProperty records ENTWFStateProperties.Delete(db, ID); //Add the records that were chosen on the screen. if (ENTWFStateProperties.Save(db, ref validationErrors, userAccountId)) { return(true); } else { return(false); } } else { //Didn't pass validation. return(false); } } else { throw new Exception("DBAction not Save."); } }
protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { if (TransitionName.Trim() == "") { validationErrors.Add("The transition name is required."); } if (ENTWorkflowId == 0) { validationErrors.Add("Please select a workflow."); } }
protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { if (RoleName.Trim().Length == 0) { validationErrors.Add("The name is required."); } //The role name must be unique. if (new ENTRoleData().IsDuplicateRoleName(db, ID, RoleName)) { validationErrors.Add("The name must be unique."); } }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { if (IsNewRecord()) { //Add ID = new ENTWFOwnerGroupData().Insert(db, ENTWorkflowId, OwnerGroupName, DefaultENTUserAccountId, IsDefaultSameAsLast, Description, userAccountId); foreach (ENTWFOwnerGroupUserAccountEO user in UserAccounts) { user.ENTWFOwnerGroupId = ID; } } else { //Update if (!new ENTWFOwnerGroupData().Update(db, ID, ENTWorkflowId, OwnerGroupName, DefaultENTUserAccountId, IsDefaultSameAsLast, Description, userAccountId, Version)) { UpdateFailed(ref validationErrors); return(false); } } //Now save the users if (UserAccounts.Save(db, ref validationErrors, userAccountId)) { return(true); } else { return(false); } } else { //Didn't pass validation. return(false); } } else { throw new Exception("DBAction not Save."); } }
public void AuditDelete(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { var auditObject = new ENTAuditObjectEO(); if (auditObject.Load(db, this.GetType().Name)) { var audit = new ENTAuditEO(); audit.ObjectName = this.GetType().Name; audit.RecordId = ID; audit.AuditType = ENTAuditEO.AuditTypeEnum.Delete; audit.Save(db, ref validationErrors, userAccountId); } }
protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { if (OwnerGroupName.Trim() == "") { validationErrors.Add("The name is required."); } else { //The name must be unique within a workflow. if (new ENTWFOwnerGroupData().IsNameUnique(db, OwnerGroupName, ENTWorkflowId, ID) == false) { validationErrors.Add("The name must be unique."); } } }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { if (IsNewRecord()) { //Add ID = new ENTNotificationENTUserAccountData().Insert(db, ENTNotificationId, ENTUserAccountId, userAccountId); foreach (ENTNotificationENTWFStateEO notificationState in _notificationStates) { notificationState.ENTNotificationENTUserAccountId = ID; } } else { //Update if (!new ENTNotificationENTUserAccountData().Update(db, ID, ENTNotificationId, ENTUserAccountId, userAccountId, Version)) { UpdateFailed(ref validationErrors); return(false); } } //Delete all the states associated with this user _notificationStates.Delete(db, ID); //Add the states that were selected. return(_notificationStates.Save(db, ref validationErrors, userAccountId)); } else { //Didn't pass validation. return(false); } } else { throw new Exception("DBAction not Save."); } }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { return(_userNotifications.Save(db, ref validationErrors, userAccountId)); } //Didn't pass validation. return(false); } throw new Exception("DBAction not Save."); }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { if (IsNewRecord()) { //Add ID = new ENTAuditObjectData().Insert(db, ObjectName, ObjectFullyQualifiedName, userAccountId); //Add the ID to all the property objects foreach (ENTAuditObjectPropertyEO property in _properties) { property.ENTAuditObjectId = ID; } } else { //Update if (!new ENTAuditObjectData().Update(db, ID, ObjectName, ObjectFullyQualifiedName, userAccountId, Version)) { UpdateFailed(ref validationErrors); return(false); } //Delete the existing records for this object _properties.Delete(db, ID); } //Save the new settings _properties.Save(db, ref validationErrors, userAccountId); return(true); } //Didn't pass validation. return(false); } throw new Exception("DBAction not Save."); }
/// <summary> /// Deletes the record. /// </summary> internal virtual bool Delete(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Delete) { //Check if this record can be deleted. There may be referential integrity rules preventing it from being deleted ValidateDelete(db, ref validationErrors); if (validationErrors.Count == 0) { DeleteForReal(db); //Chapter 12-Auditing AuditDelete(db, ref validationErrors, userAccountId); return(true); } //The record can not be deleted. return(false); } throw new Exception("DBAction not delete."); }
/// <summary> /// This method will begin a transaction and save all the edit objects in the collection. /// </summary> /// <param name="veAL"></param> /// <param name="loginName"></param> /// <returns></returns> public bool Save(ref ENTValidationErrors validationErrors, int userAccountId) { // Check if this object has any items if (this.Count > 0) { using (var ts = new TransactionScope()) { using (var db = new HRPaidTimeOffDataContext()) { if (this.Save(db, ref validationErrors, userAccountId)) { // Commit transaction if update was successful ts.Complete(); return(true); } return(false); } } } return(true); }
public void AuditUpdate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { foreach (var property in _originalPropertyValues) { object value = this.GetType().GetProperty(property.Name).GetValue(this, null); if (((value != null) && (property.Value != null)) && (Convert.ToString(value) != Convert.ToString(property.Value))) { var audit = new ENTAuditEO(); audit.ObjectName = this.GetType().Name; audit.RecordId = ID; audit.PropertyName = property.Name; audit.OldValue = (property.Value == null ? null : Convert.ToString(property.Value)); audit.NewValue = (Convert.ToString(value)); audit.AuditType = ENTAuditEO.AuditTypeEnum.Update; audit.Save(db, ref validationErrors, userAccountId); } } }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { if (IsNewRecord()) { //Add ID = new ENTWFStatePropertyData().Insert(db, ENTWFStateId, PropertyName, Required, ReadOnly, userAccountId); } else { //Update if (!new ENTWFStatePropertyData().Update(db, ID, ENTWFStateId, PropertyName, Required, ReadOnly, userAccountId, Version)) { UpdateFailed(ref validationErrors); return(false); } } return(true); } else { //Didn't pass validation. return(false); } } else { throw new Exception("DBAction not Save."); } }
public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { //Validate the object Validate(db, ref validationErrors); //Check if there were any validation errors if (validationErrors.Count == 0) { if (IsNewRecord()) { //Add ID = new ENTNotificationData().Insert(db, Description, FromEmailAddress, Subject, Body, userAccountId); } else { //Update if (!new ENTNotificationData().Update(db, ID, Description, FromEmailAddress, Subject, Body, userAccountId, Version)) { UpdateFailed(ref validationErrors); return(false); } } return(true); } else { //Didn't pass validation. return(false); } } else { throw new Exception("DBAction not Save."); } }
/// <summary> /// This is used to save a record and start a new transaction. /// The implementor of BaseEO needs to create their own Save method that expects the /// transaction to be passed in. /// </summary> public bool Save(ref ENTValidationErrors validationErrors, int userAccountId) { if (DBAction == DBActionEnum.Save) { // Begin database transaction using (var ts = new TransactionScope()) { // Create connection using (var db = new HRPaidTimeOffDataContext())//DBHelper.GetHRPaidTimeOffConnectionString())) { //Now save the record if (this.Save(db, ref validationErrors, userAccountId)) { // Commit transaction if update was successful ts.Complete(); return(true); } return(false); } } } throw new Exception("DBAction not Save."); }
protected override void ValidateDelete(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { //throw new NotImplementedException(); //Check if associates with a transition }
protected override void ValidateDelete(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors) { //TODO: validate that user has requests //throw new NotImplementedException(); }