public ClientWithLatestBudgetsViewModel(InsideModel.Models.Client client) { this.ClientId = client.Id; this.ClientName = client.Name; var now = DateTime.UtcNow.Date; var currentMonthDate = new DateTime(now.Year, now.Month, 1); var nextMonthDate = currentMonthDate.AddMonths(1).Date; var twoMonthsLaterDate = currentMonthDate.AddMonths(2).Date; if (client.Consultant != null) { this.Consultant = client.Consultant.Name; } if (client.AccountManager != null) { this.AccountManager = client.AccountManager.Name; } CurrentMothsBudget = client.Budgets.SingleOrDefault(b => b.Month >= currentMonthDate && b.Month < nextMonthDate); NextMothsBudget = client.Budgets.SingleOrDefault(b => b.Month >= nextMonthDate && b.Month < twoMonthsLaterDate); this.IsActive = client.IsActive; this.HasUnHandledBudgets = client.Budgets.Any(b => b.IsHandled == false); this.HasCampaignPlan = client.Labels.Any(l => l.Name == "Kampanjplaneras"); }
public ClientViewModel(InsideModel.Models.Client client) { AccountManagerId = client.AccountManagerId; Address = client.Address; AnalyticsTableId = client.AnalyticsTableId; CallTrackingMetricId = client.CallTrackingMetricId; ConsultantId = client.ConsultantId; Domain = client.Domain; EmailAddress = client.EmailAddress; Id = client.Id; IsActive = client.IsActive; Latitude = client.Latitude; Longitude = client.Longitude; Name = client.Name; ConsultantName = client.Consultant == null ? "" : client.Consultant.Name; AccountManagerName = client.AccountManager == null ? "" : client.AccountManager.Name; FeeFixedMonthly = (int)Math.Truncate(client.FeeFixedMonthly); FeePercent = (int)Math.Truncate(client.FeePercent * 100m); Labels = client.Labels.ToList().Select(l => new LabelViewModel(l)).ToEnumerable(); }