public async Task <List <DocumentationBusinessType> > FindDocumentationBusinessTypesByBTAsync(int businessTypeID)
        {
            Stopwatch timespan = Stopwatch.StartNew();

            try
            {
                var result = await db.DocumentationBusinessTypes
                             .Where(t => t.BusinessTypeID == businessTypeID)
                             .OrderByDescending(t => t.BusinessTypeID).ToListAsync();

                if (result != null)
                {
                    foreach (DocumentationBusinessType item in result)
                    {
                        db.Entry(item).Reference(x => x.Documentation).Load();
                    }
                }

                timespan.Stop();
                log.TraceApi("SQL Database", "DocumentationBusinessTypeRepository.FindDocumentationBusinessTypesByBTAsync", timespan.Elapsed, "businessTypeID={0}", businessTypeID);

                return(result);
            }
            catch (Exception e)
            {
                log.Error(e, "Error in DocumentationBusinessTypeRepository.FindDocumentationBusinessTypesByBTAsync(businessTypeID={0})", businessTypeID);
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Cuando una Presetacion la toma un Auditor para su revision
        /// </summary>
        /// <param name="presentation"></param>
        /// <returns></returns>
#warning "Falta tomar el Id del Usuario logueado"
        public async Task TakeToAudit(Presentation presentation)
        {
            Stopwatch timespan = Stopwatch.StartNew();

            SiccoAppConfiguration.SuspendExecutionStrategy = true;

            DbContextTransaction tran = db.Database.BeginTransaction();

            try
            {
                if (presentation.PresentationStatus != PresentationStatus.Pending)
                {
                    throw new Exception("No se puede tomar Presentaciones que no estan PENDIENTES");
                }

                //actualizacion de Presentation
                presentation.TakenDate = DateTime.UtcNow;
                //presentation.TakenFor = 999;
                presentation.PresentationStatus = PresentationStatus.Processing;

                //actualizacion de Requerimientos
                var requirement = await db.Requirements.FindAsync(presentation.RequirementID);

                requirement.RequirementStatus = RequirementStatus.Processing;

                //creacion de el historico de accionesde Presentation
                PresentationAction presentationAction = new PresentationAction
                {
                    PresentationID         = presentation.PresentationID,
                    PresentationDate       = DateTime.UtcNow,
                    ActionForID            = presentation.TakenForID,
                    PresentationActionType = PresentationActionType.Taken
                };
                db.PresentationActions.Add(presentationAction);

                db.Entry(presentation).State = EntityState.Modified;

                await db.SaveChangesAsync();

                tran.Commit();

                timespan.Stop();
                log.TraceApi("SQL Database", "PresentationRepository.TakeToAudit", timespan.Elapsed, "presentation={0}", presentation);
            }
            catch (Exception e)
            {
                tran.Rollback();
                log.Error(e, "Error in PresentationRepository.TakeToAudit(presentation={0})", presentation);
                throw;
            }

            SiccoAppConfiguration.SuspendExecutionStrategy = false;
        }
        public async Task UpdateAsync(Contractor contractorToSave)
        {
            Stopwatch timespan = Stopwatch.StartNew();

            try
            {
                db.Entry(contractorToSave).State = EntityState.Modified;
                await db.SaveChangesAsync();

                timespan.Stop();
                log.TraceApi("SQL Database", "ContractorRepository.UpdateAsync", timespan.Elapsed, "contractorToSave={0}", contractorToSave);
            }
            catch (Exception e)
            {
                log.Error(e, "Error in ContractorRepository.UpdateAsync(contractorToSave={0})", contractorToSave);
                throw;
            }
        }
Ejemplo n.º 4
0
        public async Task UpdateAsync(BusinessTypeTemplate businessTypeTemplateToSave)
        {
            Stopwatch timespan = Stopwatch.StartNew();

            try
            {
                db.Entry(businessTypeTemplateToSave).State = EntityState.Modified;
                await db.SaveChangesAsync();

                timespan.Stop();
                log.TraceApi("SQL Database", "BusinessTypeTemplateRepository.UpdateAsync", timespan.Elapsed, "businessTypeTemplateToSave={0}", businessTypeTemplateToSave);
            }
            catch (Exception e)
            {
                log.Error(e, "Error in BusinessTypeTemplateRepository.UpdateAsync(businessTypeTemplateToSave={0})", businessTypeTemplateToSave);
                throw;
            }
        }
Ejemplo n.º 5
0
 public void Update(T entity)
 {
     _dbContext.Entry(entity).State = EntityState.Modified;
     _dbContext.SaveChanges();
 }