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
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
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
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
static void Main(string[] args) | |
{ | |
var user = new User() | |
{ | |
CreateInvoice = true, | |
Nip = "123", | |
Email = "[email protected]", | |
Orders = new List<Order>() | |
{ | |
new Order(){Product = "Laptop"}, |
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 static class IRuleBuilderExtensions | |
{ | |
public static IRuleBuilderOptions<T, TProperty> Nip<T, TProperty>(this IRuleBuilder<T, TProperty> ruleBuilder) | |
{ | |
return ruleBuilder.SetValidator(new NipValidator()); | |
} | |
} |
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
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/elmah" /> | |
<errorMail from="[email protected]" to="[email protected]" subject="Application Exception" async="false" smtpPort="25" smtpServer="***" userName="***" password="***" /> |
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 ViewEngineCollectionWithoutResolver(); | |
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 BaseIntegrationTests | |
{ | |
protected Lazy<IEmailServiceFactory> CreateEmailServiceFactory() | |
{ | |
return new Lazy<IEmailServiceFactory>(() => | |
new EmailServiceFactory(new Lazy<IHostingEnviromentService>(() => new TestHostingEnviromentService()))); | |
} | |
} |
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
using (DataContext db = new DataContext()) | |
{ | |
db.Database.Log = m => _logger.Info(m); | |
var product = db.Products.FirstOrDefault(p => p.Id == productId); | |
if (product == null) | |
{ | |
return; | |
} |