Пример #1
0
        public override bool Load(int id)
        {
            //Get the entity object from the DAL.
            ENTWFState eNTWFState = new ENTWFStateData().Select(id);

            MapEntityToProperties(eNTWFState);

            return(eNTWFState != null);
        }
Пример #2
0
        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.");
            }
        }