refactorinf & max result per page

This commit is contained in:
2018-08-01 10:55:52 +02:00
parent 02645a0a9a
commit 27dfd14989
12 changed files with 224 additions and 103 deletions

View File

@ -18,7 +18,7 @@ namespace Yavsc.Models.Billing
public string GetInvoiceId() { return GetType().Name + "/" + Id; }
public abstract long Id { get; set; }
public abstract string Description { get; }
public abstract string Description { get; set; }
[Required()]
public bool Consent { get; set; }

View File

@ -20,12 +20,19 @@ namespace Yavsc.Models.Haircut
{
// Bill description
public override string Description { get
string _description = null;
public override string Description
{
string type = ResourcesHelpers.GlobalLocalizer[this.GetType().Name];
string gender = ResourcesHelpers.GlobalLocalizer[this.Prestation.Gender.ToString()];
return $"{type} ({gender})";
}
get
{
string type = ResourcesHelpers.GlobalLocalizer[this.GetType().Name];
string gender = ResourcesHelpers.GlobalLocalizer[this.Prestation.Gender.ToString()];
return $"{_description} {type} ({gender})";
}
set
{
_description = value;
}
}
@ -73,34 +80,35 @@ namespace Yavsc.Models.Haircut
List<IBillItem> bill = new List<IBillItem>();
if (this.Prestation==null) throw new InvalidOperationException("Prestation property is null");
if (this.SelectedProfile==null) throw new InvalidOperationException("SelectedProfile property is null");
if (this.Prestation == null) throw new InvalidOperationException("Prestation property is null");
if (this.SelectedProfile == null) throw new InvalidOperationException("SelectedProfile property is null");
// Le shampoing
if (this.Prestation.Shampoo)
bill.Add(new CommandLine { Name = "Shampoing", Description="Shampoing", UnitaryCost = SelectedProfile.ShampooPrice });
bill.Add(new CommandLine { Name = "Shampoing", Description = "Shampoing", UnitaryCost = SelectedProfile.ShampooPrice });
// la coupe
if (Prestation.Cut) {
bill.Add(new CommandLine
if (Prestation.Cut)
{
bill.Add(new CommandLine
{
Name = "Coupe",
Description = $"Coupe "+
ResourcesHelpers.GlobalLocalizer[Prestation.Gender.ToString()]+ " "+
(Prestation.Gender == HairCutGenders.Women ?
Prestation.Length == HairLength.Long ? longhairsuffix :
Prestation.Length == HairLength.HalfLong ? halflonghairsuffix :
shorthairsuffix: null),
Description = $"Coupe " +
ResourcesHelpers.GlobalLocalizer[Prestation.Gender.ToString()] + " " +
(Prestation.Gender == HairCutGenders.Women ?
Prestation.Length == HairLength.Long ? longhairsuffix :
Prestation.Length == HairLength.HalfLong ? halflonghairsuffix :
shorthairsuffix : null),
UnitaryCost =
Prestation.Gender == HairCutGenders.Women ?
Prestation.Length == HairLength.Long ? SelectedProfile.WomenLongCutPrice :
Prestation.Length == HairLength.HalfLong ? SelectedProfile.WomenHalfCutPrice :
SelectedProfile.WomenShortCutPrice : Prestation.Gender == HairCutGenders.Man ?
SelectedProfile.ManCutPrice : SelectedProfile.KidCutPrice
Prestation.Length == HairLength.Long ? SelectedProfile.WomenLongCutPrice :
Prestation.Length == HairLength.HalfLong ? SelectedProfile.WomenHalfCutPrice :
SelectedProfile.WomenShortCutPrice : Prestation.Gender == HairCutGenders.Man ?
SelectedProfile.ManCutPrice : SelectedProfile.KidCutPrice
});
}
// Les techniques
switch (Prestation.Tech)
{
@ -274,100 +282,104 @@ Prestation.Gender == HairCutGenders.Women ?
switch (Prestation.Dressing)
{
case HairDressings.Brushing:
{
string name = "Brushing";
switch (Prestation.Gender)
{
case HairCutGenders.Women:
switch (Prestation.Length)
{
case HairLength.Long:
bill.Add(new CommandLine
string name = "Brushing";
switch (Prestation.Gender)
{
case HairCutGenders.Women:
switch (Prestation.Length)
{
Name = name,
Description = name + longhairsuffix,
UnitaryCost = SelectedProfile.LongBrushingPrice
});
break;
case HairLength.HalfLong:
case HairLength.Long:
bill.Add(new CommandLine
{
Name = name,
Description = name + longhairsuffix,
UnitaryCost = SelectedProfile.LongBrushingPrice
});
break;
case HairLength.HalfLong:
bill.Add(new CommandLine
{
Name = name,
Description = name + halflonghairsuffix,
UnitaryCost = SelectedProfile.HalfBrushingPrice
});
break;
default:
bill.Add(new CommandLine
{
Name = name,
Description = name + shorthairsuffix,
UnitaryCost = SelectedProfile.ShortBrushingPrice
});
break;
}
break;
case HairCutGenders.Man:
bill.Add(new CommandLine
{
Name = name,
Description = name + halflonghairsuffix,
UnitaryCost = SelectedProfile.HalfBrushingPrice
});
break;
default:
bill.Add(new CommandLine
{
Name = name,
Description = name + shorthairsuffix,
UnitaryCost = SelectedProfile.ShortBrushingPrice
});
break;
}
break;
case HairCutGenders.Man:
bill.Add(new CommandLine
{
Name = name,
Description = name + shorthairsuffix,
UnitaryCost = SelectedProfile.ManBrushPrice
});
break;
break;
}
}
break;
case HairDressings.Coiffage:
// est offert
/* bill.Add(new CommandLine
{
Name = "Coiffage (offert)",
UnitaryCost = 0m
}); */
/* bill.Add(new CommandLine
{
Name = "Coiffage (offert)",
UnitaryCost = 0m
}); */
break;
case HairDressings.Folding:
{
string name = "Mise en plis";
switch (Prestation.Length)
{
case HairLength.Long:
string name = "Mise en plis";
switch (Prestation.Length)
{
case HairLength.Long:
bill.Add(new CommandLine
{
Name = name,
Description = name + longhairsuffix,
UnitaryCost = SelectedProfile.LongFoldingPrice
});
break;
case HairLength.HalfLong:
break;
case HairLength.HalfLong:
bill.Add(new CommandLine
{
Name = name,
Description = name + halflonghairsuffix,
UnitaryCost = SelectedProfile.HalfFoldingPrice
});
break;
default:
break;
default:
bill.Add(new CommandLine
{
Name = name,
Description = name + shorthairsuffix,
UnitaryCost = SelectedProfile.ShortFoldingPrice
});
break;
break;
}
}
break;
}
}
// les soins
if (Prestation.Cares) {
bill.Add(new CommandLine { Name = "Soins",
Description = "Soins",
UnitaryCost = SelectedProfile.CarePrice });
if (Prestation.Cares)
{
bill.Add(new CommandLine
{
Name = "Soins",
Description = "Soins",
UnitaryCost = SelectedProfile.CarePrice
});
}
return bill;
@ -375,28 +387,31 @@ Prestation.Gender == HairCutGenders.Women ?
public HairCutPayementEvent CreatePaymentEvent(PaymentInfo info, IStringLocalizer localizer)
{
return new HairCutPayementEvent(Client.UserName,info,this, localizer);
return new HairCutPayementEvent(Client.UserName, info, this, localizer);
}
public virtual BrusherProfile SelectedProfile { get; set; }
public HairCutQueryEvent CreateEvent(string subTopic, string reason, string sender) {
public HairCutQueryEvent CreateEvent(string subTopic, string reason, string sender)
{
string evdate = EventDate?.ToString("dddd dd/MM/yyyy à HH:mm")??"[pas de date spécifiée]";
string address = Location?.Address??"[pas de lieu spécifié]";
string evdate = EventDate?.ToString("dddd dd/MM/yyyy à HH:mm") ?? "[pas de date spécifiée]";
string address = Location?.Address ?? "[pas de lieu spécifié]";
var p = Prestation;
string total = GetBillItems().Addition().ToString("C",CultureInfo.CurrentUICulture);
string total = GetBillItems().Addition().ToString("C", CultureInfo.CurrentUICulture);
string strprestation = Description;
string bill = string.Join("\n", GetBillItems().Select(
l=> $"{l.Name} {l.Description} {l.UnitaryCost} € " +
((l.Count != 1) ? "*"+l.Count.ToString() : "")));
l => $"{l.Name} {l.Description} {l.UnitaryCost} € " +
((l.Count != 1) ? "*" + l.Count.ToString() : "")));
var yaev = new HairCutQueryEvent(subTopic)
{
Client = new ClientProviderInfo { 
UserName = Client.UserName ,
UserId =ClientId,
Avatar = Client.Avatar } ,
Client = new ClientProviderInfo
{
UserName = Client.UserName,
UserId = ClientId,
Avatar = Client.Avatar
},
Previsional = Previsional,
EventDate = EventDate,
Location = Location,

View File

@ -25,7 +25,16 @@ namespace Yavsc.Models.Haircut
public class HairMultiCutQuery : NominativeServiceCommand
{
// Bill description
public override string Description => "Prestation en coiffure à domicile [commande groupée]" ;
string _customDescription = null;
public override string Description
{
get {
return _customDescription ?? "Prestation en coiffure à domicile [commande groupée]" ;
}
set {
_customDescription = value;
}
}
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
override public long Id { get; set; }

View File

@ -51,7 +51,11 @@ namespace Yavsc.Server.Models.IT
}
string description;
public override string Description => description;
public override string Description
{
get { return description; }
set { description = value; }
}
public Project()
{

View File

@ -42,7 +42,19 @@ namespace Yavsc.Models.Workflow
[Display(Name="GiveAnExplicitReason")]
public string Reason { get; set; }
public override string Description => "Rendez-vous";
string _description = "Rendez-vous";
public override string Description
{
get
{
string type = ResourcesHelpers.GlobalLocalizer[this.GetType().Name];
return $"{_description} {type}";
}
set
{
_description = value;
}
}
public RdvQuery()
{

View File

@ -3,11 +3,12 @@ using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account
{
using Yavsc;
public class RegisterViewModel
{
[StringLength(102)]
[YaRegularExpression(Constants.UserNameRegExp, ErrorMessageResourceName="InvalidUserName", ErrorMessageResourceType = typeof(RegisterViewModel))]
[YaRegularExpression(Constants.UserNameRegExp)]
public string UserName { get; set; }
[YaRequired()]
@ -23,9 +24,10 @@ namespace Yavsc.ViewModels.Account
public string Password { get; set; }
[DataType(DataType.Password)]
[Compare("Password", ErrorMessageResourceName = "PassAndConfirmDontMach", ErrorMessageResourceType = typeof(RegisterViewModel) )]
[Compare("Password")]
public string ConfirmPassword { get; set; }
public string GoogleRegId { get; set; }
}
}