Example #1
0
 public static void LogFileAudit(long fileInformationId, AuditStates auditStates, int userId)
 {
     new Thread(() =>
     {
         try
         {
             using (var entities = new Entities())
             {
                 entities.FileAuditLogs.Add(new FileAuditLog()
                 {
                     IsDeleted         = false,
                     AuditCommitUserId = userId,
                     AuditPeriod       = DateTime.Now,
                     AuditType         = (int)auditStates,
                     FileInformationId = fileInformationId
                 });
                 entities.SaveChanges();
             }
         }
         catch (Exception e)
         {
             ActivityLogger.Log(e);
         }
     }).Start();
 }
        private AuditStates ValidateDescriptionAuditState(SQLHoshinCoreContext _ctx, IMapper _mapper, AuditState auditState)
        {
            AuditStates auditStateValidation = _ctx.AuditStates.Where(x => (x.Name == auditState.Name || x.Code == auditState.Code || x.Color == auditState.Color) && x.AuditStateID != auditState.AuditStateID).FirstOrDefault();

            if (auditStateValidation == null)
            {
                return(_mapper.Map <AuditState, AuditStates>(auditState));
            }

            return(null);
        }
        public AuditState Update(AuditState updateAuditState)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var _mapper = scope.ServiceProvider.GetService(typeof(IMapper)) as IMapper;
                var _ctx    = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;

                AuditStates auditStateRetriver = ValidateDescriptionAuditState(_ctx, _mapper, updateAuditState);
                if (auditStateRetriver is null)
                {
                    return(null);
                }
                _ctx.AuditStates.Update(auditStateRetriver);
                _ctx.SaveChanges();
                return(_mapper.Map <AuditStates, AuditState>(auditStateRetriver));
            }
        }