Ejemplo n.º 1
0
        public Task <DataResult <bool> > DeleteAsync(int accessaryUnitId)
        {
            return(Task.Run(() => {
                if (!accessaryRepository.ExistByCondition(x => x.UnitId == accessaryUnitId))
                {
                    accessaryUnitRepository.Delete(accessaryUnitId);
                    _unitOfWork.SaveChanges();

                    return new DataResult <bool> {
                        Errors = new List <ErrorDescriber>(), Target = true
                    };
                }
                else
                {
                    var dependentErrorMessage = ConfigExtensions <string> .GetValue("dependentErrorMessage");
                    dependentErrorMessage = dependentErrorMessage.Replace("%ItemType%", "đơn vị tính");

                    return new DataResult <bool>
                    {
                        Target = false,
                        Errors = new List <ErrorDescriber> {
                            new ErrorDescriber(dependentErrorMessage)
                        }
                    };
                }
            }));
        }
        public static string[] GetVirtualPaths(BundConfigType type, string folderName)
        {
            string[] filePaths = null;
            var      folder    = ConfigExtensions <string> .GetValue(folderName);

            if (type == BundConfigType.Css)
            {
                var cssDirectory = string.Concat(defaultCssFilePath, folder);
                var directory    = HostingEnvironment.MapPath(cssDirectory);
                filePaths = new DirectoryInfo(directory).EnumerateFiles("*.*", SearchOption.AllDirectories)
                            .Where(d => d.Name.EndsWith(".css") || d.Name.EndsWith(".map") || d.Name.EndsWith(".less"))
                            .Select(d => string.Concat(cssDirectory, d.Name)).ToArray();
            }
            else if (type == BundConfigType.Js)
            {
                var jsDirectory = string.Concat(defaultJsFilePath, folder);
                var directory   = HostingEnvironment.MapPath(jsDirectory);
                filePaths = new DirectoryInfo(directory).GetFiles("*.js", SearchOption.TopDirectoryOnly)
                            .Select(d => string.Concat(jsDirectory, d.Name)).ToArray();
            }
            return(filePaths);
        }