public void IsItWorthSellingOrOwning(int numberOfYears) { Selling s2 = new Selling(); double c = s2.GetMoneyLeft(720000, 560500, 3); double f = s2.GetMoneyGainedOnSelling(c, 12, numberOfYears); Console.WriteLine("The money gained on Selling the property in " + numberOfYears + " years is " + f); double sellingbenefit = s2.moneygainedonselling; Owning o2 = new Owning(); o2.LessSaleCost(720000, 4, 3); o2.MoneyGainedOnOwning(33319.2, 720000, 4, 560500, numberOfYears); Console.WriteLine("The money gained on Owning the property in " + numberOfYears + " years is " + o2.moneygainedonowning); double owningbenefit = o2.moneygainedonowning; if (sellingbenefit < owningbenefit) { Console.WriteLine("Hello Sandeep, Please own the property for benefit. Good Luck! "); } else { Console.WriteLine("Hello Sandeep, Please sell the property for benefit. Good Luck! "); } }
public void IsItWorthSellingOrOwning() { Selling s = new Selling(); double a = s.GetMoneyLeft(720000, 560500, 3); double d = s.GetMoneyGainedOnSelling(a, 12, 1); Console.WriteLine("The money gained on Selling the property in 1 year is " + d); Selling s1 = new Selling(); double b = s1.GetMoneyLeft(720000, 560500, 3); double e = s1.GetMoneyGainedOnSelling(b, 12, 3); Console.WriteLine("The money gained on Selling the property in 3 years is " + e); Selling s2 = new Selling(); double c = s2.GetMoneyLeft(720000, 560500, 3); double f = s2.GetMoneyGainedOnSelling(c, 12, 5); Console.WriteLine("The money gained on Selling the property in 5 years is " + f); double sellingbenefit = s2.moneygainedonselling; Owning o = new Owning(); o.LessSaleCost(720000, 4, 3); o.MoneyGainedOnOwning(33319.2, 720000, 4, 560500, 1); Console.WriteLine("The money gained on Owning the property in 1 year is " + o.moneygainedonowning); Owning o1 = new Owning(); o1.LessSaleCost(720000, 4, 3); o1.MoneyGainedOnOwning(33319.2, 720000, 4, 560500, 3); Console.WriteLine("The money gained on Owning the property in 3 years is " + o1.moneygainedonowning); Owning o2 = new Owning(); o2.LessSaleCost(720000, 4, 3); o2.MoneyGainedOnOwning(33319.2, 720000, 4, 560500, 5); Console.WriteLine("The money gained on Owning the property in 5 years is " + o2.moneygainedonowning); double owningbenefit = o2.moneygainedonowning; if (sellingbenefit < owningbenefit) { Console.WriteLine("Hello Sandeep, Please own the property for benefit. Good Luck! "); } else { Console.WriteLine("Hello Sandeep, Please sell the property for benefit. Good Luck! "); } }
public void SellFromOwning(Profile profile, OwningDto soldOwning) { bool isFirst = true; int totalOwningCount = 0; var ownings = profile.Ownings.Where(x => x.Name == soldOwning.Name).OrderBy(x => x.PurchaseDate).ToList(); ownings.ForEach(x => totalOwningCount += x.PurchaseQuantity); if (totalOwningCount < soldOwning.PurchaseQuantity) { throw new Exception("Sahip olunandan daha fazla satış yapılamaz"); } var soldOwnings = new List <Owning>(); Owning remainingOwning = null; var remainingOwningList = new List <Owning>(); int remainingQuantity = soldOwning.PurchaseQuantity; foreach (var owning in ownings) { if (owning.PurchaseQuantity <= remainingQuantity) { owning.SellDate = soldOwning.SellDate; owning.SellValue = soldOwning.SellValue; remainingQuantity -= owning.PurchaseQuantity; soldOwnings.Add(owning); } else { if (isFirst) { remainingOwning = (Owning)owning.Clone(); remainingOwning.PurchaseQuantity -= remainingQuantity; remainingOwningList.Add(remainingOwning); isFirst = false; } else { remainingOwningList.Add(owning); } } } profile.Ownings.RemoveAll(x => x.Name == soldOwning.Name); if (remainingOwningList.Count > 0) { profile.Ownings.AddRange(remainingOwningList); } profile.Solds.AddRange(soldOwnings); }
/// <summary> /// Редактирование записи о владении /// </summary> /// <param name="entity"></param> /// <returns></returns> public async Task Edit(Owning entity) { _appartmentContext.Entry(entity).State = EntityState.Modified; await _appartmentContext.SaveChangesAsync(); }
/// <summary> /// Добавление записи о владении /// </summary> /// <param name="entity">Запись владении</param> /// <returns></returns> public async Task Add(Owning entity) { _appartmentContext.Ownings.Add(entity); await _appartmentContext.SaveChangesAsync(); }