///// <summary>
        ///// Get available times in format for an specific date
        ///// </summary>
        ///// <param name="p">parameters</param>
        ///// <returns></returns>
        //public IList<vDoctorSchedule> GetTimesByRange(DoctorScheduleGetByRangeSP p)
        //{
        //    List<string> columns = new List<string>();
        //    columns.Add(vDoctorSchedule.ColumnNames.DoctorScheduleID);
        //    columns.Add(vDoctorSchedule.ColumnNames.SlotUnixEpoch);
        //    return GetByRangeWithColumns(p, null);
        //}


        private IList <vDoctorSchedule> GetByRangeWithColumns(DoctorScheduleGetByRangeSP p, List <string> columns)
        {
            FilterExpression filter = GetByRangeFilter(p);

            filter.AndMerge(new FilterExpression(vDoctorSchedule.ColumnNames.NumberOfFreePositions, 0, FilterOperatorEnum.GreaterThan));

            SortExpression sort = new SortExpression(vDoctorSchedule.ColumnNames.SlotUnixEpoch);

            if (columns != null)
            {
                if (columns.Contains(vDoctorSchedule.ColumnNames.NumberOfAllowedPatients))
                {
                    columns.Add(vDoctorSchedule.ColumnNames.NumberOfAllowedPatients);
                }
                if (columns.Contains(vDoctorSchedule.ColumnNames.NumberOfRegisteredPatients))
                {
                    columns.Add(vDoctorSchedule.ColumnNames.NumberOfRegisteredPatients);
                }
            }

            GetByFilterParameters getParams = new GetByFilterParameters(filter, sort, 0, 1000, columns, GetSourceTypeEnum.View);

            IList <vDoctorSchedule> list = GetByFilterV(getParams);

            return(list);

            // we filter the list from database to speed up the process.
            //List<vDoctorSchedule> results = new List<vDoctorSchedule>();
            //foreach (var item in list)
            //{
            //    if (item.NumberOfAllowedPatients > item.NumberOfRegisteredPatients)
            //        results.Add(item);
            //}
            //return results;
        }
        public void AndMergeTest()
        {
            // empty test
            FilterExpression target     = new FilterExpression();
            FilterExpression filterExp2 = new FilterExpression();

            target.AndMerge(filterExp2);
            Assert.AreEqual(target.FiltersList.Count, 1);
            List <object> valuesList = new List <object>();
            string        s          = target.GetFilterString(valuesList);

            Assert.AreEqual(s, "");
        }
        public void AndMergeTest2()
        {
            FilterExpression target = new FilterExpression();

            target.AddFilter(new Filter(vTestCaseTester.ColumnNames.FieldString, "C1"));
            FilterExpression filterExp2 = new FilterExpression();

            filterExp2.AddFilter(new Filter(vTestCaseTester.ColumnNames.FieldString, "C2"));
            target.AndMerge(filterExp2);
            Assert.AreEqual(target.FiltersList.Count, 2);
            List <object> valuesList = new List <object>();
            string        actual     = target.GetFilterString(valuesList);
            string        expected   = "(" + GetSimpleFilterString(vTestCaseTester.ColumnNames.FieldString, "=", Filter.ParameterPrefix + "0") +
                                       " AND " + GetSimpleFilterString(vTestCaseTester.ColumnNames.FieldString, "=", Filter.ParameterPrefix + "1") + ")";

            Assert.AreEqual(actual, expected);
        }
        public void SendNotificationTest()
        {
            Notification notification = CreateNewNotification((short)EntityEnums.NotificationTemplateEnum.TestNotification);

            notification.IsSMS = true;
            notification.IsMobilePushMessage = true;

            INotificationService service = (INotificationService)
                                           EntityFactory.GetEntityServiceByName(vNotification.EntityName, "");

            service.Insert(notification, new InsertParameters());
            vNotification nSaved = (vNotification)service.GetByID(notification.NotificationID, new GetByIDParameters(GetSourceTypeEnum.View));

            NotificationSenderAgent.SendNotification(nSaved);

            // Check that log inserted for all notifications (no error happened anywhere)
            IAppLogService logService = (IAppLogService)
                                        EntityFactory.GetEntityServiceByName(AppLog.EntityName, "");
            FilterExpression filter = new FilterExpression(new Filter(AppLog.ColumnNames.ExtraBigInt, nSaved.NotificationID));
            FilterExpression f2     = new FilterExpression();

            f2.AddFilter(new Filter(AppLog.ColumnNames.AppLogTypeID, (int)EntityEnums.AppLogType.Notify_Email));
            f2.AddFilter(new Filter(AppLog.ColumnNames.AppLogTypeID, (int)EntityEnums.AppLogType.Notify_MobilePush));
            f2.AddFilter(new Filter(AppLog.ColumnNames.AppLogTypeID, (int)EntityEnums.AppLogType.Notify_SMS));
            f2.LogicalOperator = FilterLogicalOperatorEnum.OR;
            filter.AndMerge(f2);

            long logCount = logService.GetCount(filter);

            Assert.AreEqual(2, logCount, "EMAIL, SMS has not saved in logs. So, error in media");

            // check that all parameters are valid after save
            vNotification nSaved2 = (vNotification)service.GetByID(notification.NotificationID, new GetByIDParameters(GetSourceTypeEnum.View));

            Assert.IsNull(nSaved2.NotificationErrorMessage);
            Assert.IsNotNull(nSaved2.EmailSendDate);
            Assert.IsNotNull(nSaved2.SMSSendDate);
        }
        public override void GetMax(string columnName, FilterExpression f)
        {
            FilterExpression filter = new FilterExpression(new Filter(this.FieldName, this.FieldValue));

            f.AndMerge(filter);
        }
        public override void GetCount(FilterExpression f)
        {
            FilterExpression filter = new FilterExpression(new Filter(this.FieldName, this.FieldValue));

            f.AndMerge(filter);
        }