public static SettingsViewModel GetSettings(Guid userid) { PBProxy p = new PBProxy(); Setting temp = p.GetSettings(userid); Paycheck pc = p.GetPaychecks(userid).FirstOrDefault(); p = null; SettingsViewModel Return = Mapper.Map <SettingsViewModel>(temp); Return.PaycheckAmount = pc == null ? 0 : pc.Amount; return(Return); }
public IncomeViewModel(Guid userid) { this.Paychecks = new List <PaycheckViewModel>(); PBProxy p = new PBProxy(); this.Paychecks = Mapper.Map <List <PaycheckViewModel> >(p.GetPaychecks(userid).OrderBy(a => a.Type)); int index = 0; foreach (string type in "A,B,C,D".Split(',')) { if (this.Paychecks.All(a => a.Type != type)) { this.Paychecks.Insert(index, new PaycheckViewModel() { Type = type, Exists = false, UserID = userid, PayCheck = null }); } index++; } this.PayDay = p.GetPaydays(userid).FirstOrDefault(); }