public RevenueViewModel(Revenue entry) : this() { Entry = entry; Contractor = entry.Contractor; if (!entry.EconomicEvent.IsInDictionary) EconomicEventDescription = entry.EconomicEvent.Description; if (!entry.Comment.IsInDictionary) CommentText = entry.Comment.Text; ButtonContent = "Edytuj"; Title = $"Edycja wpisu {entry.EvidenceNumber}"; ButtonCommand = new RelayCommand(EditEntry); }
public RevenueViewModel() { Header = "Przychód"; var startOfTheMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1); int count; using (var database = new LedgerContext()) { EconomicEvents = database.LedgerDictionaries.OfType<EconomicEvent>() .Where(x => x.IsInDictionary && x.ForRevenue).ToList(); Comments = database.LedgerDictionaries.OfType<Comment>() .Where(x => x.IsInDictionary && x.ForRevenue).ToList(); count = database.Entries .Count(x => x.Date >= startOfTheMonth); } Entry = new Revenue { Date = DateTime.Today, EconomicEventId = EconomicEvents.First().Id, CommentId = Comments.First().Id, EvidenceNumber = $"{count + 1}/{ DateTime.Today.Month}/{DateTime.Today.Year}" }; }