コード例 #1
0
 public async Task Savexcuda_PreviousItem(xcuda_PreviousItem i)
 {
     if (i == null)
     {
         return;
     }
     using (var ctx = new xcuda_PreviousItemService())
     {
         await ctx.Updatexcuda_PreviousItem(i).ConfigureAwait(false);
     }
 }
コード例 #2
0
        public static async Task ReorderDocumentItems(int ASYCUDA_Id)
        {
            List <xcuda_Item> rlst;

            using (var ctx = new xcuda_ItemService())
            {
                rlst =
                    (await ctx.Getxcuda_ItemByExpression(string.Format("ASYCUDA_Id == {0}", ASYCUDA_Id),
                                                         new List <string>()
                {
                    "xcuda_PreviousItem"
                })
                     .ConfigureAwait(false))
                    .OrderBy(x => x.LineNumber)
                    .ToList();
            }

            //if (!rlst.Where(x => x.xcuda_PreviousItem != null).Select(x => x.xcuda_PreviousItem).Any()) return;

            for (int i = 0; i < rlst.Count(); i++)
            {
                rlst.ElementAt(i).LineNumber = i + 1;
                if (rlst.ElementAt(i).xcuda_PreviousItem != null)
                {
                    rlst.ElementAt(i).xcuda_PreviousItem.StartTracking();
                    rlst.ElementAt(i).xcuda_PreviousItem.Current_item_number = (i + 1).ToString();
                }
            }

            using (var ctx = new xcuda_PreviousItemService())
            {
                foreach (var p in rlst.Select(x => x.xcuda_PreviousItem))
                {
                    if (p == null)
                    {
                        continue;
                    }
                    p.xcuda_Item = null;
                    await ctx.Updatexcuda_PreviousItem(p).ConfigureAwait(false);
                }
            }

            using (var ctx = new DocumentItemDSContext())
            {
                foreach (var i in rlst)
                {
                    ctx.Database.ExecuteSqlCommand("update xcuda_Item" +
                                                   $" set linenumber = {i.LineNumber}" +
                                                   $" where Item_Id = {i.Item_Id}");
                }
            }
        }