private double[] GetBurndown(ExpensesType type) { var burnValues = new double[nOfDays]; var incomeSum = GetIncomeSum(type); var yesterdaySum = burnValues[0] = incomeSum; for (var i = 1; i < nOfDays; i++) { burnValues[i] = yesterdaySum; switch (type) { case ExpensesType.Daily: burnValues[i] -= (double)period.GetSumOfDailyExpensesOfDate(period.startDate.AddDays(i - 1)); break; case ExpensesType.All: burnValues[i] -= (double)period.GetSumOfAllExpensesOfDate(period.startDate.AddDays(i - 1)); break; } yesterdaySum = burnValues[i]; SetMinValue(burnValues[i]); } return(burnValues); }
public async Task <IActionResult> Edit(int id, [Bind("ExpensesTypeID,ExpensesTypeName")] ExpensesType expensesType) { if (id != expensesType.ExpensesTypeID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(expensesType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ExpensesTypeExists(expensesType.ExpensesTypeID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(expensesType)); }
public ExpensesInfo(Guid id, double expenditure, string comment, DateTime costsDate, ExpensesType expensesType) { Id = id; Expenditure = expenditure; Comment = comment; СostsDate = costsDate; ExpensesType = expensesType; }
public ExpensesInfo(double expenditure, string comment, DateTime costsDate, ExpensesType expensesType) { Id = Guid.NewGuid(); Expenditure = expenditure; Comment = comment; СostsDate = costsDate; ExpensesType = expensesType; }
public async Task <IActionResult> Create([Bind("ExpensesTypeID,ExpensesTypeName")] ExpensesType expensesType) { if (ModelState.IsValid) { _context.Add(expensesType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(expensesType)); }
public void Get_ExpensesWithType_Just_Good() { var getDbContext = new GetDbContextDAL(); var context = getDbContext.ReturnDbContext(); var et = context.ExpensesEntity.Include(x => x.Type).ToList(); ExpensesType newType = new ExpensesType(); Assert.Equal(newType.GetType(), et.Select(x => x.Type).FirstOrDefault().GetType()); }
public static string GetDescriptionFromValue(string value) { ExpensesType Value = (ExpensesType)Enum.Parse(typeof(ExpensesType), value); string Description = Value.GetType().GetMember(value)[0] .GetCustomAttributes(true) .OfType <DescriptionAttribute>() .First() .Description; return(Description); }
public void Get_ExpensesMonthlyWithType_Just_Good() { //Facts var getDbContext = new GetDbContextDAL(); var context = getDbContext.ReturnDbContext(); var et = context.ExpensesMonthly.Include(x => x.Type).ToList(); //Arrangement ExpensesType newType = new ExpensesType(); Assert.Equal(newType.GetType(), et.Select(x => x.Type).FirstOrDefault().GetType()); }
private double GetIncomeSum(ExpensesType type) { var sum = (double)(period.GetSumOfIncomes()); switch (type) { case ExpensesType.Daily: sum -= (double)period.GetSumOfMonthlyExpenses(); break; case ExpensesType.All: break; } return(sum); }
private double[] GetAverageBurndown(ExpensesType type) { var avgBurnValues = new double[nOfDays]; var incomeSum = GetIncomeSum(type); var plannedSavings = (double)period.plannedSavings; for (var i = 0; i < nOfDays; i++) { var a = -(incomeSum - plannedSavings) / (nOfDays - 1); var b = incomeSum; avgBurnValues[i] = a * i + b; SetMinValue(avgBurnValues[i]); } return(avgBurnValues); }
/// <summary> /// Add an entity. /// </summary> /// <param name="model"></param> /// <returns></returns> public ExpensesTypeViewModel Add(ExpensesTypeViewModel model) { this.ThrowExceptionIfExist(model); var entity = model.ToEntity(); entity = this._ExpensesTypesRepository.Add(entity); var entityAr = new ExpensesType { Id = entity.Id, Name = model.NameAr, Description = model.DescriptionAr, Language = Framework.Common.Enums.Language.Arabic }; entity.ChildTranslatedExpensesTypes.Add(entityAr); this._ExpensesTypesRepository.Add(entityAr); var entityEn = new ExpensesType { Id = entity.Id, Name = model.NameEn, Description = model.DescriptionEn, Language = Framework.Common.Enums.Language.English }; entity.ChildTranslatedExpensesTypes.Add(entityEn); this._ExpensesTypesRepository.Add(entityEn); #region Commit Changes this._unitOfWork.Commit(); #endregion model = entity.ToModel(); return(model); }
public JsonResult AddExpensesType(ExpensesType model) { var result = false; try { ExpensesType newExpesne = new ExpensesType(); newExpesne.name = model.name; newExpesne.comment = model.comment; _db.ExpensesType.Add(newExpesne); _db.SaveChanges(); result = true; } catch (Exception ex) { throw ex; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public IEnumerable <ViewExpensesInfo> Search(string searchingText, DateTime fromExpensesDate, DateTime toExpensesDate, bool isDateConsider, ExpensesType selectedExpensesType, double expensesDiap1, double expensesDiap2, IEnumerable <ViewExpensesInfo> lst) { List <ViewExpensesInfo> SearchedExpenses = new List <ViewExpensesInfo>(); foreach (ViewExpensesInfo item in lst) { SearchedExpenses.Add((ViewExpensesInfo)item.Clone()); } if (searchingText != null && searchingText != string.Empty && searchingText != DefaultValuesForControllers.Instance.DefaultSearchStringContent) { SearchedExpenses = SearchedExpenses.Where(expensesInfo => expensesInfo.Comment.IndexOf(searchingText, StringComparison.OrdinalIgnoreCase) >= 0).ToList(); } if (isDateConsider) { SearchedExpenses = SearchedExpenses.Where(expensesInfo => (DateTime.Compare(DateTime.Parse(expensesInfo.CostsDate), fromExpensesDate) >= 0) && (DateTime.Compare(DateTime.Parse(expensesInfo.CostsDate), toExpensesDate) <= 0)).ToList(); } if (selectedExpensesType != ExpensesType.Any) { SearchedExpenses = SearchedExpenses.Where(expensesInfo => expensesInfo.ExpensesType == selectedExpensesType.GetType() .GetMember(selectedExpensesType.ToString())[0] .GetCustomAttributes(true) .OfType <DescriptionAttribute>() .First() .Description).ToList(); } SearchedExpenses = SearchedExpenses.Where(expensesInfo => expensesInfo.Expenditure >= expensesDiap1 && expensesInfo.Expenditure <= expensesDiap2).ToList(); List <ViewExpensesInfo> expensesInfos = new List <ViewExpensesInfo>(); foreach (ViewExpensesInfo exp in SearchedExpenses) { exp.Expenditure = Math.Round(exp.Expenditure, DefaultValuesForControllers.Instance.DefaultDecimals); expensesInfos.Add(exp); } return(expensesInfos); }