コード例 #1
0
        public Api.BusinessLogic.Contact CreateContact([FromBody] string value)
        {
            var contact        = JsonConvert.DeserializeObject <Contact>(value);
            var serviceContact = new Api.BusinessLogic.Contact()
            {
                FirstName      = contact.FirstName,
                LastName       = contact.LastName,
                Email          = contact.Email,
                PhoneNumber    = contact.PhoneNumber,
                SelectedStatus = contact.Status
            };

            var result = _manager.CreateContact(serviceContact);

            return(result);
        }
コード例 #2
0
        public IActionResult Post([FromBody] ContactSavingModel contactToCreateModel, string team)
        {
            if (team != null)
            {
                var teamName = nameof(contactToCreateModel.Team);
                contactToCreateModel.Team = team;
                ModelState.ClearError(teamName);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var contactToCreate = ContactMapper.ContactModelToContact(contactToCreateModel);

            return(Ok(_contactManager.CreateContact(contactToCreate).ToString()));
        }
コード例 #3
0
ファイル: ContactController.cs プロジェクト: firate/easycrm
        public async Task <IActionResult> CreateNewContact([FromBody] ContactCreationDTO contactCreationDTO)
        {
            try
            {
                var contact = mapper.Map <Contact>(contactCreationDTO);

                var result = await contactManager.CreateContact(contact);

                if (result == true)
                {
                    var contactToReturn = mapper.Map <ContactReturnDTO>(contact);
                    return(CreatedAtRoute("GetContact", new { Id = contactToReturn.ContactId }, contactToReturn));
                }

                return(BadRequest());
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #4
0
ファイル: ContactBOTests.cs プロジェクト: mo5h/omeo
        [Test] public void FindContactTestAlmostEqualsWithNullAccountSearch()
        {
            IContact c1 = _contactManager.FindOrCreateContact("account1", "FirstName LastName");
            IContact c2 = _contactManager.CreateContact("FirstName LastName (JIRA)");

            Assert.IsTrue(c1.Resource.Id != c2.Resource.Id);

            IContact c = _contactManager.FindOrCreateContact(null, "FirstName LastName");

            Assert.IsTrue(c.Resource.Id == c1.Resource.Id);

            c = _contactManager.FindOrCreateContact("account1", "FirstName LastName");
            Assert.IsTrue(c.Resource.Id == c1.Resource.Id);

            //-----------------------------------------------------------------
            IResource account = _contactManager.FindOrCreateEmailAccount("account2");

            account.SetProp(_contactManager.Props.LinkEmailAcct, c2.Resource);

            c = _contactManager.FindOrCreateContact("account2", "FirstName LastName");
            Assert.IsTrue(c.Resource.Id == c2.Resource.Id);
        }
コード例 #5
0
 public IActionResult AddContact(ContactViewModel obj)
 {
     try
     {
         string userId  = User.FindFirst(ClaimTypes.NameIdentifier).Value;
         int    groupId = userManager.Users.FirstOrDefault(u => u.Id == userId).ApplicationGroupId;
         if (obj.Name == null)
         {
             obj.Name = "";
         }
         if (obj.Surname == null)
         {
             obj.Surname = "";
         }
         if (obj.Notes == null)
         {
             obj.Notes = "";
         }
         if (obj.KeyWords == null)
         {
             obj.KeyWords = "";
         }
         if (contactManager.CreateContact(obj, groupId))
         {
             return(new ObjectResult("Phone added successfully!"));
         }
         else
         {
             return(new ObjectResult("Contact with this phone number already exist!"));
         }
     }
     catch (Exception ex)
     {
         return(new ObjectResult(ex.Message));
     }
 }
コード例 #6
0
        public async Task <IActionResult> Create([FromBody] NewContactViewModel model)
        {
            var responseModel = await _contactMan.CreateContact("3ef23190-4abb-421a-94bd-77ee1a153275", model);

            return(Ok(new ResponseModel <ContactViewModel>(responseModel)));
        }