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.");
        }
        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(db, ref validationErrors);
                if (validationErrors.Count == 0)
                {
                    if (IsNewRecord())
                    {
                        ID = new ENTUserAccountData().Insert(db, WindowAccountName, FirstName, LastName, Email, IsActive, userAccountId);
                    }
                    else
                    {
                        if (!new ENTUserAccountData().Update(db, ID, WindowAccountName, FirstName, LastName, Email, IsActive, userAccountId, Version))
                        {
                            UpdateFailed(ref validationErrors);
                            return false;
                        }
                    }

                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                throw new Exception("DB Action is not Save");
            }
        }
        internal bool Load(HRPaidTimeOffDataContext db, int id)
        {
            ENTUserAccount userAccount = new ENTUserAccountData().Select(db, id);

            if (userAccount != null)
            {
                MapEntityToProperties(userAccount);
                return(true);
            }
            return(false);
        }
        public override bool Load(int id)
        {
            ENTUserAccount userAccount = new ENTUserAccountData().Select(id);

            if (userAccount != null)
            {
                MapEntityToProperties(userAccount);
                return(true);
            }
            return(false);
        }
 public override bool Load(int id)
 {
     var userAccount = new ENTUserAccountData().Select(id);
     if (userAccount != null)
     {
         MapEntityToProperties(userAccount);
         return true;
     }
     else
     {
         return false;
     }
 }
        protected override void Validate(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors)
        {
            if (string.IsNullOrEmpty(WindowAccountName) || WindowAccountName.Trim().Length == 0)
            {
                validationErrors.Add("The window account name is required.");
            }

            var entUserAccountData = new ENTUserAccountData();
            if (entUserAccountData.IsDuplicateWindowsAccountName(db, ID, WindowAccountName))
            {
                validationErrors.Add("Window account name must be unique");
            }
        }