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 string GetInvoiceId() { return GetType().Name + "/" + Id; }
public abstract long Id { get; set; } public abstract long Id { get; set; }
public abstract string Description { get; } public abstract string Description { get; set; }
[Required()] [Required()]
public bool Consent { get; set; } public bool Consent { get; set; }

View File

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

View File

@ -25,7 +25,16 @@ namespace Yavsc.Models.Haircut
public class HairMultiCutQuery : NominativeServiceCommand public class HairMultiCutQuery : NominativeServiceCommand
{ {
// Bill description // 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)] [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
override public long Id { get; set; } override public long Id { get; set; }

View File

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

View File

@ -42,7 +42,19 @@ namespace Yavsc.Models.Workflow
[Display(Name="GiveAnExplicitReason")] [Display(Name="GiveAnExplicitReason")]
public string Reason { get; set; } 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() public RdvQuery()
{ {

View File

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

View File

@ -20,6 +20,7 @@ using Newtonsoft.Json;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
using System.Text;
using Yavsc.Abstract.Manage; using Yavsc.Abstract.Manage;
using Yavsc.Helpers; using Yavsc.Helpers;
@ -60,10 +61,28 @@ namespace Yavsc.Controllers
_dbContext = dbContext; _dbContext = dbContext;
} }
const string nextPageTokenKey = "nextPageTokenKey";
const int defaultLen = 10;
[Authorize(Roles = Constants.AdminGroupName)] [Authorize(Roles = Constants.AdminGroupName)]
public async Task<IActionResult> UserList() [Route("Account/UserList/{page?}/{len?}")]
public async Task<IActionResult> UserList(string page, string len)
{ {
return View(await _dbContext.Users.ToArrayAsync()); int pageNum = page!=null ? int.Parse(page) : 0;
int pageLen = len!=null ? int.Parse(len) : defaultLen;
var users = _dbContext.Users.OrderBy(u=>u.UserName);
var shown = pageNum * pageLen;
var toShow = users.Skip(shown).Take(pageLen);
ViewBag.page = pageNum;
ViewBag.hasNext = await users.CountAsync() > (toShow.Count() + shown);
ViewBag.nextpage = pageNum+1;
ViewBag.pageLen = pageLen;
return View(toShow.ToArray());
}
string GeneratePageToken() {
return System.Guid.NewGuid().ToString();
} }
[AllowAnonymous] [AllowAnonymous]

View File

@ -453,6 +453,7 @@
<data name="PasswordRequiresUpper"><value>Les mots de passe doivent contenir au moins une lettre majuscule ('A' à 'Z').</value></data> <data name="PasswordRequiresUpper"><value>Les mots de passe doivent contenir au moins une lettre majuscule ('A' à 'Z').</value></data>
<data name="PassAndConfirmDontMach"><value>Le mot de passe et sa confirmation ne sont pas les mêmes.</value></data> <data name="PassAndConfirmDontMach"><value>Le mot de passe et sa confirmation ne sont pas les mêmes.</value></data>
<data name="PasswordConfirm"><value>Confirmation du mot de passe</value></data> <data name="PasswordConfirm"><value>Confirmation du mot de passe</value></data>
<data name="ConfirmPassword"><value>Confirmation du mot de passe</value></data>
<data name="ErrorSendingEmailForConfirm"><value>L'envoi de de courrier pour confirmation de l'adresse e-mail a échoué.</value></data> <data name="ErrorSendingEmailForConfirm"><value>L'envoi de de courrier pour confirmation de l'adresse e-mail a échoué.</value></data>
<data name="EmailSentForConfirm"><value>Un courrier a été envoyé pour confirmation de l'adresse e-mail .</value></data> <data name="EmailSentForConfirm"><value>Un courrier a été envoyé pour confirmation de l'adresse e-mail .</value></data>
<data name="ConfirmYourAccountTitle"><value>S'il vous plait, confirmez votre addresse e-mail</value></data> <data name="ConfirmYourAccountTitle"><value>S'il vous plait, confirmez votre addresse e-mail</value></data>

View File

@ -15,28 +15,28 @@
<hr /> <hr />
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div> <div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group"> <div class="form-group">
<label asp-for="UserName" class="col-md-2 control-label"></label> <label asp-for="UserName" class="col-md-2 control-label">@SR["UserName"]</label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="UserName" class="form-control" placeholder="Votre nom"/> <input asp-for="UserName" class="form-control" placeholder="Votre nom"/>
<span asp-validation-for="UserName" class="text-danger"></span> <span asp-validation-for="UserName" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="Email" class="col-md-2 control-label"></label> <label asp-for="Email" class="col-md-2 control-label">@SR["Email"]</label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="Email" class="form-control" placeholder="votre@@email" /> <input asp-for="Email" class="form-control" placeholder="votre@@email" />
<span asp-validation-for="Email" class="text-danger"></span> <span asp-validation-for="Email" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="Password" class="col-md-2 control-label"></label> <label asp-for="Password" class="col-md-2 control-label">@SR["Password"]</label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="Password" class="form-control" /> <input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span> <span asp-validation-for="Password" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="ConfirmPassword" class="col-md-2 control-label"></label> <label asp-for="ConfirmPassword" class="col-md-2 control-label">@SR["ConfirmPassword"]</label>
<div class="col-md-10"> <div class="col-md-10">
<input asp-for="ConfirmPassword" class="form-control" /> <input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span> <span asp-validation-for="ConfirmPassword" class="text-danger"></span>

View File

@ -4,5 +4,61 @@
} }
<h2>@ViewData["Title"].</h2> <h2>@ViewData["Title"].</h2>
<table>
<thead>
<th>
@SR["Public info"]
</th>
<th>
@SR["AdminOnly"]
</th>
</thead>
@foreach (var user in Model)
{
<tr>
<td>
@Html.DisplayFor(m=>user)
</td>
<td>
<dl>
<dt>
UserName
</dt>
<dd>
@Html.DisplayFor(m=>user.UserName)
</dd>
</dl>
<dl>
<dt>
FullName
</dt>
<dd>
@Html.DisplayFor(m=>user.FullName)
</dd>
</dl>
<dl>
<dt>
@SR["PostalAddress"]
</dt>
<dd>
@Html.DisplayFor(m=>user.PostalAddress)
</dd>
</dl>
<dl>
<dt>
Email
</dt>
<dd>
@Html.DisplayFor(m=>user.Email)
</dd>
</dl>
</td>
</tr>
}
</table>
@Html.DisplayFor(m=>m) @if (ViewBag.hasNext)
{
<a asp-route-page="@ViewBag.nextpage" asp-route-len="@ViewBag.pageLen">Next page</a>
}

View File

@ -0,0 +1,3 @@
namespace Yavsc.contrib
{
omg, daB4C0|)3DA!!!

View File

@ -19,11 +19,11 @@ $(BINTARGET): project.lock.json ../Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll .
dnu build --configuration $(CONFIGURATION) dnu build --configuration $(CONFIGURATION)
breaking: breaking:
dnx test -trait noregres=no dnx test -trait regres=yes
test: $(BINTARGET) test: $(BINTARGET)
ASPNET_ENV=Development dnx test -maxthreads 1 -trait noregres=yes ASPNET_ENV=Development dnx test -maxthreads 1 -trait regres=no
.PHONY: test .PHONY: test