예제 #1
0
        public Result Delete(Model.DB.AccountGroup model)
        {
            var units = UnitDA.List4AccountGroup(model.id);

            if (units.Count > 0)
            {
                return(Result(ApiResultEnum.Cited, string.Join(",", units.Select(u => u.code))));
            }

            model.created_by = user_id;
            ApiResultEnum result = AccountGroupDA.Delete(model);

            if (result == ApiResultEnum.Success && MonitorRA.GetStatusTrade() != 0)
            {
                AccountGroupRA.Delete4AccountGroup(model.id);
            }
            return(Result(result, string.Empty));
        }
예제 #2
0
        public Result UpdateItems(Model.DB.AccountGroup model)
        {
            model.items = model.items.OrderBy(i => i.sort_buy).AsEnumerable().DistinctBy(i => i.account_id).ToList();
            ApiResultEnum result = AccountGroupDA.UpdateItems(model);

            if (result == ApiResultEnum.Success && MonitorRA.GetStatusTrade() != 0)
            {
                var units = UnitDA.List4AccountGroup(model.id);
                foreach (var kvp in units)
                {
                    UnitRA.UpdatePriorityStrategy(model.priority_strategy, "U_" + kvp.id);
                }
                AccountGroupRA.Delete4AccountGroup(model.id);
                List <Model.DB.AccountGroupItem> items = AccountGroupDA.ListItems4AccountGroup(model.id);
                foreach (Model.DB.AccountGroupItem item in items)
                {
                    OpenCloseBiz.LoadAccountGroupItem(item);
                }
                TradeBiz.RunCalculateValue();
            }
            return(Result(result));
        }