Skip to content

Commit

Permalink
Web MVC site UI apperance
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Cañizares Estévez committed Oct 21, 2016
1 parent 2ba685c commit c424f08
Show file tree
Hide file tree
Showing 65 changed files with 5,497 additions and 290 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,5 @@ paket-files/
.idea/
*.sln.iml
pub/
/src/Web/WebMVC/Properties/PublishProfiles/eShopOnContainersWebMVC2016 - Web Deploy-publish.ps1
/src/Web/WebMVC/Properties/PublishProfiles/publish-module.psm1
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
- CatalogUrl=http://catalog.api
- OrderingUrl=http://ordering.api
ports:
- "80:80"
- "800:80"
depends_on:
- catalog.api

Expand All @@ -31,10 +31,10 @@ services:
- "81:80"
# (Go to Production): For secured/final deployment, remove Ports mapping and
# leave just the internal expose section
# expose:
# - "80"
expose:
- "800"
extra_hosts:
- "CESARDLBOOKVHD:10.0.75.1"
- "DESKTOP-1HNACCH:192.168.1.39"
depends_on:
- ordering.data

Expand Down
19 changes: 18 additions & 1 deletion src/Web/WebMVC/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,24 @@ public async Task<IActionResult> Register(RegisterViewModel model, string return
ViewData["ReturnUrl"] = returnUrl;
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
var user = new ApplicationUser
{
UserName = model.Email,
Email = model.Email,
CardHolderName = model.User.CardHolderName,
CardNumber = model.User.CardNumber,
CardType = model.User.CardType,
City = model.User.City,
Country = model.User.Country,
Expiration = model.User.Expiration,
LastName = model.User.LastName,
Name = model.User.Name,
Street = model.User.Street,
State = model.User.State,
ZipCode = model.User.ZipCode,
PhoneNumber = model.User.PhoneNumber,
SecurityNumber = model.User.SecurityNumber
};
var result = await _userManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
Expand Down
32 changes: 14 additions & 18 deletions src/Web/WebMVC/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,34 @@
using Microsoft.eShopOnContainers.WebMVC.Models;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Microsoft.eShopOnContainers.WebMVC.Services;
using Microsoft.eShopOnContainers.WebMVC.Models.HomeViewModels;

namespace Microsoft.eShopOnContainers.WebMVC.Controllers
{
public class HomeController : Controller
{
private HttpClient _http;
private AppSettings _settings;
private ICatalogService _catalogSvc;

public HomeController(IOptions<AppSettings> options)
public HomeController(IOptions<AppSettings> options, ICatalogService catalogSvc)
{
_http = new HttpClient();
_settings = options.Value;
_catalogSvc = catalogSvc;
}
public async Task<IActionResult> Index()
{
var dataString = await _http.GetStringAsync(_settings.CatalogUrl);
var items = JsonConvert.DeserializeObject<List<CatalogItem>>(dataString);
return View(items);
}

public IActionResult About()
{
ViewData["Message"] = "Your application description page.";

return View();
}

public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";

return View();
//var dataString = await _http.GetStringAsync(_settings.CatalogUrl);
//var items = JsonConvert.DeserializeObject<List<CatalogItem>>(dataString);
//items.AddRange(items);
var items = await _catalogSvc.GetCatalogItems();
var vm = new IndexViewModel()
{
CatalogItems = items
};
return View(vm);
}

public async Task<IActionResult> Orders()
Expand Down
39 changes: 37 additions & 2 deletions src/Web/WebMVC/Controllers/ManageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,45 @@ public async Task<IActionResult> Index(ManageMessageId? message = null)
PhoneNumber = await _userManager.GetPhoneNumberAsync(user),
TwoFactor = await _userManager.GetTwoFactorEnabledAsync(user),
Logins = await _userManager.GetLoginsAsync(user),
BrowserRemembered = await _signInManager.IsTwoFactorClientRememberedAsync(user)
BrowserRemembered = await _signInManager.IsTwoFactorClientRememberedAsync(user),
User = user
};
return View(model);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Index(IndexViewModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}

var user = await _userManager.GetUserAsync(HttpContext.User);

user.CardHolderName = model.User.CardHolderName;
user.CardNumber = model.User.CardNumber;
//user.CardType = model.User.CardType;
user.City = model.User.City;
user.Country = model.User.Country;
user.Expiration = model.User.Expiration;
user.State = model.User.State;
user.Street = model.User.Street;
user.ZipCode = model.User.ZipCode;

var result = await _userManager.UpdateAsync(user);

if (result.Succeeded)
{
_logger.LogInformation(99, "User changed his address and payment method information.");
return RedirectToAction(nameof(Index), new { Message = ManageMessageId.ProfileUpdated });
}

AddErrors(result);
return View(model);
}

//
// POST: /Manage/RemoveLogin
[HttpPost]
Expand Down Expand Up @@ -347,7 +381,8 @@ public enum ManageMessageId
SetPasswordSuccess,
RemoveLoginSuccess,
RemovePhoneSuccess,
Error
Error,
ProfileUpdated
}

private Task<ApplicationUser> GetCurrentUserAsync()
Expand Down
35 changes: 35 additions & 0 deletions src/Web/WebMVC/Controllers/OrderController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.eShopOnContainers.WebMVC.Services;
using Microsoft.eShopOnContainers.WebMVC.Models;

namespace Microsoft.eShopOnContainers.WebMVC.Controllers
{
public class OrderController : Controller
{
private IOrderingService _orderSvc;
public OrderController(IOrderingService orderSvc)
{
_orderSvc = orderSvc;
}

public IActionResult Cart()
{
return View();
}

public IActionResult Create()
{
return View();
}

public IActionResult Index(Order item)
{
_orderSvc.AddOrder(item);
return View(_orderSvc.GetOrders());
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Microsoft.eShopOnContainers.WebMVC.Data.Migrations
namespace WebMVC.Migrations
{
public partial class CreateIdentitySchema : Migration
public partial class Init_Scheme : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down Expand Up @@ -45,19 +43,33 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
Id = table.Column<string>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false),
CardHolderName = table.Column<string>(nullable: true),
CardNumber = table.Column<string>(nullable: true),
CardType = table.Column<int>(nullable: false),
City = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
Country = table.Column<string>(nullable: true),
CountryCode = table.Column<string>(nullable: true),
Email = table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false),
Expiration = table.Column<string>(nullable: true),
Latitude = table.Column<double>(nullable: false),
LockoutEnabled = table.Column<bool>(nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
Longitude = table.Column<double>(nullable: false),
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
PasswordHash = table.Column<string>(nullable: true),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
SecurityNumber = table.Column<string>(nullable: true),
SecurityStamp = table.Column<string>(nullable: true),
State = table.Column<string>(nullable: true),
StateCode = table.Column<string>(nullable: true),
Street = table.Column<string>(nullable: true),
TwoFactorEnabled = table.Column<bool>(nullable: false),
UserName = table.Column<string>(maxLength: 256, nullable: true)
UserName = table.Column<string>(maxLength: 256, nullable: true),
ZipCode = table.Column<string>(nullable: true)
},
constraints: table =>
{
Expand Down
Loading

0 comments on commit c424f08

Please sign in to comment.