Ejemplo n.º 1
0
 private async Task UpdateDbWorkflow(UserWorkflow userWorkflow)
 {
     foreach (var step in userWorkflow.Steps)
     {
         if (step.TrackingState == TrackingState.Updated)
         {
             _db.Entry(step).State = EntityState.Modified;
         }
     }
     _db.Entry(userWorkflow).State = EntityState.Modified;
     await _db.SaveChangesAsync();
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutCategorieClient(int id, CategorieClient categorieClient)
        {
            if (id != categorieClient.Id)
            {
                return(BadRequest());
            }

            _context.Entry(categorieClient).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategorieClientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 3
0
        public async Task <TEntity> UpdateAsync(TEntity input, CancellationToken cancellationToken = default)
        {
            var targetItem = await _set
                             .FirstOrDefaultAsync(x => x.Id.Equals(input.Id), cancellationToken);

            input.ModifiedAt = DateTime.Now;
            _context.Entry(targetItem).CurrentValues.SetValues(input);
            await _context.SaveChangesAsync(cancellationToken);

            return(targetItem);
        }
Ejemplo n.º 4
0
        private static async Task TestWorkflow()
        {
            Person person = await context.People
                            .AsNoTracking()
                            .FirstOrDefaultAsync(x => x.Account == "001");

            string  title   = "送審主題" + Guid.NewGuid().ToString();
            Request request = new Request()
            {
                Title               = title,
                Description         = "申請說明",
                CurrentSigningLevel = 1,
                Note     = "",
                PersonId = person.Id,
                Status   = SigningStatus.Sending,
                Person   = null,
            };

            context.Entry(request).State = EntityState.Added;
            await context.SaveChangesAsync();

            #region 第1階主管審核
            foreach (var fooxx in context.Set <Request>().Local)
            {
                context.Entry(fooxx).State = EntityState.Detached;
            }
            Person person2 = await context.People
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Account == "002");

            Request currentRequest = await context.Requests
                                     .AsNoTracking()
                                     .FirstOrDefaultAsync(x => x.Title == title);

            currentRequest.FinalSigningPersonId = person2.Id;
            currentRequest.CurrentSigningLevel++;
            currentRequest.Status = SigningStatus.Approve;
            context.Entry(currentRequest).State = EntityState.Modified;
            await context.SaveChangesAsync();

            #endregion

            #region 第2階主管審核
            foreach (var fooxx in context.Set <Request>().Local)
            {
                context.Entry(fooxx).State = EntityState.Detached;
            }
            Person person3 = await context.People
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Account == "003");

            Request currentRequest2 = await context.Requests
                                      .AsNoTracking()
                                      .FirstOrDefaultAsync(x => x.Title == title);

            currentRequest2.FinalSigningPersonId = person3.Id;
            currentRequest2.CurrentSigningLevel++;
            currentRequest2.Status = SigningStatus.Approve;
            context.Entry(currentRequest2).State = EntityState.Modified;
            await context.SaveChangesAsync();

            #endregion

            #region 第3階主管審核
            foreach (var fooxx in context.Set <Request>().Local)
            {
                context.Entry(fooxx).State = EntityState.Detached;
            }
            Person person4 = await context.People
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Account == "003");

            Request currentRequest3 = await context.Requests
                                      .AsNoTracking()
                                      .FirstOrDefaultAsync(x => x.Title == title);

            currentRequest3.FinalSigningPersonId = person4.Id;
            currentRequest3.CurrentSigningLevel++;
            currentRequest3.Status = SigningStatus.Approve;
            context.Entry(currentRequest3).State = EntityState.Modified;
            await context.SaveChangesAsync();

            #endregion
        }