Esempio n. 1
0
        private static async Task <int> GetRecordID(int domainID, UpdateModel um)
        {
            int recordID;
            var records = await RecordService.GetList(domainID, um.SubDomain);

            if (records.Status.Code != 1)
            {
                throw new APIException(records.Status);
            }


            var record = records.Records.FirstOrDefault(_ => _.Type == "A" && _.Enabled == 1);

            if (record == null)
            {
                var newRecord = await RecordService.CreateRecord(domainID, um.SubDomain, "A", um.LineName, "0.0.0.0", 0, 300);

                if (newRecord.Status.Code != 1)
                {
                    throw new APIException(newRecord.Status);
                }

                recordID = newRecord.Info.RecordID;
            }
            else
            {
                recordID = record.ID;
            }

            return(recordID);
        }
        static void Main(string[] args)
        {
            var container = new Container(_ =>
            {
                _.Scan(x =>
                {
                    x.TheCallingAssembly();
                    x.WithDefaultConventions();
                });
            });

            var service = new RecordService <Guid>(Guid.NewGuid());

            service
            .CreateRecord(new ActiveOrderConfiguration(service.AggregateId))
            .CreatedRelatedRecord(new ChildRecordPassedIn())
            .AssignAggregateId()
            .ExecuteAction(new CustomExecutor())
            .Delay(5000)
            .ExecuteActionOnAggregate(new CustomExecutor())
            .Delay(1000)
            .If(DateTime.Now.Hour > 15, x => x.CreateRelatedRecord(new ActiveOrderConfiguration(Guid.NewGuid())))
            .AssertAgainst(new MustBeCancelled())
            .Cleanup(new Cleanup());
        }
Esempio n. 3
0
        public void CreateRecord()
        {   //Arrange
            using (RecordService service = new RecordService())
            {
                //Act
                Exception error = null;

                try
                {
                    int randomNumber = new Random().Next(1, 1000);

                    service.CreateRecord(new RecordDTO()
                    {
                        UserId         = randomNumber,
                        TaskId         = randomNumber,
                        Hours          = 2.36,
                        RecordDateTime = DateTime.Now,
                        ProjectId      = randomNumber
                    });
                }
                catch (Exception E)
                {
                    error = E;
                }

                //Assert
                Assert.Null(error);
            }
        }
Esempio n. 4
0
 public ActionResult CreateRecord(Record record)
 {
     try
     {
         _recordService.CreateRecord(record);
         return(Ok());
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }