Exemple #1
0
        public ActionResult Create(CreateOrganisationViewModel vm)
        {
            PrepareViewModel(vm);
            var validator = new OrganisationCreationValidator(ModelState, currencyRepository, entityRepository, organisationRepository);

            if (validator.Validate(vm, SessionHelper.CurrentEntity))
            {
                var param = new CreateOrganisationParameters()
                {
                    Name      = vm.OrganisationName,
                    OwnerID   = SessionHelper.CurrentEntity.EntityID,
                    CountryID = vm.CountryID
                };

                var org = organisationService.CreateOrganisation(param);

                Transaction adminTransaction, countryTransaction;
                prepareTransactions(vm, SessionHelper.CurrentEntity, org, org.Country, out adminTransaction, out countryTransaction);

                transactionService.MakeTransaction(adminTransaction);
                transactionService.MakeTransaction(countryTransaction);

                return(RedirectToHome());
            }

            return(View(vm));
        }
        public async Task <ActionResult <CreatedDto> > CreateOrganisation([FromBody] OrganisationDto organisationDto)
        {
            int createdId = await _organisationService.CreateOrganisation(organisationDto);

            return(Created($"/organisations/{createdId}",
                           new CreatedDto {
                Id = createdId
            }));                                    //TODO: Configure Base Url from configuration
        }
        public ActionResult CreateOrganisation([FromBody] OrganisationModelCreate organisationModel)
        {
            try
            {
                string userId = User.Identity.Name;

                int organisationId = _organisationService.CreateOrganisation(organisationModel, int.Parse(userId));

                var organisationReadDto = _mapper.Map <OrganisationReadDto>(organisationModel);

                return(CreatedAtRoute("getOrganisationById", new { Id = organisationId }, organisationReadDto));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Exemple #4
0
 public async Task <bool> CreateOrganisation([FromBody] CreateOrganisationRequest request)
 {
     return(await organisationService.CreateOrganisation(request));
 }