예제 #1
0
        /*
         * // Evento para setear el BoxNumber desde otro hilo
         * public void setNumberBoxText(int pElementIndex, string pText)
         * {
         *  if (this.boxArray[pElementIndex].textbox.InvokeRequired)
         *  {
         *      SetNumberBoxTextCallback callBack = new SetNumberBoxTextCallback(setNumberBoxText);
         *      this.Invoke(callBack, new object[] { pElementIndex, pText });
         *  }
         *  else
         *  {
         *      this.boxArray[pElementIndex].textbox.Text = pText;
         *  }
         * }
         * // Evento para obtener el SelectedGroup desde otro hilo
         * public int getSelectedGroup()
         * {
         *  int selectedIndex = 0;
         *  if (this.drawTypeBox.InvokeRequired)
         *  {
         *      GetSelectedGroupCallback callBack = new GetSelectedGroupCallback(getSelectedGroup);
         *      selectedIndex = (int)this.Invoke(callBack, new object[] { });
         *  }
         *  else
         *  {
         *      selectedIndex = this.drawTypeBox.SelectedIndex;
         *  }
         *  Console.WriteLine("selectedIndex: " + selectedIndex);
         *  return selectedIndex;
         * }
         * // Evento para setear el SelectedGroup desde otro hilo
         * public void setSelectedGroup(int pGroupId)
         * {
         *  if (this.drawTypeBox.InvokeRequired)
         *  {
         *      SetSelectedGroupCallback callBack = new SetSelectedGroupCallback(setSelectedGroup);
         *      this.Invoke(callBack, new object[] { pGroupId });
         *  }
         *  else
         *  {
         *      this.drawTypeBox.SelectedIndex = pGroupId;
         *  }
         * }
         * // Evento para setear el TotalImport desde otro hilo
         * public void setTotalImport(string pText)
         * {
         *  if (this.txbTotalImport.InvokeRequired)
         *  {
         *      SetTotalImportCallback callBack = new SetTotalImportCallback(setTotalImport);
         *      this.Invoke(callBack, new object[] { pText });
         *  }
         *  else
         *  {
         *      this.txbTotalImport.Text = pText;
         *  }
         * }
         * // Evento para setear el SyncImport desde otro hilo
         * public void setSyncImport(string pText)
         * {
         *  if (this.txbSyncImport.InvokeRequired)
         *  {
         *      SetSyncImportCallback callBack = new SetSyncImportCallback(setSyncImport);
         *      this.Invoke(callBack, new object[] { pText });
         *  }
         *  else
         *  {
         *      this.txbSyncImport.Text = pText;
         *  }
         * }
         * // Evento para setear el PendingImport desde otro hilo
         * public void setPendingImport(string pText)
         * {
         *  if (this.txbPendingImport.InvokeRequired)
         *  {
         *      SetPendingImportCallback callBack = new SetPendingImportCallback(setPendingImport);
         *      this.Invoke(callBack, new object[] { pText });
         *  }
         *  else
         *  {
         *      this.txbPendingImport.Text = pText;
         *  }
         * }
         * // Evento para setear el MaxToReceive desde otro hilo
         * public void setMaxToReceive(string pText)
         * {
         *  if (this.txbMaxToReceive.InvokeRequired)
         *  {
         *      SetMaxToReceiveCallback callBack = new SetMaxToReceiveCallback(setMaxToReceive);
         *      this.Invoke(callBack, new object[] { pText });
         *  }
         *  else
         *  {
         *      this.txbMaxToReceive.Text = pText;
         *  }
         * }
         */

        //--------------------------------------- Métodos de Actualización --------------------------------------//

        private void updateBoxArray(long pGroupId)
        {
            this.updateTotalBoxes(pGroupId);

            int totalImport = 0;
            //int pendingImport = 0;
            ListService listService = new ListService();

            // Calcular importe sincronizado con el server
            int[] syncTotalImportArray = listService.getDrawTotals(this.datePickerList.Value.Date, pGroupId);
            for (int i = 0; i < syncTotalImportArray.Length; i++)
            {
                totalImport += syncTotalImportArray[i];
                //this.boxArray[i].textbox.Text = FormatService.formatInt(syncTotalImportArray[i]);
                this.setNumberBoxText(i, FormatService.formatInt(syncTotalImportArray[i]));
            }
            this.setTotalImport(FormatService.formatInt(totalImport));

            /*
             * // Calcular importe pendiente de sincronización
             * int[] pendingSyncImportArray = listService.getDrawPendingSyncTotals(this.datePickerList.Value.Date, pGroupId);
             * for (int i = 0; i < syncTotalImportArray.Length; i++)
             * {
             *  pendingImport += pendingSyncImportArray[i];
             * }
             * this.setSyncImport(FormatService.formatInt(totalImport - pendingImport));
             * this.setPendingImport(FormatService.formatInt(pendingImport));
             * int maxToReceive = (int) (totalImport * 0.03);
             * this.setMaxToReceive(maxToReceive == 0 ? "" : FormatService.formatInt(maxToReceive));
             */
        }
예제 #2
0
 public System(CommandService commandService, ListService systemService, CooldownService cooldownService, LeaderboardService lbService)
 {
     _commandService  = commandService;
     _systemService   = systemService;
     _cooldownService = cooldownService;
     _lbService       = lbService;
 }
예제 #3
0
        public void c()
        {
            try
            {
                IUserServiceContext userServiceContext = new UserServiceContext("28b41d8c-73d6-4dea-8cc9-cb99a7192e51", "uc37g5sq8nzryxmhn8n6qemj");
                var contactService = new ContactService(userServiceContext);
                var ListService    = new ListService(userServiceContext);
                var contact        = contactService.GetContacts("*****@*****.**", null, null, null);
                if (contact.Results.Count == 0)
                {
                    var     List = ListService.GetLists(null);
                    Contact c    = new Contact();
                    c.Confirmed = true;
                    c.EmailAddresses.Add(new EmailAddress()
                    {
                        EmailAddr = "*****@*****.**"
                        ,
                        ConfirmStatus = "CONFIRMED",
                        OptInDate     = DateTime.Now.ToString("o"),
                        OptInSource   = "ACTION_BY_VISITOR"
                    });
                    c.Lists = List.ToList();

                    //   c.FirstName = "bhalmung";
                    //  c.LastName = "Knight";

                    var cx = contactService.AddContact(c, true);
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #4
0
        [Route("api/Listing/GetItems")]  // of restaurants, super stores etc
        public ResponseModel GetListOfItems(GetListRequestModel listModel)
        {
            var response = new ResponseModel
            {
                Success  = false,
                Messages = new List <string>()
            };

            if (listModel == null || listModel.Type == 0)    // 1. food  2.grocery
            {
                response.Messages.Add("Mandatory data can not be empty");
            }
            else if (listModel.CurrentPage <= 0 || listModel.ItemsPerPage <= 0)
            {
                response.Messages.Add("Current page/ItemsPerPage should be greater than 0");
            }
            else
            {
                try
                {
                    var items = ListService.GetItemsForList(listModel);
                    response.Data = items;
                    response.Messages.Add("Success");
                    response.Success = true;
                }
                catch (Exception excep)
                {
                    response.Messages.Add("Something bad happened.");
                }
            }
            return(response);
        }
예제 #5
0
 public ListController(ListService listService, UsersService UserService, ReportService reportService)
 {
     _listService   = listService;
     _userService   = UserService;
     _reportService = reportService;
     //actorId=HttpContext.User.Claims.Where(c=>c.Type=="id").FirstOrDefault().Value;
 }
예제 #6
0
 public void _01_ListService_HeartBeatRemote()
 {
     var service = new ListService();
     var address = service.GetServiceAddress(1);
     var client = new HttpService();
     var ret = client.Get(address);
 }
예제 #7
0
        public CollectionContext<ListViewModel> Put(SpecificListsGetRequest listsRequest)
        {
            ServiceUtility.RequestBackendUserAuthentication();

            var listService = new ListService();

            var listManager = listService.GetManager(listsRequest.Provider);

            if (listsRequest.Ids != null && listsRequest.Ids.Length > 0)
            {
                var lists = listService.GetContentItems(listsRequest.Provider)
                                       .Where(l => listsRequest.Ids.Contains(l.Id) && l.Status == ContentLifecycleStatus.Master)
                                       .ToList();

                var liveContentDictionary = this.GetRelevantItemsList(lists, listManager, ContentLifecycleStatus.Live);
                var tempContentDictionary = this.GetRelevantItemsList(lists, listManager, ContentLifecycleStatus.Temp);

                var result = listService.GetViewModelList(lists, listManager.Provider, liveContentDictionary, tempContentDictionary).ToList();

                this.LoadLifecycleStatus(result, liveContentDictionary, tempContentDictionary, listManager);

                ServiceUtility.DisableCache();

                return new CollectionContext<ListViewModel>(result) { TotalCount = result.Count };
            }

            return new CollectionContext<ListViewModel>();
        }
예제 #8
0
        public ResponseModel_GetCatogries GetCatogries(GetCategoriesRequestModel model)
        {
            var response = new ResponseModel_GetCatogries
            {
                Success  = false,
                Messages = new List <string>()
            };

            if (model == null)
            {
                response.Messages.Add("model is not mapped");
                response.Data = model;
            }
            else
            {
                try
                {
                    var menuItems = ListService.GetCategories(model.Status);
                    response.Data            = menuItems;
                    response.MessageContents = "Enjoy free delivery for the whole week from 10am-7pm";
                    response.ShowMessage     = true;
                    response.MessageTitle    = "Free Delivery";

                    response.Messages.Add("Success");
                    response.Success = true;
                }
                catch (Exception excep)
                {
                    response.Messages.Add("Something bad happened.");
                }
            }
            return(response);
        }
예제 #9
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            Singleton.Edition           = PinnaFaceEdition.WebEdition;
            Singleton.BuildType         = BuildType.Production;
            Singleton.SeedDefaults      = true;
            Singleton.UseServerDateTime = true;//TO Handle Datetime.Now from serverornot

            /**************/
            Singleton.SystemVersionDate = DbCommandUtil.GetCurrentDatabaseVersion();

            if (!ValidateProduct())
            {
                LogUtil.LogError(ErrorSeverity.Critical, "ValidateProduct",
                                 "Higher Database Version", "", "");
                return;
            }
            /*****************/

            IEnumerable <ListDTO> aa = new ListService().GetAll();

            new InitializeObjects().InitializeWebSecurity();

            Container = new UnityContainer();
            Container.RegisterType <IDbContext, PinnaFaceServerDBContext>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IUnitOfWork, UnitOfWork>();
        }
        protected async Task HandleAddButtonClick()
        {
            if (SelectedListId > 0)
            {
                DisplayLoadingSpinner = true;

                var request = new AddMovieItemRequest
                {
                    TmdbId = Movie.Id,
                    Title  = Movie.Title
                };

                var response = await ListService.AddMovieToListAsync(SelectedListId, request);

                if (response.Success)
                {
                    DisplayLoadingSpinner = false;
                    ToastService.ShowSuccess(response.Message);
                }
                else
                {
                    DisplayLoadingSpinner = false;
                    ToastService.ShowError(response.Message);
                }
            }
        }
예제 #11
0
        public ResponseModel GetMenu(GetMenuRequestModel listModel)
        {
            var response = new ResponseModel
            {
                Success  = false,
                Messages = new List <string>()
            };

            if (listModel == null || listModel.ItemId == 0)
            {
                response.Messages.Add("ItemId can not be empty");
            }
            else if (listModel.CurrentPage <= 0 || listModel.ItemsPerPage <= 0)
            {
                response.Messages.Add("Current page/ItemsPerPage should be greater than 0");
            }
            else
            {
                try
                {
                    var menuItems = ListService.GetMenuByListItemId(listModel.ItemId);
                    response.Data = menuItems;
                    response.Messages.Add("Success");
                    response.Success = true;
                }
                catch (Exception excep)
                {
                    response.Messages.Add("Something bad happened.");
                }
            }
            return(response);
        }
예제 #12
0
        public void GetAllBlogs_GetAllListsWithItems_Should_Return_Enumerable_TodoLists()
        {
            var listData = new List<TodoList>
            {
                new TodoList { Name = "BBB", Id = 1 },
                new TodoList { Name = "ZZZ", Id = 2 },
                new TodoList { Name = "AAA", Id = 3 },
            };

            var listItemData = new List<TodoListItem>
            {
                new TodoListItem { Id = 1, Name = "testItem", Content = "test content"}
            };

            var connection = Effort.DbConnectionFactory.CreateTransient();
            using (var ctx = new MiniArchDatabaseContext(connection))
            {
                ctx.TodoLists.AddRange(listData);
                ctx.TodoListItems.AddRange(listItemData);
                ctx.SaveChanges();

                var service = new ListService(ctx);
                var todoLists = new List<TodoListModel>(service.GetAllListsWithItems());

                Assert.AreEqual(3, todoLists.Count);
                Assert.AreEqual("BBB", todoLists[0].Name);
                Assert.AreEqual("ZZZ", todoLists[1].Name);
                Assert.AreEqual("AAA", todoLists[2].Name);
            }
        }
예제 #13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         IUserServiceContext userServiceContext = new UserServiceContext(_accessToken, _apiKey);
         IListService        listServiceContext = new ListService(userServiceContext);
         if (Request.QueryString["LeadID"] != null)
         {
             int             leadID    = Convert.ToInt32(Request.QueryString["LeadID"]);
             DailyLeadEntity dailyLead = dailyLeadHelper.GetLeadRecordsByLeadID(leadID);
             txtDoT.Text             = dailyLead.DOTNumber;
             txtBusinessName.Text    = dailyLead.LegalName;
             txtComplianceAgent.Text = Request.Cookies["Name"].Value;
             txtBestPhone.Text       = dailyLead.PhoneNo;
         }
         ContactList[]      contactlist = listServiceContext.GetLists(DateTime.Now.Subtract(new TimeSpan(2000, 2000, 2000))).ToArray();
         List <ContactList> contactData = new List <ContactList>();
         foreach (ContactList item in contactlist)
         {
             ContactList contactitem = item;
             contactData.Add(contactitem);
         }
         drpEmailList.DataSource     = contactData;
         drpEmailList.DataTextField  = "Name";
         drpEmailList.DataValueField = "Id";
         drpEmailList.DataBind();
     }
 }
예제 #14
0
        private async void eraseList(long pListId)
        {
            // Obtener la lista por el id
            ListService     listService = new ListService();
            LTL_LotteryList list        = listService.getById(pListId);

            // Modificar el estado y guardar localmente
            list.LLS_LotteryListStatus = SystemConstants.LIST_STATUS_CANCELED;
            list.SYS_SynchronyStatus   = SystemConstants.SYNC_STATUS_PENDING_TO_SERVER;
            listService.updateList(list);
            // Reversar la lista en el servidor
            SynchronizeService syncService = new SynchronizeService();
            await syncService.processReverseToServerAsync(list);

            // Acciones posteriores a la reversión
            this.Hide();
            MessageService.displayInfoMessage(GeneralConstants.SUCCESS_TRANSACTION_CANCELATION_MESSAGE, GeneralConstants.SUCCESS_TRANSACTION_CANCELATION_TITLE);
            LotteryDrawRepository     drawRepository     = new LotteryDrawRepository();
            LotteryDrawTypeRepository drawTypeRepository = new LotteryDrawTypeRepository();
            ListInstanceForm          listInstance       = new ListInstanceForm(
                this.appMediator,
                this,
                UtilityService.getPointSale(),
                drawTypeRepository.getById(drawRepository.getById(list.LTD_LotteryDraw).LDT_LotteryDrawType),
                DateTime.Today,
                listService.getListDetail(pListId)
                );

            listInstance.StartPosition = FormStartPosition.CenterParent;
            listInstance.ShowDialog();
            //listInstance.ShowDialog(this);
        }
        protected async Task HandleEditListButton()
        {
            var options = new ModalOptions()
            {
                DisableBackgroundCancel = true,
                HideCloseButton         = true
            };

            var parameters = new ModalParameters();

            parameters.Add(nameof(User), User);
            parameters.Add(nameof(MovieList), MovieList);

            var modal  = Modal.Show <EditMovieListForm>("Edit List", parameters, options);
            var result = await modal.Result;

            if (!result.Cancelled && MovieList != null)
            {
                var movieList = await ListService.GetMovieListAsync(MovieList.Id);

                MovieList = movieList;

                StateHasChanged();
            }
        }
예제 #16
0
        private void JPGGenerator()
        {
            ListService service = new ListService(new Reader_HSK());

            var includedWords = service.GetAllWords(1);

            List <Word> arrayIncluded = ToList(includedWords);

            int index = 1;

            foreach (Word_HSK w in arrayIncluded.OrderBy(x => x.NumberPinyin))

            {
                //FANGSONG
                //	KAITI
                //	SIMHEI
                //DengXian

                string sIndex = NumeroCuadrado(index, 3);

                BitmapService.GenerateBitmapfromFontChar(w.Character, "FangSong", FontStyle.Regular, sIndex);
                BitmapService.GenerateBitmapfromFontChar(w.Character, "Kaiti", FontStyle.Regular, sIndex);

                index++;
            }
        }
예제 #17
0
 public static void LoadState(IDictionary <string, object> state)
 {
     if (state.ContainsKey("application-list-service"))
     {
         ListService.LoadLastResult((List <IStationInfo>)state["application-list-service"]);
     }
 }
예제 #18
0
        public CollectionContext <ListViewModel> Put(SpecificListsGetRequest listsRequest)
        {
            ServiceUtility.RequestBackendUserAuthentication();

            var listService = new ListService();

            var listManager = listService.GetManager(listsRequest.Provider);

            if (listsRequest.Ids != null && listsRequest.Ids.Length > 0)
            {
                var lists = listService.GetContentItems(listsRequest.Provider)
                            .Where(l => listsRequest.Ids.Contains(l.Id) && l.Status == ContentLifecycleStatus.Master)
                            .ToList();

                var liveContentDictionary = this.GetRelevantItemsList(lists, listManager, ContentLifecycleStatus.Live);
                var tempContentDictionary = this.GetRelevantItemsList(lists, listManager, ContentLifecycleStatus.Temp);

                var result = listService.GetViewModelList(lists, listManager.Provider, liveContentDictionary, tempContentDictionary).ToList();

                this.LoadLifecycleStatus(result, liveContentDictionary, tempContentDictionary, listManager);

                ServiceUtility.DisableCache();

                return(new CollectionContext <ListViewModel>(result)
                {
                    TotalCount = result.Count
                });
            }

            return(new CollectionContext <ListViewModel>());
        }
예제 #19
0
        public HttpResponseMessage Get(string type)
        {
            try
            {
                List <SelectListItem> list = new List <SelectListItem>();

                switch (type.ToLower())
                {
                case "countries":
                    list = ListService.GetCountries(null, _lookupRepository);
                    break;

                case "gadgets":
                    list = ListService.GetGadgets(_configRepository);
                    break;

                case "roles":
                    list = ListService.GetRoles(_secutiryReposiory);
                    break;

                case "areatypes":
                    list = ListService.GetAreaTypes();
                    break;

                case "galleries":
                    list = ListService.GetGalleries(_galleryRepsitory);
                    break;

                case "articletypes":
                    list = ListService.GetArticleTypes(null, _configRepository);
                    break;

                case "parentcategories":
                    list = ListService.GetParentCategories(null, _lookupRepository);
                    break;

                case "categories":
                    list = ListService.GetCategories(null, _lookupRepository);
                    break;

                case "flags":
                    return(Request.CreateResponse(HttpStatusCode.OK, ListService.GetFlags("")));

                case "phonetypes":
                    list = ListService.GetPhoneTypes(null);
                    break;
                }

                if (list == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NoContent));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, list));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
예제 #20
0
        public ListDetail Get(ListCriteria criteria)
        {
            using (var uow = UnitOfWorkFactory.Create <NovelContext>())
            {
                var service = new ListService(uow);

                var detail = service.Get(criteria);
                // connector
                detail.Connectors = service.View <Connector>()
                                    .Where(w => w.IsDeleted == false && w.ConnectorType == R.ConnectorType.SERIES_USERLIST)
                                    .Where(w => w.TargetID == detail.ID).ToList();

                // series
                var listSeriesIDs = detail.Connectors.Select(s => s.SourceID).ToList();
                detail.Series = new SeriesService(uow).Search(new SearchModel <SeriesCriteria>
                {
                    Criteria = new SeriesCriteria {
                        IDs = listSeriesIDs
                    },
                    PagedListConfig = new PagedListConfig {
                        PageSize = int.MaxValue
                    }
                }).Data;
                // releases
                detail.Releases = service.View <Release>().Where(w => listSeriesIDs.Contains(w.SeriesID)).ToList();
                // user reads
                var releaseIDs = detail.Releases.Select(s => s.ID);
                detail.Reads = service.View <UserRead>().Where(w => w.UserID == criteria.ByUserID)
                               .Where(w => w.SourceTable == R.SourceTable.RELEASE)
                               .Where(w => releaseIDs.Contains(w.SourceID)).ToList();

                return(detail);
            }
        }
예제 #21
0
        public void LoadProfessionsAmharic()
        {
            ProfessionsAmharic        = new ObservableCollection <ListDataItem>();
            SelectedProfessionAmharic = new ListDataItem();

            IEnumerable <string> professionsAmharicList = new ListService(true)
                                                          .GetAll()
                                                          .Where(l => l.Type == ListTypes.ProfessionAmharic)
                                                          .Select(l => l.DisplayName).Distinct().ToList();
            //IEnumerable<string> professionsAmharicList2 = new VisaService(true)
            //    .GetAllConditions()
            //    .Select(l => l.ProfessionAmharic).Distinct().ToList();

            //professionsAmharicList = professionsAmharicList.Union(professionsAmharicList2).Distinct();

            var i = 0;

            foreach (var item in professionsAmharicList)
            {
                var dataItem = new ListDataItem
                {
                    Display = item,
                    Value   = i
                };
                ProfessionsAmharic.Add(dataItem);
                i++;
            }
        }
예제 #22
0
        public async Task GetList_ShouldCallListRepositoryGet()
        {
            // Data
            var listModel = new ListModel {
                Name = "todo list"
            };
            var listEntity = new Data.Entities.List {
                Name = "todo list"
            };
            IEnumerable <Data.Entities.List> lists = new List <Data.Entities.List>
            {
                listEntity
            };

            // Setup
            _mockListRepository.Setup(x => x.Get(listModel.Id, listModel.UserId, listModel.Name))
            .Returns(Task.FromResult(lists)).Verifiable();

            // Test
            var listService = new ListService(_mockListRepository.Object);
            await listService.GetList(listModel);

            // Analysis
            _mockListRepository.Verify();
        }
 public MailChimpApi()
 {
     RestClient   = new RestClient(this);
     ListService  = new ListService(RestClient);
     UseHttps     = true;
     OutputFormat = Format.json;
 }
예제 #24
0
        private ListService CreateListService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new ListService(userId);

            return(service);
        }
예제 #25
0
        public void TestList_List_Post_Using_LINQ_Operations()
        {
            IListService <BloggingContext, Post> listService = new ListService <BloggingContext, Post>(this._context);
            var queryable = listService.List <PostDto>();

            Assert.Null(queryable.Where(x => x.PostId == 999).FirstOrDefault());
            Assert.Null(queryable.Where(x => x.PostId == 999).SingleOrDefault());
            Assert.Null(queryable.FirstOrDefault(x => x.PostId == 999));
            Assert.Null(queryable.SingleOrDefault(x => x.PostId == 999));
            Assert.Throws <InvalidOperationException>(() => queryable.Where(x => x.PostId == 999).Single());
            Assert.Throws <InvalidOperationException>(() => queryable.Where(x => x.PostId == 999).First());
            Assert.Throws <InvalidOperationException>(() => queryable.Single(x => x.PostId == 999));
            Assert.Throws <InvalidOperationException>(() => queryable.First(x => x.PostId == 999));
            var a = queryable.Where(x => x.PostId == 1).FirstOrDefault();

            Assert.NotNull(queryable.Where(x => x.PostId == 1).FirstOrDefault());
            Assert.NotNull(queryable.Where(x => x.PostId == 1).SingleOrDefault());
            Assert.NotNull(queryable.FirstOrDefault(x => x.PostId == 1));
            Assert.NotNull(queryable.SingleOrDefault(x => x.PostId == 1));
            Assert.NotNull(queryable.Where(x => x.NumberOfBlogsBelongTo == 1).FirstOrDefault());
            Assert.NotNull(queryable.FirstOrDefault(x => x.NumberOfBlogsBelongTo == 1));
            Assert.Equal(4, queryable.Where(x => x.NumberOfBlogsBelongTo == 1).Count());
            Assert.Equal(4, queryable.Count(x => x.NumberOfBlogsBelongTo == 1));
            var c = queryable.OrderByDescending(x => x.PostId);

            Assert.Equal(4, queryable.OrderByDescending(x => x.PostId).ThenBy(x => x.NumberOfBlogsBelongTo).First().PostId);
        }
예제 #26
0
        public ResponseModel SetFavouriteItem(AddFavtItemRequestModel item)
        {
            var response = new ResponseModel
            {
                Success  = false,
                Messages = new List <string>()
            };

            if (item == null || string.IsNullOrEmpty(item.UserId) || string.IsNullOrEmpty(item.ItemId))
            {
                response.Messages.Add("Mandatory data can not be empty");
            }
            else
            {
                try
                {
                    var responseCall = ListService.AddRemove_Favourite_Restaurent(item);
                    response.Data = item;
                    response.Messages.Add(responseCall);
                    response.Success = true;
                }
                catch (Exception excep)
                {
                    response.Messages.Add("Something bad happened.");
                }
            }
            return(response);
        }
예제 #27
0
        public ResponseModel GetListOfFavouriteItems(GetFavouriteListRequestModel listModel)
        {
            var response = new ResponseModel
            {
                Success  = false,
                Messages = new List <string>()
            };

            if (listModel == null || string.IsNullOrEmpty(listModel.UserId) || string.IsNullOrEmpty(listModel.Cords))
            {
                response.Messages.Add("Mandatory data can not be empty");
                response.Data = listModel;
            }
            else if (listModel.CurrentPage <= 0 || listModel.ItemsPerPage <= 0)
            {
                response.Messages.Add("Current page/ItemsPerPage should be greater than 0");
                response.Data = listModel;
            }
            else
            {
                try
                {
                    var items = ListService.GetI_Favourite_temsForList(listModel);
                    response.Data = items;
                    response.Messages.Add("Success");
                    response.Success = true;
                }
                catch (Exception excep)
                {
                    response.Messages.Add("Something bad happened.");
                }
            }
            return(response);
        }
예제 #28
0
        public void TestList_List_Blog_Using_LINQ_Project_Operations_Not_Supported()
        {
            IListService <BloggingContext, Blog> listService = new ListService <BloggingContext, Blog>(this._context);
            var queryable = listService.List <BlogDto>();

            Assert.Throws <InvalidOperationException>(() => queryable.Select(x => x.Posts.First()));
            Assert.Throws <InvalidOperationException>(() => queryable.SelectMany(x => x.Posts));
        }
예제 #29
0
        public void TestList_Query_Post()
        {
            IListService <BloggingContext, Post> listService = new ListService <BloggingContext, Post>(this._context);
            var result = listService.Query <PostDto>(x => x.PostId == 1);

            Assert.Equal(1, result.Result.Count);
            Assert.Equal(1, result.Result[0].NumberOfBlogsBelongTo);
        }
예제 #30
0
        public void Ctor_NullUnitOfWork_ThrowsArgumentNullException()
        {
            IUnitOfWork unitOfWork = null;
            var listRepo = new Mock<IListRepository>();
            var user = new User();

            var listService = new ListService(unitOfWork, listRepo.Object, user);
        }
예제 #31
0
        public void TestList_List_Post_ByPostId_And_NumberofBlogs_1()
        {
            IListService <BloggingContext, Post> listService = new ListService <BloggingContext, Post>(this._context);
            var queryable = listService.List <PostDto>().Where(x => x.PostId == 1).Where(x => x.NumberOfBlogsBelongTo == 0);
            var result    = queryable.ToList();

            Assert.Equal(0, result.Count);
        }
예제 #32
0
        public IHttpActionResult list([FromBody] JObject filter)
        {
            ListService<DBUser> ls = new ListService<DBUser>(filter, ctx.DBUsers);

            List<IEntity> list = ls.q.ToList<IEntity>();

            return Json(list);
        }
예제 #33
0
 public BreakAwayManager(ListService listServiceInstance)
 {
     _breakAwayCfg     = new BreakAwayCfgHelper();
     _configuration    = _breakAwayCfg.GetConfiguration();
     _loginSession     = new LoginSession();
     _listService      = listServiceInstance;
     _breakAwayLatency = GetBreakAwayLatencyValue();
 }
예제 #34
0
 public int AddList(ListForm form)
 {
     using (var uow = UnitOfWorkFactory.Create <NovelContext>())
     {
         var service = new ListService(uow);
         return(service.SaveChanges(form));
     }
 }
        protected override IListService CreateService()
        {
            var store = new EmbeddableDocumentStore { RunInMemory = true };
            store.Conventions.DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites;
            store.Initialize();
            var service = new ListService(new ListRepository(store));
            DocumentStore = store;

            return service;
        }
예제 #36
0
        public void Ctor_Success()
        {
            var unitOfWork = new Mock<IUnitOfWork>();
            var listRepo = new Mock<IListRepository>();
            var user = new User();

            var listService = new ListService(unitOfWork.Object, listRepo.Object, user);

            Assert.IsNotNull(listService);
        }
        public void Check01ReferencesOk()
        {

            //SETUP    

            //ATTEMPT
            IListService<Blog, SimpleBlogWithPostsDto> listService = new ListService<Blog, SimpleBlogWithPostsDto>(null);

            //VERIFY
            (listService is ListService<Blog, SimpleBlogWithPostsDto>).ShouldEqual(true);
        }
        public void Check01ReferencesOk()
        {

            //SETUP    

            //ATTEMPT
            ICreateService<Post, DetailPostDto> createService = new CreateService<Post, DetailPostDto>(null);
            IDetailService<Post, DetailPostDto> detailService = new DetailService<Post, DetailPostDto>(null);
            IListService<Post, DetailPostDto> listService = new ListService<Post, DetailPostDto>(null);
            IUpdateService<Post, DetailPostDto> updateService = new UpdateService<Post, DetailPostDto>(null);

            //VERIFY
            (listService is ListService<Post, DetailPostDto>).ShouldEqual(true);
        }
        public void Test01DirectReferenceOk()
        {

            //SETUP    

            //ATTEMPT
            ICreateService<Post> createService = new CreateService<Post>(null);
            IDetailService<Post> detailService = new DetailService<Post>(null);
            IListService<Post> listService = new ListService<Post>(null);
            IUpdateService<Post> updateService = new UpdateService<Post>(null);

            //VERIFY
            (listService is IListService<Post>).ShouldEqual(true);
        }
        public void Test01ListOrderDetailViaServiceOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service = new ListService(db);

                //ATTEMPT
                var list = service.GetAll<CrudSalesOrderDetailDto>().ToList();

                //VERIFY
                list.Count.ShouldBeGreaterThan(0);
                list.First().ProductName.ShouldNotEqualNull();
            }
        }
        public void Test02ListSalesOrdersViaServiceOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service = new ListService(db);

                //ATTEMPT
                var list = service.GetAll<ListSalesOrderDto>().ToList();

                //VERIFY
                list.Count.ShouldBeGreaterThan(0);
                list[0].CustomerCompanyName.ShouldNotEqualNull();
            }
        }
        public void Test05ListCustomersViaServiceProductCategoryIdNonNullOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service = new ListService(db);

                //ATTEMPT
                var list = service.GetAll<Product>().Computed().ToList();

                //VERIFY
                list.Count.ShouldBeGreaterThan(0);
                list.Any( x => x.ProductCategoryIDNonNull != 0).ShouldEqual(true);
            }
        }
        public void Test01ListCustomersCheckIsOnSaleOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP

                var service = new ListService(db);

                //ATTEMPT
                var list = service.GetAll<ListProductDto>().Computed().ToList();

                //VERIFY
                list.Count.ShouldBeGreaterThan(0);
                list.Where( c => c.SellStartDate < DateTime.Today && (DateTime.Today <= (c.SellEndDate ?? DateTime.Today))).All( x => x.IsOnSale).ShouldEqual(true);
                list.Where(c => !(c.SellStartDate < DateTime.Today && (DateTime.Today <= (c.SellEndDate ?? DateTime.Today)))).All(x => x.IsOnSale).ShouldEqual(false);
            }
        }
        public void Test02ListDirectPostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new ListService<Post>(db);
                var firstPost = db.Posts.Include(x => x.Blogger).First();

                //ATTEMPT
                var list = service.GetAll().Include(x => x.Blogger).ToList();
                
                //VERIFY
                list.Count().ShouldEqual(3);
                list.First().Title.ShouldEqual(firstPost.Title);
                list.First().Blogger.Name.ShouldEqual(firstPost.Blogger.Name);
                list.First().Tags.ShouldEqual(null);
            }
        }
        public void Check01ListGradesOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new ListService<PostTagGrade, SimplePostTagGradeDto>(db);
                var firstGrade = db.PostTagGrades.Include(x => x.TagPart).Include(x => x.PostPart).First();

                //ATTEMPT
                var list = service.GetAll().ToList();

                //VERIFY
                list.Count().ShouldEqual(2);
                list.First().PostPartTitle.ShouldEqual(firstGrade.PostPart.Title);
                list.First().TagPartName.ShouldEqual(firstGrade.TagPart.Name);

            }
        }
        public void Test02ListCustomersViaServiceNoTotalOrdersOk()
        {
            using (var db = new AdventureWorksLt2012())
            {
                //SETUP
                var service = new ListService(db);
                var log = new List<string>();
                db.Database.Log = log.Add;

                //ATTEMPT
                var query = service.GetAll<ListCustomerDto>().Where(x => !x.HasBoughtBefore);
                var customers = query.ToList();

                //VERIFY
                customers.Count.ShouldBeGreaterThan(0);
                customers[0].FullName.ShouldNotEqualNull();
                customers.All(x => x.TotalAllOrders == 0).ShouldEqual(true);
            }
        }
        public void Check02NoComputedTakenInDtoDecomplierOnButNoComputedCopiedOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                GenericServicesConfig.UseDelegateDecompilerWhereNeeded = true;
                var service = new ListService<Post, SimplePostDto>(db);
                var firstPost = db.Posts.Include(x => x.Blogger).OrderBy(x => x.PostId).First();

                //ATTEMPT
                var list = service.GetAll().OrderBy(x => x.PostId).ToList();

                //VERIFY
                list.Count().ShouldEqual(3);
                list.First().Title.ShouldEqual(firstPost.Title);
                list.First().BloggerName.ShouldEqual(firstPost.Blogger.Name);
                list.First().Tags.ShouldNotEqualNull();
            }
        }
        public void Check02ListBlogsCheckIncludesPostsOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new ListService<Blog, SimpleBlogWithPostsDto>(db);

                //ATTEMPT
                var list = service.GetAll().ToList();

                //VERIFY
                list.Count().ShouldEqual(2);
                var firstBlog = db.Blogs.Include(x => x.Posts).AsNoTracking().First();
                list.First().Name.ShouldEqual(firstBlog.Name);
                list.First().EmailAddress.ShouldEqual(firstBlog.EmailAddress);
                list.First().Posts.ShouldNotEqualNull();
                CollectionAssert.AreEquivalent(firstBlog.Posts.Select(x => x.PostId), list.First().Posts.Select(x => x.PostId));
            }
        }
        public void Check02ListPostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new ListService<Post, SimplePostDto>(db);

                //ATTEMPT
                var list = service.GetAll().ToList();

                //VERIFY
                list.Count().ShouldEqual(3);
                list.First().Title.ShouldEqual("First great post");
                list.First().BloggerName.ShouldEqual("Jon Smith");
                list.First().TagNames.ShouldEqual("Ugly post, Good post");
                list.First().LastUpdatedUtc.Kind.ShouldEqual(DateTimeKind.Utc);

            }
        }
        public void Check05ListComputedOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                GenericServicesConfig.UseDelegateDecompilerWhereNeeded = true;
                var service = new ListService<Post, DelegateDecompilePostDto>(db);
                var firstPost = db.Posts.Include(x => x.Tags).First();

                //ATTEMPT
                var list = service.GetAll().OrderBy(x => x.PostId).ToList();

                //VERIFY
                list.Count().ShouldEqual(3);
                list.First().Title.ShouldEqual(firstPost.Title);
                list.First().BloggerNameAndEmail.ShouldEndWith("nospam.com)");
                list.First().TagNames.ShouldNotEqualNull();
                CollectionAssert.AreEqual(firstPost.Tags.Select(x => x.Name), list.First().TagNames); 
            }
        }
        public void Check02ListPostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new ListService(db);
                var firstPost = db.Posts.Include(x => x.Blogger).First();

                //ATTEMPT
                var query = service.GetAll<Post>().Include(x => x.Blogger);
                var list = query.ToList();

                //VERIFY
                list.Count.ShouldEqual(3);
                list[0].Title.ShouldEqual(firstPost.Title);
                list[0].Blogger.Name.ShouldEqual(firstPost.Blogger.Name);
                list[0].Tags.ShouldEqual(null);

            }
        }
        public void Check02ListPostOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var service = new ListService<Post, DetailPostDto>(db);

                //ATTEMPT
                var list = service.GetAll().ToList();

                //VERIFY
                list.Count().ShouldEqual(3);
                var firstPost = db.Posts.Include(x => x.Tags).ToList().First(x => x.PostId == list.First().PostId);
                list.First().Title.ShouldEqual(firstPost.Title);
                list.First().Content.ShouldEqual(firstPost.Content);
                list.First().BloggerName.ShouldEqual(firstPost.Blogger.Name);
                list.First().TagNames.ShouldEqual("Ugly post, Good post");
                list.First().LastUpdatedUtc.Kind.ShouldEqual(DateTimeKind.Utc);
            }
        }
예제 #53
0
        public void CreateToDoList_Should_Create_ToDoList()
        {
            var connection = Effort.DbConnectionFactory.CreateTransient();
            using (var ctx = new MiniArchDatabaseContext(connection))
            {
                //write the list
                var service = new ListService(ctx);
                service.CreateToDoList(new TodoListModel()
                {
                    Name = "test list"
                });

                //get the list

                var todoLists = ctx.TodoLists.ToList();
                Assert.AreEqual(todoLists.Count, 1);
                Assert.AreEqual(todoLists[0].Name, "test list");

            }
        }
예제 #54
0
 private static void RunCommand2(IGenericServicesDbContext db)
 {
     var service = new ListService(db);
     var list = service.GetAll<SimplePostDto>().ToList();
 }
        public void Check10ListNestedComputedOk()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                GenericServicesConfig.UseDelegateDecompilerWhereNeeded = true;
                var service = new ListService<Tag, DelegateDecompileNeededPostDto>(db);
                var firstTag = db.Tags.Include(x => x.Posts).First();

                //ATTEMPT
                var list = service.GetAll().OrderBy(x => x.TagId).ToList();

                //VERIFY
                list.Count().ShouldEqual(3);
                list.First().Name.ShouldEqual(firstTag.Name);
                list.First().Posts.First().BloggerNameAndEmail.ShouldNotEqualNull();
            }
        }
        public void Check09UpdateWithListDtoBad()
        {
            using (var db = new SampleWebAppDb())
            {
                //SETUP
                var listService = new ListService<Post, SimplePostDto>(db);
                var firstPostUntracked = listService.GetAll().First();
                var service = new UpdateService<Post, SimplePostDto>(db);

                //ATTEMPT
                firstPostUntracked.Title = "Can't I ask a question?";
                var status = service.Update(firstPostUntracked);
                firstPostUntracked.LogSpecificName("End");

                //VERIFY
                status.IsValid.ShouldEqual(false);
                status.Errors.Count.ShouldEqual(1);
                status.Errors[0].ErrorMessage.ShouldEqual("Sorry, but you can't ask a question, i.e. the title can't end with '?'.");

            }
        }