Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="auditUser"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static ApplyAuditVdto <AuditStreamModel> ToAuditVDTO <T>(this AuditApplyViewModel model, User auditUser, IQueryable <T> db) where T : IHasGuidId, IAuditable, new()
        {
            var b = new ApplyAuditVdto <AuditStreamModel>()
            {
                AuditUser = auditUser,
                List      = model.Data.List.Select(d => new ApplyAuditNodeVdto <AuditStreamModel>()
                {
                    Action    = d.Action,
                    AuditItem = db.FirstOrDefault(i => i.Id == d.Id).ToModel(),
                    Remark    = d.Remark
                })
            };

            return(b);
        }
        public IEnumerable <ApiResult> Audit <T>(ref ApplyAuditVdto <T> model) where T : IAuditable
        {
            if (model == null)
            {
                return(null);
            }

            var list    = new List <ApiResult>();
            var handles = model.List.ToList();

            for (var i = 0; i < handles.Count; i++)
            {
                var apply  = handles[i];
                var result = AuditSingle(ref apply, model.AuditUser);
                list.Add(result);
            }
            model.List = handles;
            return(list);
        }