public ActionResult Index(Authorizates authorization) { if (ModelState.IsValid) { context.Authorizates.Add(authorization); context.SaveChanges(); Redirect("Home"); } return(View()); }
public override IEnumerable <ModelValidationResult> Validate(object container) { Authorizates b = (Authorizates)Metadata.Model; List <ModelValidationResult> errors = new List <ModelValidationResult>(); if (b.Name == "1" && b.Surname == "2" && b.Password.Length == 6) { errors.Add(new ModelValidationResult { MemberName = "", Message = "Unavailable book" }); } return(errors); }
public override IEnumerable <ModelValidationResult> Validate(object container) { Authorizates b = container as Authorizates; if (b != null) { switch (Metadata.PropertyName) { case "Name": if (string.IsNullOrEmpty(b.Name)) { return(new ModelValidationResult[] { new ModelValidationResult { MemberName = "", Message = "Enter book name" } }); } break; case "Surname": if (string.IsNullOrEmpty(b.Surname)) { return(new ModelValidationResult[] { new ModelValidationResult { MemberName = "", Message = "Enter book author" } }); } break; case "Password": if (string.IsNullOrEmpty(b.Password)) { return(new ModelValidationResult[] { new ModelValidationResult { MemberName = "", Message = "Enter Pass" } }); } break; } } return(Enumerable.Empty <ModelValidationResult>()); }
// GET: Authorization public ActionResult Index() { Authorizates authorization = new Authorizates(); return(View(authorization)); }