public static DashboardItem ToDashBoardItem( this DataAccess.Calendar entity) { if (entity != null) { return(new DashboardItem { Url = "/Calendar/Detail/" + entity.Id, Icon = "fa-newspaper-o", Name = "Event: " + entity.Event.Name, Description = "Venue:" + entity.Venue.Name, Message = entity.ScheduleDate.ToCustomLongDate(), TimeString = entity.StartTime.ToString(), DateTimeStamp = entity.CreatedTimestamp }); } return(null); }
/// <summary> /// Convert Calendar Entity into Calendar Object /// </summary> ///<param name="model">CalendarViewModel</param> ///<param name="CalendarEntity">DataAccess.Calendar</param> ///<returns>CalendarViewModel</returns> public static CalendarViewModel ToViewModel( this DataAccess.Calendar entity, CalendarViewModel model) { model.Id = entity.Id; model.Event = entity.Event.Name; model.FinYear = entity.FinYear.Name; model.Venue = entity.Venue.Name; model.EventId = entity.EventId; model.FinYearId = entity.FinYearId; model.VenueId = entity.VenueId; model.Notes = entity.Notes; model.IsActive = entity.IsActive; model.ScheduleDate = entity.ScheduleDate; model.RevisedDate = entity.RevisedDate; model.StartTime = entity.StartTime; model.ScheduleDateString = entity.RevisedDate.HasValue ? entity.RevisedDate.ToCustomLongDate(): entity.ScheduleDate.ToCustomLongDate(); model.ModeratorIds = entity.Moderators.Select(a => a.MemberId); return(model); }
/// <summary> /// Convert Calendar Object into Calendar Entity /// </summary> ///<param name="model">Calendar</param> ///<param name="CalendarEntity">DataAccess.Calendar</param> ///<returns>DataAccess.Calendar</returns> public static DataAccess.Calendar ToEntity(this CalendarViewModel model, DataAccess.Calendar entity) { if (entity.Id == 0) { entity.CreatedUserId = model.SessionUserId; entity.IsActive = model.IsActive; } else { entity.UpdatedUserId = model.SessionUserId; entity.UpdatedTimestamp = DateTime.Now; } entity.EventId = model.EventId; entity.FinYearId = model.FinYearId; entity.StartTime = model.StartTime; entity.VenueId = model.VenueId; entity.ScheduleDate = model.ScheduleDate; entity.RevisedDate = model.RevisedDate; return(entity); }