refactorinf & max result per page

vnext
Paul Schneider 6 years ago
parent 02645a0a9a
commit 27dfd14989
12 changed files with 223 additions and 102 deletions

@ -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; }

@ -20,11 +20,18 @@ namespace Yavsc.Models.Haircut
{
// Bill description
public override string Description { get
string _description = null;
public override string Description
{
get
{
string type = ResourcesHelpers.GlobalLocalizer[this.GetType().Name];
string gender = ResourcesHelpers.GlobalLocalizer[this.Prestation.Gender.ToString()];
return $"{type} ({gender})";
return $"{_description} {type} ({gender})";
}
set
{
_description = value;
}
}
@ -73,24 +80,25 @@ 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) {
if (Prestation.Cut)
{
bill.Add(new CommandLine
{
Name = "Coupe",
Description = $"Coupe "+
ResourcesHelpers.GlobalLocalizer[Prestation.Gender.ToString()]+ " "+
Description = $"Coupe " +
ResourcesHelpers.GlobalLocalizer[Prestation.Gender.ToString()] + " " +
(Prestation.Gender == HairCutGenders.Women ?
Prestation.Length == HairLength.Long ? longhairsuffix :
Prestation.Length == HairLength.HalfLong ? halflonghairsuffix :
shorthairsuffix: null),
shorthairsuffix : null),
UnitaryCost =
Prestation.Gender == HairCutGenders.Women ?
Prestation.Length == HairLength.Long ? SelectedProfile.WomenLongCutPrice :
@ -364,10 +372,14 @@ Prestation.Gender == HairCutGenders.Women ?
}
// les soins
if (Prestation.Cares) {
bill.Add(new CommandLine { Name = "Soins",
if (Prestation.Cares)
{
bill.Add(new CommandLine
{
Name = "Soins",
Description = "Soins",
UnitaryCost = SelectedProfile.CarePrice });
UnitaryCost = SelectedProfile.CarePrice
});
}
return bill;
@ -376,27 +388,30 @@ 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,

@ -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; }

@ -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()
{

@ -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()
{

@ -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; }
}
}

@ -20,6 +20,7 @@ using Newtonsoft.Json;
namespace Yavsc.Controllers
{
using System.Text;
using Yavsc.Abstract.Manage;
using Yavsc.Helpers;
@ -60,10 +61,28 @@ namespace Yavsc.Controllers
_dbContext = dbContext;
}
const string nextPageTokenKey = "nextPageTokenKey";
const int defaultLen = 10;
[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]

@ -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="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="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="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>

@ -15,28 +15,28 @@
<hr />
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<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">
<input asp-for="UserName" class="form-control" placeholder="Votre nom"/>
<span asp-validation-for="UserName" class="text-danger"></span>
</div>
</div>
<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">
<input asp-for="Email" class="form-control" placeholder="votre@@email" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
</div>
<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">
<input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span>
</div>
</div>
<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">
<input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>

@ -4,5 +4,61 @@
}
<h2>@ViewData["Title"].</h2>
<table>
<thead>
<th>
@SR["Public info"]
</th>
<th>
@SR["AdminOnly"]
</th>
@Html.DisplayFor(m=>m)
</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>
@if (ViewBag.hasNext)
{
<a asp-route-page="@ViewBag.nextpage" asp-route-len="@ViewBag.pageLen">Next page</a>
}

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

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

Loading…