当前位置: 首页>>代码示例>>C#>>正文


C# IRepository.Any方法代码示例

本文整理汇总了C#中IRepository.Any方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.Any方法的具体用法?C# IRepository.Any怎么用?C# IRepository.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRepository的用法示例。


在下文中一共展示了IRepository.Any方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: foreach

        /// <summary>
        /// This method assumes that RemoteRepo.Load() was already called.
        /// </summary>
        /// <param name="app"></param>
        /// <returns></returns>
        public List<RemoteVsLocalFile> GroupFilesByName
            (string localFoldrPath, IRepository<SyncableFileRemote> repo, SyncDirection syncDirection)
        {
            var list   = new List<RemoteVsLocalFile>();
            var locals = _fileSeeker.GetFiles(localFoldrPath);


            foreach (var loc in locals)
            {
                var rem = repo.One(x => x.Name == loc.Name);
                list.Add(RemVsLoc(loc, rem, syncDirection));
            }


            foreach (var rem in repo.Any(r
                => !list.Has(l => l.Filename == r.Name)))
            {
                var loc = locals.One(x => x.Name == rem.Name);
                list.Add(RemVsLoc(loc, rem, syncDirection));
            }


            //  if no files in folder, or no folder at all,
            //    - assume that it's a first run : download all
            //
            if (locals.Count == 0)
                list.ForEach(x => x.DoNext(Target.Local, FileTask.Create));


            return list;
        }
开发者ID:peterson1,项目名称:ErrH,代码行数:36,代码来源:AppFileGrouper.cs

示例2: TransactionRequestModule

        public TransactionRequestModule(IRepository<TransactionRequest> transactionRequestRepo)
        {
            Get["/Transactions/Request/{requestId}"] = param =>
            {
                var requestId = new Guid(param.requestId);

                if (!transactionRequestRepo.Any(x => x.RequestId == requestId && x.ExpirationDate > DateTime.UtcNow))
                    return Response.AsJson(new { Error = "Request expired" });

                if (transactionRequestRepo.Any(x => x.RequestId == requestId && x.UserState == ApiCommitRequestUserState.Cancelled))
                    return Response.AsJson(new { Error = "Request cancelled by user" });

                if (transactionRequestRepo.Any(x => x.RequestId == requestId && x.ExpirationDate > DateTime.UtcNow))
                    return Response.AsJson(new { Success = "Request valid" });

                return Response.AsJson(new { Error = "Technical error" });
            };
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:18,代码来源:TransactionRequestModule.cs

示例3: UserAliasModule

        public UserAliasModule(IBus bus, IRepository<ClientUserAlias> userAliasRepository, IRepository<User> usereRepository)
        {
            Get["/UserAliases/{clientId:guid}"] = _ =>
            {
                var clientId = (Guid)_.clientId;
                var aliases = userAliasRepository.Where(x => x.Client.Id == clientId);
                return Response.AsJson(Mapper.Map<IEnumerable<ClientUserAlias>, IEnumerable<UserAliasDto>>(aliases));
            };

            //TODO: Error checking for file type. Allow csv only
            Post["/UserAliases/ImportUsers/FilesUpload/{clientId:guid}"] = _ =>
            {
                var clientId = (Guid)_.clientId;
                var filesUploaded = Request.Files;
                var files = new List<FileUploadDto>();
                var clientImportUsers = new List<UserAliasDto>();

                foreach (var httpFile in filesUploaded)
                {
                    //if (httpFile.ContentType != "text/csv")
                    //{
                    //    // Response for file upload component
                    //    files.Add(new FileUploadDto
                    //    {
                    //        name = httpFile.Name,
                    //        size = Convert.ToInt32(httpFile.Value.Length),
                    //        error = "File type not allowed"
                    //    });

                    //    break;
                    //};

                    // CSV to object
                    using (var reader = new StreamReader(httpFile.Value))
                    {
                        var contents = reader.ReadToEnd().Split('\n');
                        var csv = from line in contents select line.Split(',').ToArray();

                        clientImportUsers.AddRange(csv.Skip(1).TakeWhile(r => r.Length > 1 && r.Last().Trim().Length > 0)
                            .Select(row => new UserAliasDto
                            {
                                UuId = row[0],
                                FirstName = row[1],
                                LastName = row[2],
                                UserName = row[3].Replace("\r", ""),
                                ClientId = clientId
                            }));

                        foreach (var clientImportUser in clientImportUsers)
                        {
                            var exists = userAliasRepository.Any(x => x.Client.Id == clientId && x.UserName.Trim().ToLower() == clientImportUser.UserName.Trim().ToLower());
                            if (exists)
                                throw new LightstoneAutoException("{0} already exists".FormatWith(clientImportUser.UserName));
                            var entity = Mapper.Map(clientImportUser, new ClientUserAlias());
                            bus.Publish(new CreateUpdateEntity(entity, "Create"));
                        }
                    }

                    // Response for file upload component
                    files.Add(new FileUploadDto
                    {
                        name = httpFile.Name,
                        size = Convert.ToInt32(httpFile.Value.Length),
                        thumbnailUrl = "http://icons.iconarchive.com/icons/custom-icon-design/pretty-office-2/72/success-icon.png",
                        deleteType = "DELETE"
                    });
                }

                var fileResponseJsonObject = new JObject(new JProperty("files", JsonConvert.SerializeObject(files)));

                return Response.AsJson(fileResponseJsonObject);
            };

            Post["/UserAliases/LinkAlias"] = _ =>
            {
                var dto = this.Bind<AliasDto>();
                var command = new LinkUserAliasCommand(dto.AliasId, dto.CustomerId, dto.UserId);
                bus.Publish(command);

                return Response.AsJson("Saved!");
            };
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:82,代码来源:UserAliasModule.cs


注:本文中的IRepository.Any方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。