/// <summary> /// Gets the parent folder of this location /// </summary> /// <param name="loc">Location</param> /// <param name="level">Parent level</param> /// <returns>Parent location</returns> public static ILocation GetParent(this ILocation loc, int level = 1) { if (loc.IsFile()) { return(loc.Create(loc.Root, "", loc.Segments.Take(loc.Segments.Count - (level - 1)))); } else { return(loc.Create(loc.Root, "", loc.Segments.Take(loc.Segments.Count - level))); } }
public async Task <ActionResult <Location> > PostLocation(LocationDTO location) { await _location.Create(location); await _log.CreateLog(HttpContext, User.FindFirst("UserName").Value); return(CreatedAtAction("GetLocation", new { id = location.Id }, location)); }
public async Task <IActionResult> Create([Bind("Id,Name,Description")] LocationDTO location) { if (ModelState.IsValid) { await _location.Create(location); return(RedirectToAction(nameof(Index))); } return(View(location)); }
/// <summary> /// Finds the relative location /// </summary> /// <param name="loc">Location</param> /// <param name="relativeTo">Location to get relative to</param> /// <param name="compType">Comparison type</param> /// <returns>Relative location</returns> public static ILocation GetRelative(this ILocation loc, ILocation relativeTo, StringComparison compType = StringComparison.CurrentCultureIgnoreCase) { if (loc.IsInLocation(relativeTo, compType)) { return(loc.Create("", loc.FileName, loc.Segments.Skip(relativeTo.Segments.Count))); } else { throw new BaseUserMessageException($"'{loc.ToId()}' location is not within the '{relativeTo.ToId()}'"); } }
private SecureLibraryLoader ResolveSecureLibrary(IComponentContext ctx, string manifestPath, string publicKeyXml) { if (!System.IO.File.Exists(manifestPath)) { throw new UserMessageException($"Specified library manifest file is not found: {manifestPath}"); } var manifest = new UserSettingsService().ReadSettings <SecureLibraryManifest>( manifestPath, new BaseValueSerializer <ILocation>(null, x => Location.FromString(x))); ILocation libLoc = Location.FromString(manifestPath); libLoc = libLoc.Create(libLoc.Root, "", libLoc.Segments); return(ctx.Resolve <SecureLibraryLoader>( new TypedParameter(typeof(ILocation), libLoc), new TypedParameter(typeof(SecureLibraryManifest), manifest), new TypedParameter(typeof(string), publicKeyXml))); }
public LocationBO Post([FromBody] LocationBO location) { return(_location.Create(location)); }
/// <summary> /// Combines location with aditional data /// </summary> /// <param name="loc">Location</param> /// <param name="blocks">Blocks to append to location</param> /// <returns>New combined location</returns> public static ILocation Combine(this ILocation loc, params string[] blocks) { return(loc.Create(loc.Root, "", loc.Segments.Concat(blocks))); }
/// <see cref="Combine(ILocation, string[])"/> /// <param name="other">Other location to append to this location</param> public static ILocation Combine(this ILocation loc, ILocation other) { return(loc.Create(loc.Root, other.FileName, loc.Segments.Concat(other.Segments))); }