コード例 #1
0
ファイル: OperationService.cs プロジェクト: JosephKigin/Armis
        //Post
        public async Task <OperationModel> AddOperation(OperationModel anOperation)
        {
            var theOperEntityToAdd = anOperation.ToEntity();

            var theMostRecentId = await context.Operation.MaxAsync(i => i.OperationId);

            var theOperationGroup = await context.OperationGroup.FirstOrDefaultAsync(i => i.OperGroupId == anOperation.Group.Id);

            theOperEntityToAdd.OperationId = theMostRecentId + 1;
            theOperEntityToAdd.OperGroup   = theOperationGroup;
            context.Add(theOperEntityToAdd);
            await context.SaveChangesAsync();

            return(theOperEntityToAdd.ToModel());
        }
コード例 #2
0
ファイル: OrderHeadService.cs プロジェクト: JosephKigin/Armis
        //Post
        public async Task <OrderHeadModel> PostOrderHead(OrderHeadModel anOrderHeadModel)
        {
            var theOrderHeadId = await Context.OrderHead.MaxAsync(i => i.OrderId) + 1;

            anOrderHeadModel.OrderId = theOrderHeadId;

            foreach (var orderDetail in anOrderHeadModel.OrderDetails) //Assigns the order id to all the orderDetails
            {
                orderDetail.OrderId = theOrderHeadId;
            }

            Context.Add(anOrderHeadModel.ToEntity());

            Context.AddRange(anOrderHeadModel.OrderDetails.ToEntities());

            await Context.SaveChangesAsync();

            return(anOrderHeadModel);
        }