Skip to content

Instantly share code, notes, and snippets.

[AutoMap(typeof(EventListViewModel))]
public ActionResult Index(int? page)
{
page = page ?? 1;
var entities = //load data from database
.AsPagination(page.Value, 20); //pagination method from MVC Contrib
return View(entities);
}
public ActionResult View(User entity) {
UserEditModel model = //change entity into a edit model
return View(model);
}
public ActionResult Login(string username, string password) {
if(username != “user” || password != “123”) {
ModelState.AddError(“username or password incorrect”);
return View();
}
return new LoginResult(username); //I typically pass the actual user into the login result
}
[TestMethod]
public void Login_Success() {
AuthenticationController controller = new AuthenticationController();
ActionResult result = controller.Login(“user”, “123”);
Assert.IsTrue(result.GetType() == typeof(LoginResult));
Assert.AreEqual(“user”, ((LoginResult)result).Username);
}
public ActionResult Graph() {
var data = null; //todo load some data
return new PdfResult(data);
}
return View(ViewModel).WithSuccessMessage(“user created succesfully”);
return RedirectToAction(“Index”).WithSuccessMessage(“user created succesfully”);
return new StatusResult(View(ViewModel), “user created succesfully”);
public class ValidatorProvider : DataAnnotationsModelValidatorProvider
{
private IConfigurationProvider _mapper;
public ValidatorProvider(IConfigurationProvider mapper)
{
_mapper = mapper;
}
protected override System.Collections.Generic.IEnumerable<ModelValidator> GetValidators(System.Web.Mvc.ModelMetadata metadata, ControllerContext context, IEnumerable<Attribute> attributes)
public class MetadataProvider : DataAnnotationsModelMetadataProvider
{
private IConfigurationProvider _mapper;
public MetadataProvider(IConfigurationProvider mapper)
{
_mapper = mapper;
}
protected override System.Web.Mvc.ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName)
Detailed Message: There was an error during job agent execution. The operation will be retried. Similar errors in the next five minutes may not be logged.
Exception Message: An item with the same key has already been added. (type ArgumentException)
Exception Stack Trace: at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.TeamFoundation.Framework.Server.TeamFoundationExtensionUtility.LoadExtensionTypeMap[T](String pluginDirectory)
at Microsoft.TeamFoundation.Framework.Server.JobApplication.SetupInternal()
at Microsoft.TeamFoundation.Framework.Server.JobServiceUtil.RetryOperationsUntilSuccessful(RetryOperations operations, Int32 maxTries, Int32& delayOnExceptionSeconds)