public IQueryable <AircraftViewModel> GetAll() { var users = _context.AsQueryable <AircraftType>() .Select(x => new AircraftViewModel() { ID = x.ID, Name = x.Name, Description = x.Description }); return(users); }
public IQueryable <DestinationViewModel> GetAll() { var data = _context.AsQueryable <Data.Entities.Destination>() .Select(x => new DestinationViewModel() { ID = x.ID, Name = x.Name, Description = x.Description }); return(data); }
public IQueryable <RegistrationViewModel> GetAll() { var registrations = _context.AsQueryable <Registration>() .Select(x => new RegistrationViewModel() { ID = x.ID, Name = x.Name, AircraftID = x.AircraftID, AircraftName = x.AircraftType.Name, Description = x.Description }); return(registrations); }
public LoginModel LetMeIn(LoginModel model) { string message = "Invalid username/password"; model.UserID = 0; AAContext context = new AAContext(); User user = context.AsQueryable <User>() .Where(x => x.Username == model.Username.Trim() && x.Password == model.Password.Trim()) .FirstOrDefault(); if (user != null) { if (user.ID > 0) { message = ""; model.UserID = user.ID; model.RoleID = user.RoleID; model.Username = user.Username; model.FullName = string.Format("{0}, {1} {2}", user.LastName, user.FirstName, user.MiddleName); model.Email = user.Email; model.RoleName = user.Role.Name; } } model.Message = message; return(model); }
public IQueryable <RoleViewModel> GetAllRoles() { var roles = _context.AsQueryable <Role>() .Select(x => new RoleViewModel() { ID = x.ID, Name = x.Name, Description = x.Description, Active = x.Active }); return(roles); }
public IQueryable <LogsViewModel> GetAll() { var logs = _context.AsQueryable <Data.Entities.Logs>() .Select(x => new LogsViewModel() { ID = x.ID, ActionType = x.ActionType, Description = x.Description, ModifiedBy = x.ModifiedBy, DateModified = x.DateModified.ToString() }); foreach (var log in logs) { log.DateModified = DateTime.Parse(log.DateModified).ToString("MM/dd/yyyy HH:mm"); } return(logs); }
public IQueryable <CalendarViewModel> GetAll() { var data = _context.AsQueryable <Schedule>() .Select(x => new CalendarViewModel() { ID = x.ID, Title = x.Name, AircraftID = x.AircraftID, RegistrationID = x.RegistrationID, Start = x.StartDate.ToString(),//"yyyy-MM-dd HH:mm" End = x.EndDate.ToString(), WaitingStart = x.WaitingStart.ToString(), WaitingEnd = x.WaitingEnd.ToString(), RouteStartID = x.RouteStartID, DestinationID = x.RouteDestinationID, RouteEndID = x.RouteEndID, PilotID = x.PilotID, CopilotID = x.AssistantPilotID, Notes = x.Notes, Passengers = x.Passengers, FlightInfo = x.FlightInfo, TechnicalStops = x.TechnicalStops, ETC = x.ETC, ScheduleCrews = x.ScheduleCrews.Where(y => y.ScheduleID == x.ID).Select(z => new CrewViewModel() { CrewID = z.CrewID, ScheduleID = z.ScheduleID }).ToList() }); foreach (var cal in data) { cal.Start = DateTime.Parse(cal.Start).ToString("yyyy-MM-dd HH:mm"); cal.End = DateTime.Parse(cal.End).ToString("yyyy-MM-dd HH:mm"); if (!string.IsNullOrEmpty(cal.WaitingStart)) { cal.WaitingStart = DateTime.Parse(cal.WaitingStart).ToString("yyyy-MM-dd HH:mm"); } if (!string.IsNullOrEmpty(cal.WaitingEnd)) { cal.WaitingEnd = DateTime.Parse(cal.WaitingEnd).ToString("yyyy-MM-dd HH:mm"); } } return(data); }
public IQueryable <UserViewModel> GetAll() { var users = _context.AsQueryable <User>() .Select(x => new UserViewModel() { ID = x.ID, RoleID = x.RoleID, RoleName = x.Role.Name, Username = x.Username, Password = x.Password, FirstName = x.FirstName, LastName = x.LastName, MiddleName = x.MiddleName, Address = x.Address, Phone = x.Phone, Email = x.Email, SSS = x.SSS, TIN = x.TIN, Status = x.Active == true ? "Active" : "Inactive" }); return(users); }
public List <RptScheduleViewModel> GetAllSchedules(string start, string end) { List <RptScheduleViewModel> models = new List <RptScheduleViewModel>(); DateTime dtStart = DateTime.Parse(start) , dtEnd = DateTime.Parse(end); models = _context.AsQueryable <Schedule>() .Where(x => (DbFunctions.TruncateTime(x.StartDate) >= dtStart && DbFunctions.TruncateTime(x.StartDate) <= dtEnd)) .OrderBy(x => x.StartDate) .Select(x => new RptScheduleViewModel() { Date = x.StartDate.ToString(), AircraftRegistration = x.AircraftType.Name + "-" + x.Registration.Name, FirstLegOfFlight = x.RouteStart.Name + "-" + x.RouteDestination.Name, SecondLegOfFlight = x.RouteDestination.Name + "-" + x.RouteEnd.Name, StartDate = x.StartDate.ToString(), EndDate = x.EndDate.ToString(), StartDate2 = x.WaitingStart.ToString(), EndDate2 = x.WaitingEnd.ToString(), Notes = x.Notes, Passenger = x.Passengers, FlightInfo = x.FlightInfo, TechStops = x.TechnicalStops, Etc = x.ETC, Pilot = x.Pilot.LastName + ", " + x.Pilot.FirstName, CoPilot = x.AssistantPilot.LastName + ", " + x.AssistantPilot.FirstName, Crews = x.ScheduleCrews.Where(y => y.ScheduleID == x.ID).Select(y => new CrewViewModel() { Fullname = y.Crew.LastName + ", " + y.Crew.FirstName }).ToList() }) .ToList(); List <RptScheduleViewModel> retvalues = new List <RptScheduleViewModel>(); foreach (var model in models) { try { string date = DateTime.Parse(model.Date).ToString("MM/dd/yyyy"); DateTime s1 = DateTime.Parse(model.StartDate) , s2 = DateTime.Parse(model.StartDate2) , e1 = DateTime.Parse(model.EndDate) , e2 = DateTime.Parse(model.EndDate2); model.StartDate = s1.ToString("MM/dd/yyyy"); model.StartTime = s1.ToString("HH:mm"); model.EndDate = e1.ToString("MM/dd/yyyy"); model.EndTime = e1.ToString("HH:mm"); model.StartDate2 = s2.ToString("MM/dd/yyyy"); model.StartTime2 = s2.ToString("HH:mm"); model.EndDate2 = e2.ToString("MM/dd/yyyy"); model.EndTime2 = e2.ToString("HH:mm"); model.Date = date; retvalues.Add(model); } catch { continue; } } return(retvalues); }