Exemple #1
0
        public IHttpActionResult AddTenant(AddTenantRequest request)
        {
            request.ValidateNotNull();
            TenantDomain tenantDomain = new TenantDomain()
            {
                //Identifier = request.Identifier,
                Name              = request.Name,
                IsActive          = request.IsActive,
                DefaultLanguageId = request.DefaultLanguageId
            };

            return(Ok(new AddTenantResponse()
            {
                Data = _tenantManipulation.AddTenant(tenantDomain),
                Success = Common.Enumerations.ResponseStatus.Succeeded
            }));
        }
        public async Task <IActionResult> AddTenant(AddTenantRequest request)
        {
            Logger.LogDebug(
                $"{nameof(TenantController)} - {nameof(AddTenant)} method called with this input: {request}");

            if (string.IsNullOrWhiteSpace(request.Identifier) || string.IsNullOrWhiteSpace(request.Name))
            {
                return(BadRequest(new { Message = ErrorKeys.ParameterNull }));
            }

            var input  = Mapping.AutoMapper.Mapper.Map <Tenant>(request);
            var result = await _tenantLogic.AddTenant(input);

            if (result?.Error != null)
            {
                return(BadRequest(new { Message = result.Error }));
            }

            return(Ok(ApiValidatedResult <AddTenantResponse> .Ok(
                          Mapping.AutoMapper.Mapper.Map <AddTenantResponse>(input))));
        }