Пример #1
0
        public async Task <IActionResult> AddNewContact([FromBody] Contacts contact)
        {
            try
            {
                var result = await _contactService.AddNewContact(contact);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                _logger.LogError("Error occured while adding new Contact.", ex);
                return(BadRequest());
            }
        }
Пример #2
0
        public IActionResult Post([FromBody] ContactDTO contact)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { Message = "Parameter can not be null" }));
            }
            var result = _contactService.AddNewContact(contact);

            if (result)
            {
                return(Json(new { Success = true, Message = "New Contact added succesfullly" }));
            }
            else
            {
                return(Json(new { Success = false, Message = "Error while adding new language" }));
            }
        }
Пример #3
0
        public ActionResult AddContact(ContactModel model)
        {
            var contact = new ContactDTO();

            contact.Name = model.Name;
            contact.ContactFields.Add(new ContactFieldDTO
            {
                Field = "Phone",
                Value = model.Phone
            });
            contact.ContactFields.Add(new ContactFieldDTO
            {
                Field = "Email",
                Value = model.Email
            });
            contactService.AddNewContact(contact);
            return(RedirectToAction("Index"));
        }
        public ActionResult AddUser(ContactViewModel model)
        {
            var result = _service.AddNewContact(model);

            return(View(model));
        }
 public IActionResult Add([FromBody] Contact contact)
 {
     _service.AddNewContact(contact);
     return(Ok());
 }