* AccountController.cs: Fixes the Profile edition view, regarding
the avatar * Product.aspx: a CommandForm property for a Product will never be served null to a view, le page code is simpler.
This commit is contained in:
parent
bf8dbeee04
commit
85346d0e00
2 changed files with 31 additions and 45 deletions
|
|
@ -229,11 +229,7 @@ namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
string username = Membership.GetUser ().UserName;
|
string username = Membership.GetUser ().UserName;
|
||||||
ViewData ["UserName"] = username;
|
ViewData ["UserName"] = username;
|
||||||
if (AvatarFile == null) {
|
if (AvatarFile != null) {
|
||||||
// do not update <c>avatar</c> to null since
|
|
||||||
// it's not in the model.
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// if said valid, move as avatar file
|
// if said valid, move as avatar file
|
||||||
// else invalidate the model
|
// else invalidate the model
|
||||||
if (AvatarFile.ContentType == "image/png") {
|
if (AvatarFile.ContentType == "image/png") {
|
||||||
|
|
@ -243,49 +239,38 @@ namespace Yavsc.Controllers
|
||||||
model.avatar =
|
model.avatar =
|
||||||
Path.Combine(AvatarDir.Substring(1),username)+".png";
|
Path.Combine(AvatarDir.Substring(1),username)+".png";
|
||||||
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
ModelState.AddModelError ("Avatar",
|
ModelState.AddModelError ("Avatar",
|
||||||
string.Format ("Image type {0} is not supported (suported formats : {1})",
|
string.Format ("Image type {0} is not supported (suported formats : {1})",
|
||||||
AvatarFile.ContentType, "image/png")
|
AvatarFile.ContentType, "image/png"));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
/* Sync the property in the Profile model to display :
|
||||||
|
* string cAvat = HttpContext.Profile.GetPropertyValue ("avatar") as string;
|
||||||
|
if (cAvat != null) if (model.avatar == null) model.avatar = cAvat;
|
||||||
|
*/
|
||||||
if (ModelState.IsValid) {
|
if (ModelState.IsValid) {
|
||||||
HttpContext.Profile.SetPropertyValue (
|
if (model.avatar != null)
|
||||||
"Address", model.Address);
|
HttpContext.Profile.SetPropertyValue ("avatar", model.avatar);
|
||||||
HttpContext.Profile.SetPropertyValue (
|
HttpContext.Profile.SetPropertyValue ("Address", model.Address);
|
||||||
"BlogTitle", model.BlogTitle);
|
HttpContext.Profile.SetPropertyValue ("BlogTitle", model.BlogTitle);
|
||||||
HttpContext.Profile.SetPropertyValue (
|
HttpContext.Profile.SetPropertyValue ("BlogVisible", model.BlogVisible);
|
||||||
"BlogVisible", model.BlogVisible);
|
HttpContext.Profile.SetPropertyValue ("CityAndState", model.CityAndState);
|
||||||
HttpContext.Profile.SetPropertyValue (
|
HttpContext.Profile.SetPropertyValue ("ZipCode", model.ZipCode);
|
||||||
"CityAndState", model.CityAndState);
|
HttpContext.Profile.SetPropertyValue ("Country", model.Country);
|
||||||
HttpContext.Profile.SetPropertyValue (
|
HttpContext.Profile.SetPropertyValue ("WebSite", model.WebSite);
|
||||||
"ZipCode", model.ZipCode);
|
HttpContext.Profile.SetPropertyValue ("Name", model.Name);
|
||||||
HttpContext.Profile.SetPropertyValue (
|
HttpContext.Profile.SetPropertyValue ("Phone", model.Phone);
|
||||||
"Country", model.Country);
|
HttpContext.Profile.SetPropertyValue ("Mobile", model.Mobile);
|
||||||
HttpContext.Profile.SetPropertyValue (
|
HttpContext.Profile.SetPropertyValue ("BankCode", model.BankCode);
|
||||||
"WebSite", model.WebSite);
|
HttpContext.Profile.SetPropertyValue ("WicketCode", model.WicketCode);
|
||||||
HttpContext.Profile.SetPropertyValue (
|
HttpContext.Profile.SetPropertyValue ("AccountNumber", model.AccountNumber);
|
||||||
"Name", model.Name);
|
HttpContext.Profile.SetPropertyValue ("BankedKey", model.BankedKey);
|
||||||
HttpContext.Profile.SetPropertyValue (
|
HttpContext.Profile.SetPropertyValue ("BIC", model.BIC);
|
||||||
"Phone", model.Phone);
|
HttpContext.Profile.SetPropertyValue ("IBAN", model.IBAN);
|
||||||
HttpContext.Profile.SetPropertyValue (
|
|
||||||
"Mobile", model.Mobile);
|
|
||||||
HttpContext.Profile.SetPropertyValue (
|
|
||||||
"BankCode", model.BankCode);
|
|
||||||
HttpContext.Profile.SetPropertyValue (
|
|
||||||
"WicketCode", model.WicketCode);
|
|
||||||
HttpContext.Profile.SetPropertyValue (
|
|
||||||
"AccountNumber", model.AccountNumber);
|
|
||||||
HttpContext.Profile.SetPropertyValue (
|
|
||||||
"BankedKey", model.BankedKey);
|
|
||||||
HttpContext.Profile.SetPropertyValue (
|
|
||||||
"BIC", model.BIC);
|
|
||||||
HttpContext.Profile.SetPropertyValue (
|
|
||||||
"IBAN", model.IBAN);
|
|
||||||
HttpContext.Profile.Save ();
|
HttpContext.Profile.Save ();
|
||||||
FormsAuthentication.SetAuthCookie (username, model.RememberMe);
|
FormsAuthentication.SetAuthCookie (username, model.RememberMe);
|
||||||
ViewData ["Message"] = "Profile enregistré, cookie modifié.";
|
ViewData ["Message"] = "Profile enregistré, cookie modifié.";
|
||||||
|
|
||||||
}
|
}
|
||||||
return View (model);
|
return View (model);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ Prix unitaire : <%= Html.Encode(Model.UnitaryPrice.Quantity.ToString())%>
|
||||||
<% } else { %> Gratuit! <% } %>
|
<% } else { %> Gratuit! <% } %>
|
||||||
</div>
|
</div>
|
||||||
<div class="booking">
|
<div class="booking">
|
||||||
<% if (Model.CommandForm!=null) { %>
|
<!---
|
||||||
Défaut de formulaire de commande!!!
|
- TODO: better
|
||||||
<% } else { Response.Write( Html.CommandForm(Model,"Ajouter au panier")); } %>
|
- ASSERT (Model.CommandForm!=null) --->
|
||||||
|
<%= Html.CommandForm(Model,"Ajouter au panier") %>
|
||||||
|
|
||||||
<% if (Model.CommandValidityDates!=null) { %>
|
<% if (Model.CommandValidityDates!=null) { %>
|
||||||
Offre valable du <%= Model.CommandValidityDates.StartDate.ToString("dd/MM/yyyy") %> au
|
Offre valable du <%= Model.CommandValidityDates.StartDate.ToString("dd/MM/yyyy") %> au
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue