Example #1
0
 public SPOListPipeBind()
 {
     _onlineList = null;
     _list = null;
     _id = Guid.Empty;
     _name = string.Empty;
 }
        public void SetValueFromPath_AddListValue_AddsValue()
        {
            //Arrange
            var entity = new ListEntity
            {
                Foo = new List <string> {
                    "Element One", "Element Two"
                }
            };

            //act
            PathHelper.SetValueFromPath(typeof(ListEntity), "/foo/1", entity, "Element Two Updated", JsonPatchOperationType.add);

            //Assert
            Assert.AreEqual("Element Two Updated", entity.Foo[1]);
            Assert.AreEqual("Element Two", entity.Foo[2]);
            Assert.AreEqual(3, entity.Foo.Count);
        }
        public void ApplyUpdate_MoveListElement_EntityUpdated()
        {
            //Arrange
            var patchDocument = new JsonPatchDocument <ListEntity>();
            var entity        = new ListEntity
            {
                Foo = new List <string> {
                    "Element One", "Element Two", "Element Three"
                }
            };

            //Act
            patchDocument.Move("/Foo/2", "/Foo/1");
            patchDocument.ApplyUpdatesTo(entity);

            //Assert
            Assert.AreEqual(3, entity.Foo.Count);
            Assert.AreEqual("Element One", entity.Foo[0]);
            Assert.AreEqual("Element Three", entity.Foo[1]);
            Assert.AreEqual("Element Two", entity.Foo[2]);
        }
Example #4
0
        /// <summary>
        /// Búsqueda paginada
        /// </summary>
        /// <param name="context">Contexto</param>
        /// <param name="search">Objeto de búsqueda a través de una expresión sobre la entidad </param>
        /// <returns>Listado paginado de la entidad</returns>
        public ListEntity <TEntityType> Search(TContextType context, SearchExpression <TEntityType> search)
        {
            ListEntity <TEntityType> result = null;

            try
            {
                Validator.Validate(search);

                var query = Search(context, search.Expression);

                result = new ListEntity <TEntityType>
                {
                    Count = query.Count(),
                    Data  = query.Paginate(search).ToList()
                };
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex, PolicyType.Data);
            }

            return(result);
        }
Example #5
0
        private static bool CanBeVisible(ListEntity listEntity)
        {
            switch (listEntity.ListType)
            {
            case Constants.Lists.SaleStage:
            case Constants.Lists.SaleTypeCategory:
            case Constants.Lists.ProjectStatus:
            case Constants.Lists.ProjectTypeStatus:
            case Constants.Lists.ChatProtocols:
            case Constants.Lists.QuoteDeliveryTerms:
            case Constants.Lists.QuoteDeliveryType:
            case Constants.Lists.QuotePaymentTerms:
            case Constants.Lists.QuotePaymentType:
            case Constants.Lists.ProductCategory:
            case Constants.Lists.ProductFamily:
            case Constants.Lists.ProductType:
            case Constants.Lists.ProductSubscriptionUnit:
            case Constants.Lists.ProductPriceUnit:
                return(false);

            default:
                return(listEntity.IsMDOList);
            }
        }
Example #6
0
        public void ListEntity_Serialization()
        {
            TestListEntity <string> entity = new TestListEntity <string>
            {
                IsFixedSize = true
            };
            PrivateObject privObj = new PrivateObject(entity, new PrivateType(typeof(ListEntity <string>)));

            List <string> genes = new List <string> {
                "a", "b"
            };

            privObj.SetField("genes", genes);

            ListEntity <string> result = (ListEntity <string>)SerializationHelper.TestSerialization(entity, new Type[0]);

            Assert.Equal(entity.IsFixedSize, result.IsFixedSize);

            PrivateObject resultPrivObj = new PrivateObject(result, new PrivateType(typeof(ListEntity <string>)));
            List <string> resultGenes   = (List <string>)resultPrivObj.GetField("genes");

            Assert.Equal(genes[0], resultGenes[0]);
            Assert.Equal(genes[1], resultGenes[1]);
        }
Example #7
0
 public SPOListPipeBind(ListEntity list)
 {
     this._onlineList = list;
 }
Example #8
0
        public override void DataBind()
        {
            //base.DataBind();
            MonoXCacheManager cacheManager = MonoXCacheManager.GetInstance(TweetsCacheKey, this.CacheDuration);

            KeyValuePair <SyndicationFeed, int> bindContainer = cacheManager.Get <KeyValuePair <SyndicationFeed, int> >(ProfileName, TweetsCount);

            if (bindContainer.Value == 0)
            {
                try
                {
                    TweetsCount = TweetsCount.HasValue ? TweetsCount : 10;
                    var             url  = string.Format("http://api.twitter.com/1/statuses/user_timeline.rss?screen_name={0}&count={1}", ProfileName, TweetsCount);
                    SyndicationFeed feed = LoadFrom(url);
                    bindContainer = new KeyValuePair <SyndicationFeed, int>(feed, feed.Items.Count());
                    cacheManager.Store(bindContainer, ProfileName, TweetsCount);
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }

                try
                {
                    if (Page.User.Identity.IsAuthenticated)
                    {
                        //Save the Tweets to the DB
                        Guid listId = Guid.Empty;
                        if (!Guid.Empty.Equals(ListId))
                        {
                            listId = ListId;
                        }
                        else if (!String.IsNullOrEmpty(ListName))
                        {
                            listId = BaseMonoXRepository.GetInstance().GetFieldValue <Guid>(ListFields.Title, ListName, ListFields.Id);
                        }

                        if (Guid.Empty.Equals(listId) && !String.IsNullOrEmpty(ListName))
                        {
                            //Create a List
                            ListEntity list = ListRepository.GetInstance().CreateNewList();
                            list.Title    = ListName;
                            list.UserId   = SecurityUtility.GetUserId();
                            list.ListType = 0;
                            ListRepository.GetInstance().SaveEntity(list, true);
                            listId = list.Id;
                        }

                        if (!Guid.Empty.Equals(listId))
                        {
                            foreach (var item in bindContainer.Key.Items)
                            {
                                Guid urlId = BaseMonoXRepository.GetInstance().GetFieldValue <Guid>(ListItemLocalizationFields.ItemUrl, item.Id, ListItemLocalizationFields.Id);
                                if (!Guid.Empty.Equals(urlId))
                                {
                                    break;                            //Suppose that we have imported upcoming tweets
                                }
                                ListItemEntity listItem = ListRepository.GetInstance().CreateNewListItem(listId);
                                listItem.DateCreated = Convert.ToDateTime(item.PublishDate.ToString());
                                listItem.ItemTitle   = HtmlFormatTweet(item.Title.Text);
                                listItem.ItemUrl     = item.Id;
                                ListRepository.GetInstance().SaveEntity(listItem);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
            }

            //Note: We need to perform the in-memory paging
            List <SyndicationItem> items = bindContainer.Key.Items.Skip(pager.CurrentPageIndex * pager.PageSize).Take(pager.PageSize).ToList();

            PagerUtility.BindPager(pager, DataBind, lvItems, items, bindContainer.Value);

            if (HideIfEmpty)
            {
                this.Visible = (bindContainer.Value != 0);
            }
        }
Example #9
0
        public async Task <List> GetListById(string listId)
        {
            ListEntity listEntity = await GetListEntityById(listId);

            return(ConvertListEntityToDomainModel(listEntity));
        }
Example #10
0
 public SPOListPipeBind(ListEntity list)
 {
     this._onlineList = list;
 }
Example #11
0
 public ListModel(ListEntity list)
 {
     _list = list;
 }
Example #12
0
        internal async void LoadAppointment(DateTime date)
        {
            Appointment appointment = null;

            ListEntity dadosPatient = new ListEntity
            {
                Id   = Patient.Id,
                Name = Patient.NameCompleto
            };

            switch (ConsultationType)
            {
            case Appointment._ORIENTACAO:
                appointment = new Appointment(ConsultationType, "", ResponsibleId, dadosPatient, IdAction, 0, false, false, date, new ObservableCollection <string>(InternCollection.Select(item => item.Id).ToList()));
                break;

            case Appointment._GRUPO:
                appointment = new Appointment(ConsultationType, "", ResponsibleId, dadosPatient, IdAction, 0, false, true, date, new ObservableCollection <string>(InternCollection.Select(item => item.Id).ToList()));
                break;

            case Appointment._INDIVIDUAL:
                appointment = new Appointment(ConsultationType, "", ResponsibleId, dadosPatient, IdAction, 0, false, true, date, new ObservableCollection <string>(InternCollection.Select(item => item.Id).ToList()));
                break;
            }

            var appointmentMarcado = (await appointmentRepository.GetAppointmentByEventIdActionIdAsync(appointment.EventId, IdAction, appointment.Patient.Id));

            if (appointmentMarcado == null)
            {
                IEnumerable <ScheduleAction> schedulesIndisponiveis = await scheduleActionRepository.GetAppointmentsByIdActionAsync(IdAction);

                if (schedulesIndisponiveis.FirstOrDefault(x => x.StartTime.DayOfWeek == date.DayOfWeek && x.StartTime.Hour == date.Hour) == null)
                {
                    var action = await dialogService.DisplayActionSheetAsync("Deseja agendar o atendimento?", "Cancelar", "Agendar");

                    switch (action)
                    {
                    case "Cancelar":
                        return;

                    case "Agendar":
                        Create(appointment);
                        break;
                    }
                }
            }
            else
            {
                appointment = appointmentMarcado;
                var action = await dialogService.DisplayActionSheetAsync("Selecione a operação desejada:", "Cancelar", null, "Ver detalhes", "Desmarcar");

                switch (action)
                {
                case "Cancelar":
                    return;

                case "Ver detalhes":
                    OpenAppointment(appointment);
                    break;

                case "Desmarcar":
                    Delete(appointment);
                    break;
                }
            }
        }