Esempio n. 1
0
        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"));
        }
Esempio n. 3
0
 public IHttpActionResult Save(Contact contact)
 {
     _contactService.Add(contact);
     return(Ok());
 }