コード例 #1
0
ファイル: AddEfCoreStore.cs プロジェクト: tongxin3267/alabo
        /// <summary>
        ///     批量添加
        /// </summary>
        /// <param name="soucre"></param>
        public void AddMany(IEnumerable <TEntity> soucre)
        {
            if (soucre == null)
            {
                throw new ArgumentNullException(nameof(soucre));
            }

            UnitOfWork.AddRange(soucre);
            var count = UnitOfWork.SaveChanges();
        }
コード例 #2
0
        public IHttpActionResult GetDetails([FromBody] DocumentActions item)
        {
            var list = new UnitOfWork().DocumentActionsRepo.Get(x =>
                                                                x.RefId == item.RefId && x.TableName == item.TableName)
                       .Select(x => new
            {
                x.DateCreated,
                x.ActionDate,
                x.CreatedBy,
                x.ActionTaken,
                CreatedByUsers = new ModelDb().Users.Where(m => m.Id == x.CreatedBy)
                                 .Select(m => new { FullName = m.FirstName + " " + m.LastName }).FirstOrDefault(),
                x.RouterUsers,
                x.Remarks,
                x.Programs,
                x.MainActivity,
                x.Activity,
                x.SubActivity
            })


                       .OrderByDescending(m => m.DateCreated).ToList();

            if (item.TableName == "PurchaseRequests")
            {
                var po = unitOfWork.PurchaseOrdersRepo.Get(x => x.PRId == item.RefId);

                foreach (var i in po)
                {
                    foreach (var obr in i.Obligations)
                    {
                        list.AddRange(unitOfWork.DocumentActionsRepo.Get(x =>
                                                                         x.RefId == obr.Id && x.TableName == "Obligations").Select(x => new
                        {
                            x.DateCreated,
                            x.ActionDate,
                            x.CreatedBy,
                            x.ActionTaken,
                            CreatedByUsers = new ModelDb().Users.Where(m => m.Id == x.CreatedBy)
                                             .Select(m => new { FullName = m.FirstName + " " + m.LastName }).FirstOrDefault(),
                            x.RouterUsers,
                            x.Remarks,
                            x.Programs,
                            x.MainActivity,
                            x.Activity,
                            x.SubActivity
                        }));
                    }
                }
            }
            return(Ok(list));
        }