Last active
May 10, 2019 19:33
-
-
Save vmandic/e85b3cfe2ef99ae238facfd8e12f99a7 to your computer and use it in GitHub Desktop.
meds-processor part/4 snippet #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
namespace MedsProcessor.Common.Models | |
{ | |
public class HzzoMedsDownloadDto | |
{ | |
private readonly string _rootLocation; | |
public HzzoMedsDownloadDto(string href, string validFrom, string rootLocation) | |
{ | |
this.Href = href; | |
this.ValidFrom = DateTime.Parse(validFrom); | |
this._rootLocation = rootLocation; | |
} | |
[JsonIgnore] | |
public string FilePath => | |
Path.Combine(_rootLocation, FileName); | |
[JsonIgnore] | |
public bool IsDownloaded => | |
File.Exists(FilePath); | |
[JsonIgnore] | |
public string FileName => | |
ValidFrom.ToString("yyyy-MM-dd_") + | |
(Href.Split('/').LastOrDefault() ?? Href.Replace("/", "_").Replace(":", "_")).TrimEnd(); | |
public ISet<HzzoMedsImportDto> MedsList { get; } = new HashSet<HzzoMedsImportDto>(); | |
public string Href { get; set; } | |
public DateTime ValidFrom { get; private set; } | |
[JsonIgnore] | |
public Task<Stream> DocumentStream { get; set; } | |
[JsonIgnore] | |
public bool IsDataParsed { get; private set; } | |
public void MarkAsParsed() => | |
IsDataParsed = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment