Ejemplo n.º 1
0
        public JsonResult AddContactToGroup(int contactId, int contactGroupId)
        {
            var result = new ServiceResponse <Object>();

            Contact      contact      = null;
            ContactGroup contactGroup = null;

            try
            {
                contact      = _contactService.GetContactById(contactId);
                contactGroup = _contactService.GetGroupById(contactGroupId);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("AddContactToGroup: " + ex.Message);

                result.Message = "A contact or group does not exist";
            }

            if (contact != null && contactGroup != null)
            {
                try
                {
                    _contactService.AddContactToGroup(contact, contactGroup);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine("AddContactToGroup: " + ex.Message);

                    result.Message = ex.Message;
                }
            }

            result.Result = GetAllGroupsResponse();

            return(JsonResponse(result));
        }