コード例 #1
0
 /// <summary>
 /// 投票选项数添加
 /// </summary>
 /// <param name="Num">投票数</param>
 /// <param name="option">选项</param>
 /// <param name="guid">选项ID</param>
 /// <returns></returns>
 public DZAFCPortal.Entity.OnlineVoteOptions CreateNewPrefer(int Num, string option, string guid)
 {
     DZAFCPortal.Entity.OnlineVoteOptions op = new DZAFCPortal.Entity.OnlineVoteOptions();
     op            = GenericService.GetAll().Where(p => p.NY_OnlineVoteID == guid).Where(p => p.Option == option).FirstOrDefault();
     op.ReviewsNum = Num + 1;
     return(op);
 }
コード例 #2
0
        public void Generic_Create_Service()
        {
            var fakeContext = new FakeContext("Generic_Create_Service");

            fakeContext.FillWithAll();

            using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object))
            {
                var repository = new GenericRepository <Product>(context);
                var service    = new GenericService <Product>(repository);

                var product = new Product("1000", "Product 1", 10M, 15, new DateTime(2019, 03, 10),
                                          new DateTime(2020, 7, 14));

                var response = service.Create(product);

                Assert.Equal(6, service.GetAll().Count());
                Assert.Equal("{ Message = Produto cadastrado com sucesso. }", response.ToString());
                Assert.Equal("1000", service.GetById(6).Sku);
                Assert.Equal("Product 1", service.GetById(6).Name);
                Assert.Equal(10M, service.GetById(6).Price);
                Assert.Equal(15, service.GetById(6).Quantity);
                Assert.Equal(2019, service.GetById(6).CreatedAt.Year);
            }
        }
コード例 #3
0
        public void SureRendingReply(Guid itemId)
        {
            var item = GenericService.GetModel(itemId);

            if (item == null)
            {
                throw new Exception("用户不存在,或已被删除!");
            }

            item.ApplyState = 99;

            var newItem = new DZAFCPortal.Entity.MyFriends();

            newItem.ID              = Guid.NewGuid().ToString();
            newItem.UserAccount     = item.MyFriendAccount;
            newItem.MyFriendAccount = item.UserAccount;
            newItem.ApplyState      = 99;

            //判断用户是否在另一用户列表中
            var _temp = GenericService.GetAll(p => p.UserAccount == newItem.UserAccount && p.MyFriendAccount == newItem.MyFriendAccount).FirstOrDefault();

            if (_temp != null)
            {
                _temp.ApplyState = 99;
                GenericService.Update(_temp);
            }
            else
            {
                GenericService.Add(newItem);
            }

            GenericService.Save();
        }
コード例 #4
0
        public void Generic_Delete_Product_NotFound_Service_Warehouse()
        {
            var fakeContext = new FakeContext("Generic_Delete_Product_NotFound_Service_Warehouse");

            fakeContext.FillWith <Product>();

            using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object))
            {
                var repository = new GenericRepository <Product>(context);
                var service    = new GenericService <Product>(repository);

                var countBefore = service.GetAll().Count();

                Assert.Equal(5, countBefore);
                var response = service.Delete(6);
                Assert.Equal("{ Message = Produto não encontrado. }", response.ToString());
                Assert.Equal(5, service.GetAll().Count());
            }
        }
コード例 #5
0
        public void Generic_Delete_Service()
        {
            var fakeContext = new FakeContext("Generic_Delete_Service");

            fakeContext.FillWithAll();

            using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object))
            {
                var repository = new GenericRepository <Product>(context);
                var service    = new GenericService <Product>(repository);

                var countBefore = service.GetAll().Count();

                Assert.Equal(5, countBefore);
                var response = service.Delete(1);
                Assert.Equal("{ Message = Produto removido com sucesso. }", response.ToString());
                Assert.Equal(4, service.GetAll().Count());
            }
        }
コード例 #6
0
        public bool IsRoleExsist(string name, string id, bool isEdit)
        {
            System.Linq.Expressions.Expression <Func <Role, bool> > predicate = p => p.Name == name;
            if (isEdit)
            {
                predicate = p => p.Name == name && p.ID != id;
            }

            var items = GenericService.GetAll(predicate);

            return(items != null && items.Count() > 0);
        }
コード例 #7
0
        /// <summary>
        /// 判断是否已投票
        /// </summary>
        /// <param name="guid">评选ID</param>
        /// <returns></returns>
        public bool IsOnline(string guid)
        {
            bool   result   = false;
            string userName = UserInfo.Account;
            var    od       = GenericService.GetAll().Where(p => p.OnlineVoteID == guid && p.UserName == userName).ToList();

            if (od.Count > 0)
            {
                result = true;
            }
            return(result);
        }
コード例 #8
0
        /// <summary>
        /// 判断活动名额是否已满
        /// </summary>
        /// <param name="guid">活动ID</param>
        /// <returns></returns>
        public bool isBookMax(string guid)
        {
            ActivitiesService eventSerivce = new ActivitiesService();
            bool result           = false;
            var  booktimeRegister = eventSerivce.GenericService.GetModel(guid);
            var  teamRegister     = GenericService.GetAll(p => p.NY_EventSolicitationID == guid).ToList();
            int  MaxCount         = booktimeRegister.MaxPersonCount;
            int  UsedMaxCOunt     = teamRegister.Count;

            if (teamRegister.Count >= MaxCount)
            {
                result = true;
            }
            return(result);
        }
コード例 #9
0
        public List <StaffHome_VM> GetHomeOnline()
        {
            List <StaffHome_VM> listHn = new List <StaffHome_VM>();
            var online = GenericService.GetAll().OrderByDescending(p => p.CreateTime).Take(2).ToList();

            foreach (OnlineVote na in online)
            {
                StaffHome_VM hn = new StaffHome_VM();
                hn.Id         = na.ID;
                hn.Name       = na.Title;
                hn.Type       = "NY_Online.aspx";
                hn.CreateTime = na.CreateTime;
                listHn.Add(hn);
            }
            return(listHn);
        }
コード例 #10
0
        public List <StaffHome_VM> GetHighlights()
        {
            List <StaffHome_VM> listHn = new List <StaffHome_VM>();
            var auction = GenericService.GetAll().OrderByDescending(p => p.CreateTime).Take(2).ToList();

            foreach (Highlights na in auction)
            {
                StaffHome_VM hn = new StaffHome_VM();
                hn.Id         = na.ID;
                hn.Name       = na.AuctionName;
                hn.Type       = "HighlightList.aspx";
                hn.CreateTime = na.CreateTime;
                listHn.Add(hn);
            }
            return(listHn);
        }
コード例 #11
0
        public void Generic_GetAll_Service()
        {
            var fakeContext = new FakeContext("Generic_GetAll_Service");

            fakeContext.FillWithAll();

            using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object))
            {
                var repository = new GenericRepository <Product>(context);
                var service    = new GenericService <Product>(repository);

                var contextProducts = context.Products;
                var serviceProducts = service.GetAll();
                var contextCount    = contextProducts.Count();
                var serviceCount    = serviceProducts.Count();

                Assert.Equal(contextCount, serviceCount);
                Assert.IsType <int>(serviceCount);
                Assert.Equal(contextProducts, serviceProducts);
            }
        }
コード例 #12
0
        public void GetAll_Should_InvokeGenericRepositoryGetAll_Once()
        {
            var returnValue = _genericService.GetAll();

            _mockGenericRepository.Verify(x => x.GetAll(It.IsAny <bool>()), Times.Once);
        }
コード例 #13
0
 public virtual List <T> GetAll()
 {
     return(service.GetAll());
 }
コード例 #14
0
        /// <summary>
        /// 获取登录用户 待审批的好友
        /// </summary>
        /// <returns></returns>
        public List <MyFriends> GetFriendPendingReply(string userAccount)
        {
            // 用户待审批好友

            return(GenericService.GetAll(p => p.MyFriendAccount == userAccount && p.ApplyState == 0).ToList());
        }
コード例 #15
0
 public IActionResult List()
 {
     return(View(service.GetAll()));
 }
コード例 #16
0
 internal async virtual Task <ActionResult <IEnumerable <TEntity> > > Gets()
 {
     return(Ok(await service.GetAll()));
 }
コード例 #17
0
 public ImmediateSupervisorSettings GetUserImmediateSupervisor(string account)
 {
     return(GenericService.GetAll(p => p.Account == account).FirstOrDefault());
 }
コード例 #18
0
ファイル: AttachService.cs プロジェクト: liuying0525/lyprotal
 /// <summary>
 /// 获取内容下的所有附件
 /// </summary>
 /// <param name="contentID">内容主体ID</param>
 /// <param name="type">类型 一般在添加时会为各分类的添加类别</param>
 /// <returns></returns>
 public List <Attach> GetContentAttachs(string contentID, int type)
 {
     return(GenericService.GetAll(p => p.ContentID == contentID && p.Type == type.ToString()).ToList());
 }
コード例 #19
0
ファイル: Program.cs プロジェクト: KSchlagowski/warehouse
        static void Main(string[] args)
        {
            GenericService <Item> genericItemService = new GenericService <Item>();

            Item itemForGeneric  = new Item(1, "Apple");
            Item item2ForGeneric = new Item(2, "Strawberry");

            genericItemService.Add(itemForGeneric);
            genericItemService.Add(item2ForGeneric);

            var items = genericItemService.GetAll();


            genericItemService.Remove(item2ForGeneric);

            GenericService <MenuAction> genericActionService = new GenericService <MenuAction>();
            MenuAction menuAction = new MenuAction(1);

            genericActionService.Add(menuAction);

            MenuActionService actionService = new MenuActionService();
            ItemService       itemService   = new ItemService();

            actionService = Initialize(actionService);

            Console.WriteLine("Welcome to warehouse app!");
            while (true)
            {
                Console.WriteLine("Please let me know what you want to do:");
                var mainMenu = actionService.GetMenuActionsByMenuName("Main");
                for (int i = 0; i < mainMenu.Count; i++)
                {
                    Console.WriteLine($"{mainMenu[i].Id}. {mainMenu[i].Name}");
                }

                var operation = Console.ReadKey();

                switch (operation.KeyChar)
                {
                case '1':
                    var keyInfo = itemService.AddNewItemView(actionService);
                    var id      = itemService.AddNewItem(keyInfo.KeyChar);
                    break;

                case '2':
                    var removeId = itemService.RemoveItemView();
                    itemService.RemoveItem(removeId);
                    break;

                case '3':
                    var detailId = itemService.ItemDetailSelectionView();
                    itemService.ItemDetailView(detailId);
                    break;

                case '4':
                    var typeId = itemService.ItemTypeSelectionView();
                    itemService.ItemsByTypeIdView(typeId);
                    break;

                default:
                    Console.WriteLine("Action you entered does not exist");
                    break;
                }
            }
        }
コード例 #20
0
 /// <summary>
 /// 获取用户
 /// </summary>
 /// <param name="userAccount"></param>
 /// <returns></returns>
 public List <MyFriends> GetMyFriends(string userAccount)
 {
     return(GenericService.GetAll(p => p.UserAccount == userAccount && p.ApplyState == 99).OrderByDescending(p => p.CreateTime).ToList());
 }