public override bool Load(int id) { //Get the entity object from the DAL. ENTWFOwnerGroup eNTWFOwnerGroup = new ENTWFOwnerGroupData().Select(id); MapEntityToProperties(eNTWFOwnerGroup); return(eNTWFOwnerGroup != null); }
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."); } }