public ActionResult <IEnumerable <AppointmentListItem> > CustomerFiltered(string id, DateTime?MinDate, string ServiceCodes, string StatusCodes) { DateTime MinSQLDateTime = new DateTime(1753, 1, 1); string[] ServiceCodeList = null; string[] StatusCodeList = null; List <AppointmentListItem> Result = new List <AppointmentListItem>(); DateTime MinAppDate = MinDate.GetValueOrDefault(DateTime.Today); if (MinAppDate <= MinSQLDateTime) { MinAppDate = MinSQLDateTime; } if (!string.IsNullOrWhiteSpace(ServiceCodes)) { ServiceCodeList = ServiceCodes.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries); } if (!string.IsNullOrWhiteSpace(StatusCodes)) { StatusCodeList = StatusCodes.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries); } foreach (AG_B_APPOINTMENT Item in DBContext.AG_B_APPOINTMENT.Where(E => E.CUSTOMER_CODE == id && E.DT_APPOINTMENT >= MinAppDate.Date && (ServiceCodeList == null || ServiceCodeList.Contains(E.SERVICE_CODE)) && (StatusCodeList == null || StatusCodeList.Contains(E.STATUS_CODE))).OrderByDescending(E => E.DT_APPOINTMENT).Take(Settings.Value.MaxQueryResult)) { AppointmentListItem ListItem = EntityMapper.Map <AppointmentListItem, AG_B_APPOINTMENT>(DBContext, Item, Item.AG_B_APPOINTMENT_EXT_AUS); Result.Add(ListItem); } return(Result); }
public IEnumerable <AppointmentListItem> GetAppointmentsByUser(string userId) { using (var ctx = new ApplicationDbContext()) { var query = ctx.Appointments.ToList(); List <AppointmentListItem> result = new List <AppointmentListItem>(); foreach (Appointment e in query) { if (e.Provider.UserId == userId) { AppointmentListItem appointment = new AppointmentListItem { AppointmentId = e.AppointmentId, Patient = e.Patient.FullName, ScheduledStart = e.ScheduledStart, Length = e.Length, Provider = e.Provider.FullName, PatientId = e.PatientId }; result.Add(appointment); } } return(result); } }
public ActionResult <AppointmentListItem> Get(Guid rowGuid) { AppointmentListItem Result = null; AG_B_APPOINTMENT Item = DBContext.AG_B_APPOINTMENT.FirstOrDefault(E => E.ROWGUID == rowGuid); if (Item == null) { throw new NotFoundException($"No appointment found with rowGuid: {rowGuid}"); } Result = EntityMapper.Map <AppointmentListItem, AG_B_APPOINTMENT>(DBContext, Item, Item.AG_B_APPOINTMENT_EXT_AUS); return(Result); }
public ActionResult <AppointmentListItem> Reschedule(Guid rescheduledAppointmentRowGuid, [FromBody] AppointmentBase value) { if (value == null) { throw new ArgumentNullException(nameof(value), $"Argument value cannot be null"); } AG_B_APPOINTMENT oldAppointment = DBContext.AG_B_APPOINTMENT.SingleOrDefault(E => E.ROWGUID == rescheduledAppointmentRowGuid); if (oldAppointment == null) { throw new NotFoundException($"No appointment found with RowGuid:{rescheduledAppointmentRowGuid}"); } if (oldAppointment.AG_B_APPOINTMENT_EXT_AUS.RESCHEDULED_NUMBER.GetValueOrDefault(0) >= 3) { throw new InvalidOperationException("Appointment reschedule max number exceeded"); } oldAppointment.AG_B_APPOINTMENT_EXT_AUS.RESCHEDULED_NUMBER = oldAppointment.AG_B_APPOINTMENT_EXT_AUS.RESCHEDULED_NUMBER.GetValueOrDefault(0) + 1; using (IDbContextTransaction scope = DBContext.Database.BeginTransaction()) { UpdateAppointmentStatus(oldAppointment.ROWGUID, appointmentStatus.Rescheduled); AppointmentListItem Result = DoPost(value, rescheduledAppointmentRowGuid: rescheduledAppointmentRowGuid); CU_B_ACTIVITY activity = EntityMapper.CreateEntity <CU_B_ACTIVITY>(); CU_B_ACTIVITY_EXT_AUS activityExt = EntityMapper.CreateEntity <CU_B_ACTIVITY_EXT_AUS>(); activity.ACTIVITY_TYPE_CODE = "DY"; activity.ACTIVITY_DATE = DateTime.Today; activity.CUSTOMER_CODE = activityExt.CUSTOMER_CODE = Result.CustomerCode; activity.EMPLOYEE_CODE = Result.EmployeeCode; activity.REFERENCE_DATE = oldAppointment.DT_APPOINTMENT; activity.REFERENCE_NUMBER = oldAppointment.APPOINTMENT_ID; activity.APPOINTMENT_ID = Result.AppointmentID; activityExt.DT_APPOINTEMENT_FROM = oldAppointment.DT_APPOINTMENT; activityExt.DT_APPOINTEMENT_TO = Result.AppointmentDate; activity.ACTIVITY_ID = activityExt.ACTIVITY_ID = FoxDataService.GetNewCounter("CU_B_ACTIVITY", "ACTIVITY_ID", Result.StatusCode, activity.USERINSERT).VALUE.GetValueOrDefault(); activity.SHOP_CODE = activity.LAPTOP_CODE = activityExt.SHOP_CODE = activityExt.LAPTOP_CODE = Result.ShopCode; DBContext.CU_B_ACTIVITY.Add(activity); DBContext.CU_B_ACTIVITY_EXT_AUS.Add(activityExt); DBContext.SaveChanges(); scope.Commit(); return(Result); } }
public ActionResult <IEnumerable <AppointmentListItem> > Customer(string id, DateTime?MinDate, int?MaxResultsCount) { DateTime MinSQLDateTime = new DateTime(1753, 1, 1); List <AppointmentListItem> Result = new List <AppointmentListItem>(); DateTime MinAppDate = MinDate.GetValueOrDefault(MinSQLDateTime); MaxResultsCount = MaxResultsCount.GetValueOrDefault(Settings.Value.MaxQueryResult); if (MinAppDate <= MinSQLDateTime) { MinAppDate = MinSQLDateTime; } foreach (AG_B_APPOINTMENT Item in DBContext.AG_B_APPOINTMENT.Where(E => E.CUSTOMER_CODE == id && E.DT_APPOINTMENT >= MinAppDate.Date).OrderByDescending(E => E.DT_APPOINTMENT).Take(MaxResultsCount.Value)) { AppointmentListItem ListItem = EntityMapper.Map <AppointmentListItem, AG_B_APPOINTMENT>(DBContext, Item, Item.AG_B_APPOINTMENT_EXT_AUS); Result.Add(ListItem); } return(Result); }
public ActionResult <AppointmentListItem> CustomerNextAppointment(string id) { AppointmentListItem Result = null; //Take next appointment AG_B_APPOINTMENT Appointment = DBContext.AG_B_APPOINTMENT.OrderBy(E => E.DT_APPOINTMENT).FirstOrDefault(E => E.CUSTOMER_CODE == id && E.DT_APPOINTMENT >= DateTime.Today && AllowedAppointmentStatus.Contains(E.STATUS_CODE)); if (Appointment == null) //Take last appointment { Appointment = DBContext.AG_B_APPOINTMENT.OrderByDescending(E => E.DT_APPOINTMENT).FirstOrDefault(E => E.CUSTOMER_CODE == id && E.DT_APPOINTMENT < DateTime.Today); } if (Appointment != null) { Result = EntityMapper.Map <AppointmentListItem, AG_B_APPOINTMENT>(DBContext, Appointment, Appointment.AG_B_APPOINTMENT_EXT_AUS); } return(Result); }
public ActionResult <IEnumerable <AppointmentListItem> > Shop(string id, string serviceCodes, string statusCodes, string employeeCodes, DateTime?appointmentDate, int?MaxResultsCount) { DateTime MinSQLDateTime = new DateTime(1753, 1, 1); List <AppointmentListItem> Result = new List <AppointmentListItem>(); DateTime AppDate = appointmentDate.GetValueOrDefault(DateTime.Today); MaxResultsCount = MaxResultsCount.GetValueOrDefault(Settings.Value.MaxQueryResult); if (AppDate <= MinSQLDateTime) { AppDate = MinSQLDateTime; } string[] unavailabilityServiceCodes = FoxDataService.GetUnavailabilityServiceCodes(id); var predicate = PredicateBuilder.New <AG_B_APPOINTMENT>(); predicate = predicate.And(E => E.APPOINTMENT_SHOP_CODE == id && E.DT_APPOINTMENT.Date == AppDate.Date && !unavailabilityServiceCodes.Contains(E.SERVICE_CODE)); if (!string.IsNullOrWhiteSpace(serviceCodes)) { string[] codes = serviceCodes.Split("|"); predicate = predicate.And(E => codes.Contains(E.SERVICE_CODE)); } if (!string.IsNullOrWhiteSpace(statusCodes)) { string[] codes = statusCodes.Split("|"); predicate = predicate.And(E => codes.Contains(E.STATUS_CODE)); } if (!string.IsNullOrWhiteSpace(employeeCodes)) { string[] codes = employeeCodes.Split("|"); predicate = predicate.And(E => codes.Contains(E.EMPLOYEE_CODE)); } foreach (AG_B_APPOINTMENT Item in DBContext.AG_B_APPOINTMENT.Where(predicate).OrderByDescending(E => E.DT_APPOINTMENT).Take(MaxResultsCount.Value)) { AppointmentListItem ListItem = EntityMapper.Map <AppointmentListItem, AG_B_APPOINTMENT>(DBContext, Item, Item.AG_B_APPOINTMENT_EXT_AUS); Result.Add(ListItem); } return(Result); }