Example #1
0
 public SaleService(ISaleRepository saleRepository, IUserRepository userRepository, IBeanRepository beanRepository, IOptions <AppSettings> settings,
                    ITimeSpanConverter timeSpanConverter)
 {
     _saleRepository   = saleRepository;
     _userRepository   = userRepository;
     _beanRepository   = beanRepository;
     _longtermTimespan = timeSpanConverter.Convert(settings.Value.LongTermSpan);
 }
Example #2
0
    public static async Task <IResult> ById(int userid, ITimeSpanConverter converter, IOptions <AppSettings> settings, ISaleService saleService)
    {
        if (userid <= 0)
        {
            return(Results.BadRequest(new ApiError(string.Format(Strings.Invalid, "user id"))));
        }
        var longTermSpan = converter.Convert(settings.Value.LongTermSpan);

        if (longTermSpan == TimeSpan.Zero)
        {
            longTermSpan = TimeSpan.FromDays(365);
        }
        var sales = await saleService.GetForUserAsync(userid);

        if (sales is not null && sales.Any())
        {
            sales.ForEach(x => x.LongTerm = x.SaleDate - x.PurchaseDate >= longTermSpan);
        }
        return(Results.Ok(sales));
    }
Example #3
0
 public CsvFileDataProcessor(ITimeSpanConverter converter, char csvSplitByCharacter)
 {
     _converter           = converter;
     _csvSplitByCharacter = csvSplitByCharacter;
 }
 public SortingProvider(IConfiguration configuration, ITimeSpanConverter converter)
 {
     _configuration = configuration;
     _converter     = converter;
 }
Example #5
0
        public void ConvertStringToTimeSpan(ITimeSpanConverter conv, string input, TimeSpan output)
        {
            var result = conv.ToTimeSpan(input);

            Assert.AreEqual(output, result);
        }
Example #6
0
        public void ConvertTimeSpanToString(ITimeSpanConverter conv, TimeSpan input, string output)
        {
            var result = conv.ToString(input);

            Assert.AreEqual(output, result);
        }