public EventFormViewModel(int eventID) { var repository = new EventRepository(); var etRepository = new EventTypeRepository(); EventTypes = etRepository.EventTypes(); try { var mnfEvent = repository.Find(eventID); ID = mnfEvent.ID; Name = mnfEvent.Name; EventTypeID = mnfEvent.EventTypeID; Cost = mnfEvent.Cost; Description = mnfEvent.Description; EventDate = mnfEvent.EventDate.ToShortDateString(); StartTime = mnfEvent.StartTime.ToShortTimeString(); EndTime = mnfEvent.EndTime.ToShortTimeString(); Location = mnfEvent.Location; ShowEvent = mnfEvent.ShowEvent; EventMarkup = mnfEvent.EventMarkup; } catch (Exception) { // record not found in db, return -1 for ID ID = -1; } }
public EventFormViewModel() { var etRepository = new EventTypeRepository(); Cost = "$0.00"; EventTypes = etRepository.EventTypes(); EventDate = DateTime.Today.ToShortDateString(); }