Пример #1
0
        static EntityActionService()
        {
            _Links = EntityDBService.GetEntityActions();

            // var d = new ActionLinkDefinition()
            // {
            //     ActionId = "ACT_1",
            //     ActionType = ActionType.View,
            //     Viewtype = EntityLayoutType.View,
            //     Text = "View 1",
            //     ExecType = ActionExecutionType.Redirect,
            //     QueryParam = new List<EvalParam>() {
            //         new EvalParam() { Name= "EntityId", Value= new EvalParamValue(){ Source = EvalSourceType.Constant, Value = 2 } },
            //         new EvalParam() { Name= "ItemId", Value= new EvalParamValue(){ Source = EvalSourceType.ModelField, Value = "Role" } }
            //         }
            // };
            // _Links.Add(d);

            // d = new ActionLinkDefinition()
            // {
            //     ActionId = "FUN_1",
            //     ActionType = ActionType.Function,
            //     Viewtype = EntityLayoutType.View,
            //     Text = "FUN 1",
            //     ExecType = ActionExecutionType.Custom,
            //     DataParam = new List<EvalParam>() {
            //         new EvalParam() { Name= "EntityId", Value= new EvalParamValue(){ Source = EvalSourceType.RequestQuery, Value = "EntityId" } },
            //         new EvalParam() { Name= "ItemId", Value= new EvalParamValue(){ Source = EvalSourceType.ModelField, Value = "Role" } }
            //         }
            // };

            // _Links.Add(d);
        }
Пример #2
0
        public AnyStatus Save(StackAppContext appContext, EntityModelBase model, IDbConnection connection, IDbTransaction transaction)
        {
            AnyStatus status = AnyStatus.NotInitialized;

            try
            {
                if (model.IsNew)
                {
                    model.SetValue("CREATEDON", DateTime.Now.ToUniversalTime());
                    model.SetValue("CREATEDBY", appContext.UserInfo.UserId);
                    model.SetMasterId(appContext.MasterId);
                }
                model.SetValue("UPDATEDON", DateTime.Now.ToUniversalTime());
                model.SetValue("UPDATEDBY", appContext.UserInfo.UserId);

                if (this.Validate(model))
                {
                    if (model is EntityRecordModel)
                    {
                        ((EntityRecordModel)model).ResolveComputedFields();
                    }
                    status = EntityDBService.SaveEntity(appContext, this, model, connection, transaction);
                    if (status == AnyStatus.Success)
                    {
                        status = OnSaveComplete(appContext, model);
                    }
                }
                else
                {
                    status = AnyStatus.InvalidData;
                }
            }
            catch (AppException ex)
            {
                status         = AnyStatus.SaveFailure;
                status.Message = ex.Message;
            }
            return(status);
        }