public void Create(DateTime startSession, int duration, string training, string trainer, string location, string student, string company)
        {
            if (training.IsEmpty() || trainer.IsEmpty() || location.IsEmpty() || student.IsEmpty() || company.IsEmpty())
            {
                return;
            }

            var key = $"{training}-{startSession:d}";

            try
            {
                if (!Mapper.Exists(key))
                {
                    var session = App.Command <PlanSession>().Execute(
                        _trainingCreator.GetId(_trainingCreator.ConstructKey(training)),
                        startSession, duration, 20,
                        _locationCreator.GetId(_locationCreator.ConstructKey(location)),
                        _trainerCreator.GetId(_trainerCreator.ConstructKey(trainer)));

                    Mapper.Add(key, session.AggregateId);
                }

                var seat = App.Command <BookSeat>().Execute(Mapper.GetId(key),
                                                            _studentCreator.GetId(_studentCreator.ConstructKey(student)),
                                                            _companyCreator.GetCompanyId(_companyCreator.ConstructKey(company)), false);

                App.Command <ValidateSeat>().Execute(seat.AggregateId, false);
            }
            catch (DomainException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #2
0
        public void Create(string contact, string email, string telephone, string companyName)
        {
            if (companyName.IsEmpty())
            {
                return;
            }
            if (contact.IsEmpty())
            {
                return;
            }

            if (Mapper.Exists(ConstructKey(contact)))
            {
                return;
            }

            var contactName    = new Name(contact);
            var createdContact = App.Command <CreateContact>().Execute(_companyCreator.GetCompanyId(companyName), contactName.Lastname, contactName.Firstname, email, telephone);

            Mapper.Add(ConstructKey(contact), createdContact.AggregateId);
        }