Example #1
0
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId,
                                                             Guid instanceId, Guid employeeID, Guid conceptPaymentID) where T : BaseEntity
        {
            var fonacotMovements = new List <FonacotMovement>();

            fonacotMovements.Add(new FonacotMovement()
            {
                ID                    = Guid.NewGuid(),
                Active                = true,
                company               = identityWorkId,
                Timestamp             = DateTime.UtcNow,
                InstanceID            = instanceId,
                Description           = "Departamento de nominas",
                CreationDate          = DateTime.Now,
                Name                  = "Nominas",
                StatusID              = 1,
                ConceptPaymentID      = conceptPaymentID,
                CreditNumber          = "AA010101",
                DeleteDate            = null,
                EmployeeID            = employeeID,
                FonacotMovementStatus = FonacotMovementStatus.Active,
                Month                 = 1,
                Year                  = 2020,
                Observations          = "Observations",
                RetentionType         = RetentionType.FixedAmount,
                user                  = Guid.Empty,
            });

            var middlewareManager = new MiddlewareManager <FonacotMovement>(new BaseRecordManager <FonacotMovement>(), new FonacotMovementValidator());
            await middlewareManager.CreateAsync(fonacotMovements, identityWorkId);

            return(fonacotMovements as List <T>);
        }
Example #2
0
            public async Task Should_Fall_Inhability_Duplicated_Folio()
            {
                var txOptions = new System.Transactions.TransactionOptions();

                txOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;

                using var scope = new TransactionScope(TransactionScopeOption.Required, txOptions, TransactionScopeAsyncFlowOption.Enabled);

                //Act
                Guid identityWorkId    = Guid.NewGuid();//Guid.Parse("7535C4E6-4712-4DD6-955D-FCA86E054D49");
                var  middlewareManager = new MiddlewareManager <Inhability>(new BaseRecordManager <Inhability>(), new InhabilityValidator());
                Guid id = Guid.Empty;

                try
                {
                    Guid instanceId   = Guid.NewGuid(); //Guid.Parse("33D7CA50-39E9-4B14-B482-5FCBEC07E8DB");
                    var  inhabilities = await new InhabilityManagerUT().CreateDefaultAsync <Inhability>(identityWorkId, instanceId);

                    id = inhabilities.FirstOrDefault().ID;
                    inhabilities.FirstOrDefault().ID = Guid.NewGuid();
                    await middlewareManager.CreateAsync(inhabilities, identityWorkId);

                    Assert.False(true);
                }
                catch (Exception ex)
                {
                    Assert.Contains("Existe 1 o más registros que ya existen en la base de datos con el campo: Folio", ex.Message);
                }
            }
Example #3
0
            public async Task Should_Create_Fonacot_CreditNumber_Duplicated_ToValidate_Finally_do_Delete()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                try
                {
                    //Arrange
                    var identityWorkId    = Guid.NewGuid();
                    var instanceId        = Guid.NewGuid();
                    var middlewareManager = new MiddlewareManager <FonacotMovement>(new BaseRecordManager <FonacotMovement>(), new FonacotMovementValidator());
                    var fonacotMovements  = await new FonacotMovementManagerUT().CreateDefaultAsync <FonacotMovement>(identityWorkId, instanceId);

                    fonacotMovements.FirstOrDefault().ID = Guid.NewGuid();

                    //Act
                    await middlewareManager.CreateAsync(fonacotMovements, identityWorkId);

                    //Assert
                    Assert.False(true, "La validación de duplicado falló");
                }
                catch (CotorraException ex)
                {
                    Assert.Equal(15001, ex.ErrorCode);
                }
                catch
                {
                    Assert.True(true);
                }
            }
        public async Task Client_Should_Call_Dummy_Async()
        {
            using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

            var iMSSFare   = new List <IMSSFare>();
            var companyId  = Guid.NewGuid();
            var instanceId = Guid.NewGuid();
            var userId     = Guid.NewGuid();

            iMSSFare = new MemoryStorageContext().GetDefaultIMSSFare(companyId, instanceId, userId);

            var middlewareManager = new MiddlewareManager <IMSSFare>(new BaseRecordManager <IMSSFare>(), new IMSSFareValidator());

            //Act
            await middlewareManager.CreateAsync(iMSSFare, companyId);

            //Asserts
            //Get
            var result = await middlewareManager
                         .GetByIdsAsync(iMSSFare.Select(p => p.ID).ToList(), companyId);

            Assert.True(result.Any());

            //Delete
            await middlewareManager.DeleteAsync(iMSSFare.Select(p => p.ID).ToList(), companyId);

            //Get it again to verify if the registry it was deleted
            var result2 = await middlewareManager
                          .GetByIdsAsync(iMSSFare.Select(p => p.ID).ToList(), companyId);

            Assert.True(!result2.Any());
        }
        public async Task <List <IncidentType> > CreateDefaultIncidentTypeAsync(Guid identityWorkId, Guid instanceID)
        {
            var middlewareManager = new MiddlewareManager <IncidentType>(new BaseRecordManager <IncidentType>(), new IncidentTypeValidator());

            List <IncidentType> incidentTypes = new List <IncidentType>()
            {
                new IncidentType()
                {
                    ID                  = Guid.NewGuid(),
                    Active              = true,
                    company             = identityWorkId,
                    Timestamp           = DateTime.UtcNow,
                    InstanceID          = instanceID,
                    Description         = "Incident",
                    CreationDate        = DateTime.Now,
                    Name                = "Incident",
                    StatusID            = 1,
                    Code                = "2",
                    DecreasesSeventhDay = false,
                    ItConsiders         = ItConsiders.Absence,
                    Percentage          = 10,
                    SalaryRight         = true,
                    TypeOfIncident      = TypeOfIncident.Days,
                    UnitValue           = 10,
                }
            };
            await middlewareManager.CreateAsync(incidentTypes, identityWorkId);

            return(incidentTypes);
        }
        public async Task <List <ConceptPayment> > CreateDefaultSalaryPaymentConceptsAsync(Guid identityWorkId, Guid instanceID)
        {
            var memoryStorageContext = new MemoryStorageContext();

            var middlewareAccumulates = new MiddlewareManager <AccumulatedType>(new BaseRecordManager <AccumulatedType>(), new AccumulatedTypeValidator());
            var accumulatesTypes      = await middlewareAccumulates.GetAllAsync(identityWorkId, instanceID);

            if (!accumulatesTypes.Any())
            {
                accumulatesTypes = memoryStorageContext.GetDefaultAccumulatedType(identityWorkId, instanceID, Guid.NewGuid());
                await middlewareAccumulates.CreateAsync(accumulatesTypes, identityWorkId);
            }

            var resultTuple = memoryStorageContext.GetDefaultConcept <ConceptPayment>(identityWorkId, instanceID, Guid.NewGuid(), accumulatesTypes);
            var concepts    = resultTuple.Item1
                              .Cast <ConceptPayment>().ToList();

            var middlewareManagerConceptPaymentRelationship = new MiddlewareManager <ConceptPaymentRelationship>(new BaseRecordManager <ConceptPaymentRelationship>(),
                                                                                                                 new ConceptPaymentRelationshipValidator());

            var middlewareConcept = new MiddlewareManager <ConceptPayment>(new BaseRecordManager <ConceptPayment>(), new ConceptPaymentValidator());
            await middlewareConcept.CreateAsync(concepts, identityWorkId);

            var relationships = resultTuple.Item2.Cast <ConceptPaymentRelationship>().ToList();
            await middlewareManagerConceptPaymentRelationship.CreateAsync(relationships, identityWorkId);

            return(concepts);
        }
Example #7
0
            public async Task Should_Fail_When_LowerLimit_is_less_than_zero()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                //Arrange
                var identityWorkId = Guid.NewGuid();
                var instanceId     = Guid.NewGuid();

                //create one uma
                var uMAs = await new UMAManagerUT().CreateDefaultAsync <UMA>(identityWorkId, instanceId);

                //Act
                var middlewareManager = new MiddlewareManager <UMA>(new BaseRecordManager <UMA>(), new UMAValidator());


                //Asserts
                //Get
                var result = (await middlewareManager
                              .GetByIdsAsync(uMAs.Select(p => p.ID).ToList(), identityWorkId)).First();

                try
                {
                    await middlewareManager.CreateAsync(new List <UMA>() { result }, identityWorkId);

                    Assert.True(false, "Debe de mandar una excepción por registro duplicado");
                }
                catch (CotorraException ex)
                {
                    Assert.Equal(9006, ex.ErrorCode);
                }
                catch
                {
                    Assert.True(true);
                }
            }
Example #8
0
            public async Task Should_Delete()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                //Arrange
                var periodTypes    = new List <PeriodType>();
                var identityWorkId = Guid.NewGuid();
                var id             = Guid.NewGuid();

                var periodType = PeriodTypeBuilder.Build(id, identityWorkId, "Quincenal");

                periodTypes.Add(periodType);

                //Act
                var middlewareManager = new MiddlewareManager <PeriodType>(new BaseRecordManager <PeriodType>(), new PeriodTypeValidator());

                await middlewareManager.CreateAsync(periodTypes, identityWorkId);

                //Assert
                var found = await middlewareManager.GetByIdsAsync(new List <Guid>() { id }, identityWorkId);

                Assert.True(found.Any());
                var register = found.FirstOrDefault(x => x.ID == id);

                Assert.NotNull(register);

                await middlewareManager.DeleteAsync(new List <Guid>() { id }, identityWorkId);

                found = await middlewareManager.GetByIdsAsync(new List <Guid>() { id }, identityWorkId);

                register = found.FirstOrDefault(x => x.ID == id);
                Assert.Null(register);
            }
        public async Task <List <T> > CreateDefaultAsyncWithPeriodDetailID <T>(Guid identityWorkId, Guid instanceID,
                                                                               Guid employeeID, Guid periodDetailID, bool salaryRight, DateTime date) where T : BaseEntity
        {
            //Act Dependencies
            var incidentType = await new IncidentTypeManagerUT().CreateDefaultAsync <IncidentType>(identityWorkId, instanceID);

            List <Incident> IncidentTypePeriodEmployeeRelationships = new List <Incident>()
            {
                new Incident()
                {
                    ID             = Guid.NewGuid(),
                    Active         = true,
                    company        = identityWorkId,
                    Timestamp      = DateTime.UtcNow,
                    InstanceID     = instanceID,
                    Description    = "2R",
                    CreationDate   = DateTime.Now,
                    Name           = "Dos horas retardo",
                    StatusID       = 1,
                    IncidentTypeID = incidentType.FirstOrDefault(p => p.SalaryRight == salaryRight).ID,
                    PeriodDetailID = periodDetailID,
                    DeleteDate     = null,
                    Date           = date,
                    Value          = 2,
                    EmployeeID     = employeeID
                }
            };

            //Act
            var middlewareManager = new MiddlewareManager <Incident>(new BaseRecordManager <Incident>(), new IncidentValidator());
            await middlewareManager.CreateAsync(IncidentTypePeriodEmployeeRelationships, identityWorkId);

            return(IncidentTypePeriodEmployeeRelationships as List <T>);
        }
Example #10
0
            public async Task Should_Fail_When_Period_Total_Days_Is_TooBig()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                //Arrange
                var periodTypes    = new List <PeriodType>();
                var identityWorkId = Guid.NewGuid();
                var periodType     = PeriodTypeBuilder.Build(Guid.NewGuid(), identityWorkId, "name");

                periodType.PeriodTotalDays = 366;

                periodTypes.Add(periodType);

                //Act
                var middlewareManager = new MiddlewareManager <PeriodType>(new BaseRecordManager <PeriodType>(), new PeriodTypeValidator());

                try
                {
                    await middlewareManager.CreateAsync(periodTypes, identityWorkId);
                }
                catch (CotorraException ex)
                {
                    //Assert
                    var res = ex.ValidationInfo;
                    Assert.NotEmpty(res);
                    Assert.Equal(9002, ex.ErrorCode);
                }
            }
Example #11
0
            public async Task Should_NotCreate_Employee_Duplicate_Name()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                try
                {
                    //Act
                    Guid identityWorkId = Guid.NewGuid();
                    Guid instanceId     = Guid.NewGuid();
                    var  employees      = await new EmployeeManagerUT().CreateDefaultAsync <Employee>(identityWorkId, instanceId, name: "Jimmy");

                    //Modify ToDuplicate
                    employees.FirstOrDefault().ID   = Guid.NewGuid();
                    employees.FirstOrDefault().Code = "2";
                    employees.FirstOrDefault().CURP = "asdasdas";
                    employees.FirstOrDefault().RFC  = "AAA010102AAB";

                    var middlewareManager = new MiddlewareManager <Employee>(new BaseRecordManager <Employee>(), new EmployeeValidator());
                    await middlewareManager.CreateAsync(employees, identityWorkId);

                    Assert.False(true, "No se permite Nombre duplicado");
                }
                catch (Exception ex)
                {
                    Assert.True(ex is CotorraException);
                    Assert.True((ex as CotorraException).ErrorCode.Equals(4003));
                }
            }
Example #12
0
            public async Task Should_Not_Create_Duplicate_DB_JobPosition_And_Get_ToValidate_Finally_do_Delete()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                var         middlewareManager = new MiddlewareManager <JobPosition>(new BaseRecordManager <JobPosition>(), new JobPositionValidator());
                List <Guid> lstIds            = new List <Guid>();
                var         identityWorkId    = Guid.NewGuid();

                try
                {
                    //Arrange
                    var JobPositions = new List <JobPosition>();
                    JobPositions.Add(new JobPosition()
                    {
                        ID           = Guid.NewGuid(),
                        Active       = true,
                        company      = identityWorkId,
                        Timestamp    = DateTime.UtcNow,
                        InstanceID   = identityWorkId,
                        Description  = "Supervisor de ventas general",
                        CreationDate = DateTime.Now,
                        Name         = "Supervisor de Ventas",
                        StatusID     = 1,
                    });
                    lstIds.Add(JobPositions.FirstOrDefault().ID);

                    //Act
                    await middlewareManager.CreateAsync(JobPositions, identityWorkId);

                    //Asserts
                    //Get
                    var result = await middlewareManager
                                 .GetByIdsAsync(JobPositions.Select(p => p.ID).ToList(), identityWorkId);

                    Assert.True(result.Any());

                    //Act
                    await middlewareManager.CreateAsync(JobPositions, identityWorkId);

                    Assert.True(false, "No debió de pasar");
                }
                catch (Exception ex)
                {
                    Assert.True(ex is CotorraException);
                    Assert.True((ex as CotorraException).ErrorCode.Equals(1002));
                }
            }
        public async Task SalaryAdjustment_Fail_PeriodClosed()
        {
            using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
            Guid identityWorkId = Guid.NewGuid();
            Guid instanceID     = Guid.NewGuid();

            try
            {
                var employee = await new EmployeeManagerUT().CreateDefaultAsync <Employee>(
                    identityWorkId, instanceID);

                var middlewareManagerPeriodDetail = new MiddlewareManager <PeriodDetail>(new BaseRecordManager <PeriodDetail>(), new PeriodDetailValidator());
                var periodDetails = await middlewareManagerPeriodDetail.FindByExpressionAsync(p =>
                                                                                              p.InstanceID == instanceID, identityWorkId);

                var CotorriaPeriodDetail = periodDetails.FirstOrDefault();
                CotorriaPeriodDetail.PeriodStatus = PeriodStatus.Authorized;
                await middlewareManagerPeriodDetail.UpdateAsync(new List <PeriodDetail> {
                    CotorriaPeriodDetail
                }, identityWorkId);

                Guid sbcID                = Guid.NewGuid();
                var  creationDate         = DateTime.Now;
                EmployeeSBCAdjustment sbc = BuildEmployeeSBCAdjustment(sbcID, Guid.NewGuid(), identityWorkId, instanceID, creationDate, employee.FirstOrDefault().ID, 123.23M, 123.23M, 123.23M);


                EmployeeSalaryIncrease employeeSalaryIncrease = new EmployeeSalaryIncrease()
                {
                    Active                  = true,
                    company                 = identityWorkId,
                    CreationDate            = creationDate,
                    DailySalary             = 145.65M,
                    DeleteDate              = null,
                    Description             = "",
                    EmployeeID              = employee.FirstOrDefault().ID,
                    ID                      = Guid.NewGuid(),
                    user                    = Guid.NewGuid(),
                    InstanceID              = instanceID,
                    ModificationDate        = periodDetails.OrderBy(p => p.InitialDate).FirstOrDefault().InitialDate.AddDays(2),
                    Name                    = "",
                    StatusID                = 1,
                    Timestamp               = DateTime.Now,
                    EmployeeSBCAdjustment   = sbc,
                    EmployeeSBCAdjustmentID = sbc.ID
                };
                var middlewareManager = new MiddlewareManager <EmployeeSalaryIncrease>(new BaseRecordManager <EmployeeSalaryIncrease>());
                await middlewareManager.CreateAsync(new List <EmployeeSalaryIncrease>() { employeeSalaryIncrease }, identityWorkId);

                Assert.True(true, "No debió de pasar");
            }
            catch (CotorraException ex)
            {
                Assert.True(ex.Code == "4005");
            }
            catch
            {
                Assert.True(true, "No debió de pasar");
            }
        }
Example #14
0
        public async Task <List <MinimunSalary> > CreateAsync(Guid identityWorkId, Guid instanceID)
        {
            var middlewareManager = new MiddlewareManager <MinimunSalary>(new BaseRecordManager <MinimunSalary>(), new MinimunSalaryValidator());
            var lstMinimunSalary  = new MemoryStorageContext().GetDefaultMinimunSalaries(identityWorkId, instanceID, Guid.NewGuid());

            await middlewareManager.CreateAsync(lstMinimunSalary, identityWorkId);

            return(lstMinimunSalary);
        }
Example #15
0
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceId) where T : BaseEntity
        {
            var MonthlyIncomeTaxs = new MemoryStorageContext().GetDefaultMonthlyEmploymentSubsidy(identityWorkId, instanceId, Guid.Empty);

            var middlewareManager = new MiddlewareManager <MonthlyEmploymentSubsidy>(new BaseRecordManager <MonthlyEmploymentSubsidy>(), new MonthlyEmploymentSubsidyValidator());
            await middlewareManager.CreateAsync(MonthlyIncomeTaxs, identityWorkId);

            return(MonthlyIncomeTaxs as List <T>);
        }
Example #16
0
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceId) where T : BaseEntity
        {
            var Areas = Build <T>(identityWorkId, instanceId) as  List <Area>;

            var middlewareManager = new MiddlewareManager <Area>(new BaseRecordManager <Area>(), new AreaValidator());
            await middlewareManager.CreateAsync(Areas, identityWorkId);

            return(Areas as List <T>);
        }
Example #17
0
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceID, PaymentPeriodicity paymentPeriodicity) where T : BaseEntity
        {
            var  periodTypes        = new List <PeriodType>();
            var  namePeriodicity    = Enum.GetName(typeof(PaymentPeriodicity), paymentPeriodicity);
            var  periodTotalDays    = 0;
            var  paymentDays        = 0;
            var  paymentDayPosition = 0;
            bool monthCalendarFixed = true;

            if (paymentPeriodicity == PaymentPeriodicity.Biweekly)
            {
                periodTotalDays    = 15;
                paymentDays        = 15;
                paymentDayPosition = 15;
                monthCalendarFixed = true;
            }
            else if (paymentPeriodicity == PaymentPeriodicity.Monthly)
            {
                periodTotalDays    = 30;
                paymentDays        = 30;
                paymentDayPosition = 30;
                monthCalendarFixed = true;
            }
            else if (paymentPeriodicity == PaymentPeriodicity.Weekly)
            {
                periodTotalDays    = 7;
                paymentDays        = 7;
                paymentDayPosition = 7;
                monthCalendarFixed = false;
            }

            periodTypes.Add(new PeriodType()
            {
                ID                   = Guid.NewGuid(),
                Active               = true,
                company              = identityWorkId,
                Timestamp            = DateTime.UtcNow,
                InstanceID           = instanceID,
                Description          = $"Periodo de pago {namePeriodicity}",
                CreationDate         = DateTime.Now,
                Name                 = namePeriodicity,
                StatusID             = 1,
                PaymentPeriodicity   = paymentPeriodicity,
                PeriodTotalDays      = periodTotalDays,
                PaymentDays          = paymentDays,
                ExtraordinaryPeriod  = false,
                MonthCalendarFixed   = monthCalendarFixed,
                FortnightPaymentDays = AdjustmentPay_16Days_Febrary.PayCalendarDays,
                PaymentDayPosition   = paymentDayPosition
            });

            //Act
            var middlewareManager = new MiddlewareManager <PeriodType>(new BaseRecordManager <PeriodType>(), new PeriodTypeValidator());
            await middlewareManager.CreateAsync(periodTypes, identityWorkId);

            return(periodTypes as List <T>);
        }
Example #18
0
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceId) where T : BaseEntity
        {
            var umas = new MemoryStorageContext().GetdDefaultUMA(identityWorkId, instanceId, Guid.Empty);

            var middlewareManager = new MiddlewareManager <UMA>(new BaseRecordManager <UMA>(), new UMAValidator());
            await middlewareManager.CreateAsync(umas, identityWorkId);

            return(umas as List <T>);
        }
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceId) where T : BaseEntity
        {
            var AnualIncomeTaxs = new MemoryStorageContext().GetDefaultAnualIncomeTax(identityWorkId, instanceId, Guid.Empty);

            var middlewareManager = new MiddlewareManager <AnualIncomeTax>(new BaseRecordManager <AnualIncomeTax>(),
                                                                           new AnualIncomeTaxValidator());
            await middlewareManager.CreateAsync(AnualIncomeTaxs, identityWorkId);

            return(AnualIncomeTaxs as List <T>);
        }
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceID)
        {
            var IMSSWorkRiskTableLst = new List <IMSSWorkRisk>();

            IMSSWorkRiskTableLst.AddRange(new MemoryStorageContext().GetDefaultIMSSWorkRisk(identityWorkId, instanceID, Guid.Empty));

            var middlewareManager = new MiddlewareManager <IMSSWorkRisk>(new BaseRecordManager <IMSSWorkRisk>(), new IMSSWorkRiskValidator());
            await middlewareManager.CreateAsync(IMSSWorkRiskTableLst, identityWorkId);

            return(IMSSWorkRiskTableLst as List <T>);
        }
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceID)
        {
            var SGDFLimitsLst = new List <SGDFLimits>();

            SGDFLimitsLst.AddRange(new MemoryStorageContext().GetDefaultSGDFLimits(identityWorkId, instanceID, Guid.Empty));

            var middlewareManager = new MiddlewareManager <SGDFLimits>(new BaseRecordManager <SGDFLimits>(), new SGDFLimitsValidator());
            await middlewareManager.CreateAsync(SGDFLimitsLst, identityWorkId);

            return(SGDFLimitsLst as List <T>);
        }
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceID)
        {
            var settlementList = new List <SettlementCatalog>();

            settlementList.AddRange(new MemoryStorageContext().GetDefaultSettlementCatalogTable(identityWorkId, instanceID, Guid.Empty));

            var middlewareManager = new MiddlewareManager <SettlementCatalog>(new BaseRecordManager <SettlementCatalog>(),
                                                                              new SettlementCatalogValidator());
            await middlewareManager.CreateAsync(settlementList, identityWorkId);

            return(settlementList as List <T>);
        }
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceId) where T : BaseEntity
        {
            var WorkCenters = new List <WorkCenter>();

            WorkCenters.Add(BuildT <WorkCenter>(identityWorkId, instanceId));

            var middlewareManager = new MiddlewareManager <WorkCenter>(new BaseRecordManager <WorkCenter>(),
                                                                       new WorkCenterValidator());
            await middlewareManager.CreateAsync(WorkCenters, identityWorkId);

            return(WorkCenters as List <T>);
        }
Example #24
0
        public async Task <AreaDTO> Post(Guid instanceID, Guid userID, Guid identityWorkID, AreaValidator validator, IMapper mapper,
                                         AreaDTO AreaDTO)
        {
            Area dep = new Area();

            mapper.Map(AreaDTO, dep);
            dep.InstanceID = instanceID;
            dep.CompanyID  = identityWorkID;

            var mgr = new MiddlewareManager <Area>(new BaseRecordManager <Area>(), validator);
            await mgr.CreateAsync(new List <Area>() { dep }, identityWorkID);

            return(AreaDTO);
        }
Example #25
0
        public async Task <DepartmentDTO> Post(Guid instanceID, Guid userID, Guid identityWorkID, DepartmentValidator validator, IMapper mapper,
                                               DepartmentDTO departmentDTO)
        {
            Department dep = new Department();

            mapper.Map(departmentDTO, dep);
            dep.InstanceID = instanceID;
            dep.CompanyID  = identityWorkID;

            var mgr = new MiddlewareManager <Department>(new BaseRecordManager <Department>(), validator);
            await mgr.CreateAsync(new List <Department>() { dep }, identityWorkID);

            return(departmentDTO);
        }
            public async Task ShouldFailWhen2ValuesAreBadSending2Objects()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                //Arrange
                var Workshifts     = new List <Workshift>();
                var identityWorkId = Guid.NewGuid();

                Workshifts.Add(new Workshift()
                {
                    ID           = Guid.NewGuid(),
                    Active       = true,
                    company      = identityWorkId,
                    Timestamp    = DateTime.UtcNow,
                    InstanceID   = Guid.NewGuid(),
                    Description  = "Turno mixto",
                    CreationDate = DateTime.Now,
                    Name         = "",
                    StatusID     = 1,
                    Hours        = 49
                });

                Workshifts.Add(new Workshift()
                {
                    ID           = Guid.NewGuid(),
                    Active       = true,
                    company      = identityWorkId,
                    Timestamp    = DateTime.UtcNow,
                    InstanceID   = Guid.NewGuid(),
                    Description  = "Turno mixto",
                    CreationDate = DateTime.Now,
                    Name         = "",
                    StatusID     = 1,
                    Hours        = 49
                });

                //Act
                var middlewareManager = new MiddlewareManager <Workshift>(new BaseRecordManager <Workshift>(), new WorkshiftValidator());

                try
                {
                    await middlewareManager.CreateAsync(Workshifts, identityWorkId);
                }
                catch (CotorraException ex)
                {
                    var res = ex.ValidationInfo;
                    Assert.NotEmpty(res);
                    Assert.Equal(8001, ex.ErrorCode);
                }
            }
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceID) where T : BaseEntity
        {
            var permanentMovements = new List <PermanentMovement>();
            List <ConceptPayment> conceptPayments = null;

            var employees = await(new EmployeeManagerUT().CreateDefaultAsync <Employee>(identityWorkId: identityWorkId, instanceID: instanceID, randomValues: true));

            var middlewareConceptPaymentManager = new MiddlewareManager <ConceptPayment>(new BaseRecordManager <ConceptPayment>(), new ConceptPaymentValidator());

            conceptPayments = await middlewareConceptPaymentManager.FindByExpressionAsync(p => p.InstanceID == instanceID, identityWorkId);

            if (!conceptPayments.Any())
            {
                conceptPayments = await(new ConceptManagerUT().CreateDefaultSalaryPaymentConceptsAsync(identityWorkId, instanceID));
            }

            permanentMovements.Add(new PermanentMovement()
            {
                AccumulatedAmount = 0,
                Active            = true,
                Amount            = 500,
                company           = identityWorkId,
                ConceptPaymentID  = conceptPayments.FirstOrDefault(p => p.ConceptType == ConceptType.SalaryPayment && p.Name == "Sueldo").ID,
                EmployeeID        = employees.FirstOrDefault().ID,
                ControlNumber     = 0,
                CreationDate      = DateTime.UtcNow,
                DeleteDate        = null,
                Description       = "",
                ID = Guid.NewGuid(),
                InitialApplicationDate = DateTime.UtcNow,
                LimitAmount            = 0,
                Name = "Movimiento permamente sueldito",
                PermanentMovementStatus = PermanentMovementStatus.Active,
                PermanentMovementType   = PermanentMovementType.Amount,
                RegistryDate            = DateTime.UtcNow,
                StatusID     = 1,
                TimesApplied = 0,
                TimesToApply = 5,
                user         = Guid.NewGuid(),
                InstanceID   = instanceID,
                Timestamp    = DateTime.UtcNow
            });

            var middlewareManager = new MiddlewareManager <PermanentMovement>(new BaseRecordManager <PermanentMovement>(), new PermanentMovementValidator());
            await middlewareManager.CreateAsync(permanentMovements, identityWorkId);

            return(permanentMovements as List <T>);
        }
Example #28
0
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceId) where T : BaseEntity
        {
            var middlewareEmployeeManager = new MiddlewareManager <Employee>(new BaseRecordManager <Employee>(), new EmployeeValidator());
            var employees = (await middlewareEmployeeManager.FindByExpressionAsync(p => p.Active && p.InstanceID == instanceId, identityWorkId));

            if (!employees.Any())
            {
                employees = (await new EmployeeManagerUT().CreateDefaultAsync <Employee>(identityWorkId: identityWorkId, instanceID: instanceId));
            }

            var middlewareConceptManager = new MiddlewareManager <ConceptPayment>(new BaseRecordManager <ConceptPayment>(), new ConceptPaymentValidator());
            var concepts = (await middlewareConceptManager.FindByExpressionAsync(p => p.Active && p.InstanceID == instanceId, identityWorkId));

            if (!concepts.Any())
            {
                concepts = (await new ConceptManagerUT().CreateDefaultSalaryPaymentConceptsAsync(identityWorkId, instanceId));
            }

            var fonacotMovements = new List <FonacotMovement>();

            fonacotMovements.Add(new FonacotMovement()
            {
                ID                    = Guid.NewGuid(),
                Active                = true,
                company               = identityWorkId,
                Timestamp             = DateTime.UtcNow,
                InstanceID            = instanceId,
                Description           = "Departamento de nominas",
                CreationDate          = DateTime.Now,
                Name                  = "Nominas",
                StatusID              = 1,
                ConceptPaymentID      = concepts.FirstOrDefault().ID,
                CreditNumber          = "AA010101",
                DeleteDate            = null,
                EmployeeID            = employees.FirstOrDefault().ID,
                FonacotMovementStatus = FonacotMovementStatus.Active,
                Month                 = 1,
                Year                  = 2020,
                Observations          = "Observations",
                RetentionType         = RetentionType.FixedAmount,
                user                  = Guid.Empty,
            });

            var middlewareManager = new MiddlewareManager <FonacotMovement>(new BaseRecordManager <FonacotMovement>(), new FonacotMovementValidator());
            await middlewareManager.CreateAsync(fonacotMovements, identityWorkId);

            return(fonacotMovements as List <T>);
        }
        public async Task <NOMSurveyReplyResult> CreateAsync(NOMSurveyReplyParams nOMSurveyReplyParams)
        {
            BeforeCreate(nOMSurveyReplyParams);

            var result = new NOMSurveyReplyResult();

            using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

            var NOMSurveyReply = CreateDefault(
                nOMSurveyReplyParams.IdentityWorkId,
                nOMSurveyReplyParams.InstanceId,
                nOMSurveyReplyParams.EmployeeId,
                nOMSurveyReplyParams.NOMEvaluationPeriodId,
                nOMSurveyReplyParams.NOMEvaluationSurveyId);

            await SetAnswers(NOMSurveyReply);

            //middleware instance
            var middlewareManager = new MiddlewareManager <NOMSurveyReply>(new BaseRecordManager <NOMSurveyReply>(), new NOMSurveyReplyValidator());

            //Get
            var resultPrevious = await middlewareManager.FindByExpressionAsync(p =>
                                                                               p.EmployeeID == nOMSurveyReplyParams.EmployeeId &&
                                                                               p.EvaluationState != EvaluationStateType.Answered &&
                                                                               p.NOMEvaluationPeriod.ID == nOMSurveyReplyParams.NOMEvaluationPeriodId, nOMSurveyReplyParams.IdentityWorkId);

            //verify if exists pending surverreply for employee
            if (!resultPrevious.Any())
            {
                //Create
                var lstToCreate = new List <NOMSurveyReply>();
                lstToCreate.Add(NOMSurveyReply);
                await middlewareManager.CreateAsync(lstToCreate, nOMSurveyReplyParams.IdentityWorkId);
            }

            //Encrypt and encode de token
            var encrypted        = StringCipher.Encrypt(NOMSurveyReply.ID.ToString());
            var encryptedEncoded = HttpUtility.UrlEncode(encrypted);

            result.NOMSurveyReply = NOMSurveyReply;
            result.Token          = encryptedEncoded;

            scope.Complete();

            return(result);
        }
        public async Task <List <T> > CreateDefaultAsync <T>(Guid identityWorkId, Guid instanceID) where T : BaseEntity
        {
            //Act Dependencies

            var accumulatedTypes = new MemoryStorageContext().GetDefaultAccumulatedType(identityWorkId, instanceID, Guid.NewGuid());
            List <IncidentType> incidentTypes = new MemoryStorageContext().GetDefaultIncidentType(identityWorkId, instanceID, Guid.NewGuid(), accumulatedTypes);

            //AcumulatedTypes
            var middlewareManagerAccumulatedType = new MiddlewareManager <AccumulatedType>(new BaseRecordManager <AccumulatedType>(), new AccumulatedTypeValidator());
            await middlewareManagerAccumulatedType.CreateAsync(accumulatedTypes, identityWorkId);

            //IncidentTypes
            var middlewareManagerIncidentType = new MiddlewareManager <IncidentType>(new BaseRecordManager <IncidentType>(), new IncidentTypeValidator());
            await middlewareManagerIncidentType.CreateAsync(incidentTypes, identityWorkId);

            return(incidentTypes as List <T>);
        }