public IActionResult Create(UserInfoModel user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ViewBag.CurrentUser = user; ContactService.Add(user); return(View("Index")); }
public async Task <IActionResult> CreateContact(ContactViewModel contact) { if (!ModelState.IsValid) { return(View("Create", contact)); } var response = await contactsService.Add(contact); if (!response.Successful) { ModelState.AddModelError(string.Empty, response.ErrorMessage); return(View("Create", contact)); } return(Redirect("Index")); }
public IHttpActionResult Save(Contact contact) { _contactService.Add(contact); return(Ok()); }