public static async Task <IResult> HistoryById(int beanid, int days, IMovementService movementService) { if (beanid <= 0) { return(Results.BadRequest(new ApiError(string.Format(Strings.Invalid, "bean id")))); } var date = days == 0 ? default : DateTime.UtcNow.AddDays(-(days - 1)); var movements = await movementService.HistoryAsync(beanid, date); return(Results.Ok(movements)); }
public static async Task <IResult> HistoryByName(string beanname, int days, IMovementService movementService, IBeanService beanService) { if (string.IsNullOrWhiteSpace(beanname)) { return(Results.BadRequest(new ApiError(string.Format(Strings.Invalid, "bean name")))); } var bean = await beanService.ReadAsync(beanname); if (bean is null) { return(Results.BadRequest(new ApiError(string.Format(Strings.ItemNotFound, "bean", "name", beanname)))); } var date = days == 0 ? default : DateTime.UtcNow.AddDays(-(days - 1)); var movements = await movementService.HistoryAsync(bean.Id, date); return(Results.Ok(movements)); }