From d14ee1d6abe61c3f9fb963a59fb8a46a7de68fa7 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sat, 8 Apr 2017 00:32:23 +0200 Subject: [PATCH] refactoring --- Yavsc/ApiControllers/HairCutController.cs | 8 +-- .../20170217221646_bookQueryStatus.cs | 2 +- .../Billing/NominativeServiceCommand.cs | 3 +- Yavsc/Models/Haircut/HairCutQuery.cs | 3 +- .../Models/Haircut/Views/HaircutQueryInfo.cs | 47 ++++++++++++++ Yavsc/Models/Workflow/Query.cs | 3 +- YavscLib/HairCut/Haircut.cs | 65 +++++++++++++++++++ YavscLib/HairCut/IHairCutQuery.cs | 10 --- .../{IPrestation.cs => IHairPrestation.cs} | 4 +- .../Workflow/QueryStatus.cs | 6 +- 10 files changed, 125 insertions(+), 26 deletions(-) create mode 100644 Yavsc/Models/Haircut/Views/HaircutQueryInfo.cs create mode 100644 YavscLib/HairCut/Haircut.cs delete mode 100644 YavscLib/HairCut/IHairCutQuery.cs rename YavscLib/HairCut/{IPrestation.cs => IHairPrestation.cs} (84%) rename {Yavsc/Interfaces => YavscLib}/Workflow/QueryStatus.cs (78%) diff --git a/Yavsc/ApiControllers/HairCutController.cs b/Yavsc/ApiControllers/HairCutController.cs index 2a1cb628..eea1657a 100644 --- a/Yavsc/ApiControllers/HairCutController.cs +++ b/Yavsc/ApiControllers/HairCutController.cs @@ -5,13 +5,13 @@ using Microsoft.Extensions.Localization; namespace Yavsc.ApiControllers { + using YavscLib; using System; using System.Linq; using System.Security.Claims; using Microsoft.Extensions.Logging; using Models; using Services; - using Yavsc.Interfaces.Workflow; using Yavsc.Models.Haircut; using Yavsc.Resources; @@ -54,8 +54,8 @@ namespace Yavsc.ApiControllers var now = DateTime.Now; var result = _context.HairCutQueries.Where( q=>q.ClientId == uid - && q.EventDate > now - && q.Status == QueryStatus.Inserted + && q.EventDate > now + && q.Status == QueryStatus.Inserted ); return Ok(result); } @@ -73,4 +73,4 @@ namespace Yavsc.ApiControllers } } -} \ No newline at end of file +} diff --git a/Yavsc/Migrations/20170217221646_bookQueryStatus.cs b/Yavsc/Migrations/20170217221646_bookQueryStatus.cs index 53aac870..9250ac35 100644 --- a/Yavsc/Migrations/20170217221646_bookQueryStatus.cs +++ b/Yavsc/Migrations/20170217221646_bookQueryStatus.cs @@ -1,8 +1,8 @@ using Microsoft.Data.Entity.Migrations; -using Yavsc.Interfaces.Workflow; namespace Yavsc.Migrations { + using YavscLib; public partial class bookQueryStatus : Migration { protected override void Up(MigrationBuilder migrationBuilder) diff --git a/Yavsc/Models/Billing/NominativeServiceCommand.cs b/Yavsc/Models/Billing/NominativeServiceCommand.cs index 878dc560..e5009076 100644 --- a/Yavsc/Models/Billing/NominativeServiceCommand.cs +++ b/Yavsc/Models/Billing/NominativeServiceCommand.cs @@ -5,7 +5,6 @@ using System.ComponentModel.DataAnnotations.Schema; namespace Yavsc.Models.Billing { - using Interfaces.Workflow; using Newtonsoft.Json; using Workflow; using YavscLib; @@ -67,4 +66,4 @@ namespace Yavsc.Models.Billing [ForeignKey("ActivityCode"),JsonIgnore] public virtual Activity Context  { get; set ; } } -} \ No newline at end of file +} diff --git a/Yavsc/Models/Haircut/HairCutQuery.cs b/Yavsc/Models/Haircut/HairCutQuery.cs index 22bfae5d..df216e00 100644 --- a/Yavsc/Models/Haircut/HairCutQuery.cs +++ b/Yavsc/Models/Haircut/HairCutQuery.cs @@ -4,11 +4,10 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Yavsc.Models.Billing; using Yavsc.Models.Relationship; -using YavscLib.HairCut; namespace Yavsc.Models.Haircut { - public class HairCutQuery : NominativeServiceCommand, IHairCutQuery + public class HairCutQuery : NominativeServiceCommand { [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long Id { get; set; } diff --git a/Yavsc/Models/Haircut/Views/HaircutQueryInfo.cs b/Yavsc/Models/Haircut/Views/HaircutQueryInfo.cs new file mode 100644 index 00000000..bf6d2387 --- /dev/null +++ b/Yavsc/Models/Haircut/Views/HaircutQueryInfo.cs @@ -0,0 +1,47 @@ +using System; +using Yavsc.Models.Auth; +using Yavsc.Models.Relationship; +using YavscLib; + +namespace Yavsc.Models.Haircut.Views +{ + public class HaircutQueryProviderInfo : HaircutQueryComonInfo { + public HaircutQueryProviderInfo(HairCutQuery query) : base (query) + { + ClientInfo = new UserInfo(query.Client); + } + public UserInfo ClientInfo { get; set; } + + } + public class HaircutQueryClientInfo : HaircutQueryComonInfo { + public HaircutQueryClientInfo(HairCutQuery query) : base (query) + { + ProviderInfo = new UserInfo(query.PerformerProfile.Performer); + } + public UserInfo ProviderInfo { get; set; } + + } + public class HaircutQueryComonInfo + { + public HaircutQueryComonInfo(HairCutQuery query) + { + Id = query.Id; + Prestation = query.Prestation; + Status = query.Status; + Location = query.Location; + EventDate = query.EventDate; + } + public long Id { get; set; } + public HairPrestation Prestation { get; set; } + + public QueryStatus Status { get; set; } + + public virtual Location Location { get; set; } + public DateTime? EventDate + { + get; + set; + } + + } +} diff --git a/Yavsc/Models/Workflow/Query.cs b/Yavsc/Models/Workflow/Query.cs index 32c2d74d..8688babf 100644 --- a/Yavsc/Models/Workflow/Query.cs +++ b/Yavsc/Models/Workflow/Query.cs @@ -1,8 +1,7 @@ namespace Yavsc.Models.Workflow { - using Interfaces.Workflow; using YavscLib; - + public interface IQuery: IBaseTrackedEntity { QueryStatus Status { get; set; } diff --git a/YavscLib/HairCut/Haircut.cs b/YavscLib/HairCut/Haircut.cs new file mode 100644 index 00000000..adb97645 --- /dev/null +++ b/YavscLib/HairCut/Haircut.cs @@ -0,0 +1,65 @@ +using System; +namespace YavscLib.Haircut +{ + public interface IProviderInfo + { + + string UserId + { + get; + set; + } + + string UserName + { + get; + set; + } + + string Avatar + { + get; + set; + } + } + + public interface IHaircutQuery + { + + IProviderInfo ProviderInfo + { + get; + set; + } + + long Id + { + get; + set; + } + + IHairPrestation Prestation + { + get; + set; + } + + long Status + { + get; + set; + } + + ILocation Location + { + get; + set; + } + + DateTime EventDate + { + get; + set; + } + } +} diff --git a/YavscLib/HairCut/IHairCutQuery.cs b/YavscLib/HairCut/IHairCutQuery.cs deleted file mode 100644 index 82e46689..00000000 --- a/YavscLib/HairCut/IHairCutQuery.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace YavscLib.HairCut -{ - public interface IHairCutQuery - { - long Id { get; set; } - long PrestationId { get; set; } - - long? LocationId { get; set; } - } -} diff --git a/YavscLib/HairCut/IPrestation.cs b/YavscLib/HairCut/IHairPrestation.cs similarity index 84% rename from YavscLib/HairCut/IPrestation.cs rename to YavscLib/HairCut/IHairPrestation.cs index 253b4c85..08e0ff37 100644 --- a/YavscLib/HairCut/IPrestation.cs +++ b/YavscLib/HairCut/IHairPrestation.cs @@ -1,6 +1,6 @@ -namespace YavscLib.HairCut +namespace YavscLib { - public interface IPrestation + public interface IHairPrestation { long Id { get; set; } int Length { get; set; } diff --git a/Yavsc/Interfaces/Workflow/QueryStatus.cs b/YavscLib/Workflow/QueryStatus.cs similarity index 78% rename from Yavsc/Interfaces/Workflow/QueryStatus.cs rename to YavscLib/Workflow/QueryStatus.cs index 39bbbbe7..413ba127 100644 --- a/Yavsc/Interfaces/Workflow/QueryStatus.cs +++ b/YavscLib/Workflow/QueryStatus.cs @@ -1,9 +1,9 @@ -namespace Yavsc.Interfaces.Workflow +namespace YavscLib { /// /// Status, /// should be associated to any - /// client user query to a provider user or + /// client user query to a provider user or /// other external entity. /// public enum QueryStatus: int @@ -17,4 +17,4 @@ namespace Yavsc.Interfaces.Workflow Failed, Success } -} \ No newline at end of file +}