public async Task <IActionResult> Post([FromBody] AddContactResource contactResource)
        {
            var contact = _mapper.Map <AddContactResource, Contact>(contactResource);
            int userId  = GetUserId();
            await _repository.AddContactAsync(contact, userId);

            await _unitOfWork.SaveChangesAsync();

            return(Created(Url.RouteUrl(contact.Id), contact));
        }
Exemple #2
0
        public async Task <IActionResult> AddContact(Contact contact)
        {
            var serviceResponse = await _contactsRepository.AddContactAsync(contact);

            if (serviceResponse.Success)
            {
                return(Ok(serviceResponse));
            }

            return(BadRequest(serviceResponse));
        }
        public async Task <IActionResult> AddNewContact([FromBody] DTOs.ContactsForDD contactsForCreate)
        {
            log.Info("AddNewContact");
            if (contactsForCreate == null)
            {
                return(BadRequest());
            }

            contactsForCreate.UserId     = "Manoj";
            contactsForCreate.OrilBrdMbr = (contactsForCreate.OrilBrdMbr == "false") ? "N" : "Y";

            Entities.ArmsContacts contact = _mapper.Map <Entities.ArmsContacts>(contactsForCreate);

            await _contactsRepository.AddContactAsync(contact);

            return(Ok(contactsForCreate));
        }