예제 #1
0
        private async Task <int> PopulateBusinessServices(InitializeData request)
        {
            var counter = 0;

            if (request.PopulateBusinessServices)
            {
                if (request.DeleteDataIfExists)
                {
                    await _businessServiceRepository.DeleteAllAsync();
                }
                var csv = GetEmbeddedResourceAsString("Overture.Core.Domain.InitialData.business_services.csv");
                using (var reader = new CsvReader(new StringReader(csv)))
                {
                    while (reader.Read())
                    {
                        var record = reader.GetRecord <dynamic>();
                        await _businessServiceRepository.AddAsync(new BusinessService
                        {
                            Name         = record.Name,
                            CategoryName = record.Category
                        });

                        counter++;
                    }
                }
            }
            return(counter);
        }
예제 #2
0
 public async Task <UseCaseResult <Models.BusinessServiceModel> > Handle(CreateBusinessService request, CancellationToken cancellationToken)
 {
     try
     {
         return(new UseCaseResult <Models.BusinessServiceModel>
         {
             ResultCode = "Ok",
             ResultText = "CreateBusinessService",
             Data = _mapper.Map <Models.BusinessServiceModel>(await _repository.AddAsync(new Domain.Entities.BusinessService
             {
                 Name = request.Name,
                 CategoryName = request.CategoryName
             }))
         });
     }
     catch (Exception e)
     {
         return(new UseCaseResult <Models.BusinessServiceModel>
         {
             ResultCode = "Error",
             ResultText = e.Message,
         });
     }
 }