This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void Seed(NugetForAspMvc.Models.DataContext context) | |
{ | |
if (context.Users.Any() == false) | |
{ | |
var users = Builder<User>.CreateListOfSize(20) | |
.All() | |
.With(u => u.Email = Faker.Internet.Email()) | |
.With(u => u.FirstName = Faker.Name.First()) | |
.With(u => u.LastName = Faker.Name.Last()) | |
.With(u => u.UserName = Faker.Internet.UserName()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public virtual ActionResult Index2() | |
{ | |
using (MiniProfiler.Current.Step("Index2 action")) | |
{ | |
IEnumerable<UserViewModel> viewModels; | |
var models = db.Users.ToList(); | |
using (MiniProfiler.Current.Step("Mapping with automapper")) | |
{ | |
viewModels = Mapper.Map<List<UserViewModel>>(models); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DateService : IDateService | |
{ | |
public DateTime Now | |
{ | |
get | |
{ | |
return DateTime.Now; | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Validator(typeof(CreateUserViewModelValidator))] | |
public class CreateUserViewModel | |
{ | |
public string Email { get; set; } | |
public bool CreateInvoice { get; set; } | |
public string Nip { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="FluentValidationWithWPF.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:local="clr-namespace:FluentValidationWithWPF" | |
mc:Ignorable="d" | |
Title="MainWindow" Height="450" Width="800"> | |
<StackPanel> | |
<TextBox Text="{Binding Email, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, ValidatesOnDataErrors=True}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TextBox | |
Text="{Binding Email, | |
UpdateSourceTrigger=PropertyChanged, | |
Mode=TwoWay, | |
ValidatesOnNotifyDataErrors=True}" | |
Name="Email"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseMailer | |
{ | |
protected void Send(Email email) | |
{ | |
var mailerName = GetType().Name.Replace("Mailer", string.Empty); | |
var viewsPath = Path.GetFullPath(string.Format(HostingEnvironment.MapPath(@"~/Views/Emails/{0}"), mailerName)); | |
var engines = new ViewEngineCollection(); | |
engines.Add(new FileSystemRazorViewEngine(viewsPath)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class User | |
{ | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
public string Email { get; set; } | |
public Gender Gender { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public virtual ActionResult Action(int id) | |
{ | |
return Content(id.ToString()); | |
} | |
public virtual ActionResult RedirectToActionUsingString() | |
{ | |
return RedirectToAction("Action", "Home", new { id = 10 }); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AutofacConfig | |
{ | |
public static IContainer Configure() | |
{ | |
var builder = new ContainerBuilder(); | |
builder.RegisterAssemblyModules(typeof(AutofacConfig).Assembly); | |
var container = builder.Build(); | |
DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); |