public int CalculateMissingAmount(HomeProductManagerContext context, int periodTypeId) { if (Period.PeriodTypeId == periodTypeId) { return(UnitAmount - (ProductAmountExist.HasValue ? ProductAmountExist.Value : 0)); } PeriodType expectedPeriod = context.PeriodTypes.FirstOrDefault(pr => pr.PeriodTypeId == periodTypeId); decimal unitAmount = UnitAmount; decimal periodInDays = Period.PeriodInDays; decimal expectedPeriodInDays = expectedPeriod.PeriodInDays;; decimal missingAmount = (unitAmount / periodInDays) * expectedPeriodInDays; return((int)Math.Ceiling(missingAmount)); }
/// <summary> /// Initializes a new instance of the <see cref="CategoryRepository"/> class. /// </summary> /// <param name="context">The context.</param> public CategoryRepository(HomeProductManagerContext context) { _context = context; }
/// <summary> /// Initializes a new instance of the <see cref="PeriodTypeRepository"/> class. /// </summary> /// <param name="context">The context.</param> public PeriodTypeRepository(HomeProductManagerContext context) { _context = context; }
/// <summary> /// Initializes a new instance of the <see cref="ProductRepository"/> class. /// </summary> /// <param name="context">The context.</param> public ProductRepository(HomeProductManagerContext context) { _context = context; }
/// <summary> /// Initializes a new instance of the <see cref="UnitTypeRepository"/> class. /// </summary> /// <param name="context">The context.</param> public UnitTypeRepository(HomeProductManagerContext context) { _context = context; }