Пример #1
0
        public bool EFInsert(string name, string family, string mobile, string email, string age, string address)
        {
            MyContact p = new MyContact
            {
                Name    = name,
                Family  = family,
                Mobile  = mobile,
                Email   = email,
                Age     = Convert.ToInt32(age),
                Address = address
            };

            db.MyContacts.Add(p);

            var res = db.SaveChanges();

            if (res == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public ActionResult Index()
        {
            DateTime            modifiedSince  = new DateTime(2018, 1, 1);
            ResultSet <Contact> contactResults = contactService.GetContacts(modifiedSince);

            IList <Contact>  contacts         = contactResults.Results;
            List <MyContact> myContacts       = new List <MyContact>();
            List <MyContact> myActiveContacts = new List <MyContact>();

            foreach (var contact in contacts)
            {
                var       serializedParent = JsonConvert.SerializeObject(contact);
                MyContact con = JsonConvert.DeserializeObject <MyContact>(serializedParent);
                if (con.Status == "ACTIVE")
                {
                    myActiveContacts.Add(con);
                }
                myContacts.Add(con);
            }

            /* foreach (var con in myContacts) {
             *   c = c + con.FirstName;
             * }
             * return Content("The contacts are " + c); */
            return(View(myActiveContacts));
        }
Пример #3
0
        private async Task ExecuteSaveCommand()
        {
            MyContact contactToBeAdded = new MyContact
            {
                Name        = Name.Value,
                Mobile      = Mobile.Value,
                Landline    = Landline.Value,
                ProfilePic  = ProfilePic.Value,
                IsFavourite = IsFavorite.Value.Equals(UIConstants.UnFavorite),
            };

            int addResult;

            try
            {
                addResult = await dataService.AddContact(contactToBeAdded);
            }
            catch (Exception ex)
            {
                await RootPage.DisplayAlert("Error adding contact", ex.Message, "Hmmmm");

                addResult = -1;
            }

            if (addResult == 1)
            {
                await GoToContactList();
            }
            else if (addResult != -1)
            {
                await RootPage.DisplayAlert("Contacts", "Error adding contact", "Hmmmm");
            }
        }
        public ActionResult Edit([Bind(Include = "Id,FirstName, LastName, EmailAddresses")] MyContact myContact)
        {
            myContact.Status = "ACTIVE";
            Contact newContact = contactService.UpdateContact(myContact, false);

            return(RedirectToAction("Index"));
        }
Пример #5
0
        public async Task <ActionResult> Details(string id)
        {
            MyContact           contact = null;
            MyContactRepository repo    = new MyContactRepository();

            contact = await repo.GetContact(id);

            return(View(contact));
        }
 public async Task<ActionResult> Create(MyContact myContact) {
   // if a contact was submitted, create it
   if (Request.HttpMethod == "POST") {
     MyContactRepository contactRepository = new MyContactRepository();
     await contactRepository.AddContact(myContact);
     return Redirect("/");
     // else create a empty model & return to the create page view
   } else {
     return View(myContact);
   }
 }
        // GET: Contact/Delete/5
        public ActionResult Delete(int?id)
        {
            Contact contact;

            if (id != null)
            {
                contact = contactService.GetContact(id.ToString());
                var       serializedParent = JsonConvert.SerializeObject(contact);
                MyContact myContact        = JsonConvert.DeserializeObject <MyContact>(serializedParent);
                return(View(myContact));
            }
            return(Content("Contact id is null"));
        }
Пример #8
0
 public static ContactDto Projection(MyContact source)
 {
     return(new ContactDto {
         Id = source.Id,
         RefId = source.RefId,
         CreationDate = source.CreationDate,
         ContactName = source.ContactName,
         ContactEmail = source.ContactEmail,
         ContactPhoneNumber = source.ContactPhoneNumber,
         ContactDescription = source.ContactDescription,
         MySyncSessionId = source.MySyncSessionId
     });
 }
 public UpdateContactPageViewModel(MyContact contactToUpdate, INavigation navigator)
 {
     this.contactToUpdate = contactToUpdate;
     this.navigator       = navigator;
     dataService          = DependencyService.Get <IDataService>();
     UpdateCommand        = Name.Select(a => !string.IsNullOrEmpty(a)).
                            CombineLatest(Mobile.Select(b => !string.IsNullOrEmpty(b)),
                                          (a, b) => a && b).ToReactiveCommand();
     UpdateCommand.Subscribe(async() => await ExecuteUpdateCommand());
     DeleteCommand.Subscribe(async() => await ExecuteDeleteCommand());
     MarkFavoriteCommand.Subscribe(async() => ExecuteMarkFavoriteCommand());
     UpdatePhotoCommand.Subscribe(async() => await ExecuteUpdatePhotoCommand());
 }
    public static void Main()
    {
        var p = new MyPerson();

        p.Name = "test";
        p.AddPhonenumber("555-2356");
        Console.WriteLine(string.Join(", ", p.Phonenumber));

        var c = new MyContact();

        c.Name = "contact";
        c.AddPhonenumber("222-235");
        Console.WriteLine(string.Join(", ", c.Phonenumber));
    }
Пример #11
0
        public async Task <ActionResult> Create(MyContact contact)
        {
            if (Request.HttpMethod == "POST")
            {
                MyContactRepository repo = new MyContactRepository();
                await repo.AddContact(contact);

                return(Redirect("/Contacts"));
            }
            else
            {
                return(View(contact));
            }
        }
Пример #12
0
        public async Task Patch()
        {
            var layer = new SalesforceLayer <MyContact>(_forceClient, new MyContactObjectDescriptor());

            var contact = new MyContact
            {
                Forename   = Guid.NewGuid().ToString(),
                Surname    = Guid.NewGuid().ToString(),
                Street     = Guid.NewGuid().ToString(),
                City       = "Glasgow",
                Country    = "United Kingdom",
                PostalCode = "G12AB",
                CanEmail   = true
            };

            var postBasket = new PostBasket <MyContact, string>(contact);
            await layer.AddResultAsync(postBasket, new Visit("Post", VisitDirections.Down)).ConfigureAwait(false);

            var id = postBasket.AscentPayload;

            Assert.False(string.IsNullOrWhiteSpace(id));

            var patchRequest = new PatchRequest <string, MyContact>(
                new Delta <string, MyContact>(id, new Dictionary <string, object>
            {
                { nameof(MyContact.Forename), "Jimmy" },
                { nameof(MyContact.Surname), "Riddle" }
            }));
            var patchBasket = new PatchBasket <string, MyContact, int>(patchRequest);
            await layer.AddResultAsync(patchBasket, new Visit("Patch", VisitDirections.Down)).ConfigureAwait(false);

            Assert.Equal(1, patchBasket.AscentPayload);

            var getBasket = new GetBasket <string, MyContact>(id);
            await layer.AddResultAsync(getBasket, new Visit("Get", VisitDirections.Down)).ConfigureAwait(false);

            var readContact = getBasket.AscentPayload;

            Assert.Equal(id, readContact.Id);
            Assert.Equal("Jimmy", readContact.Forename);
            Assert.Equal("Riddle", readContact.Surname);
            Assert.Equal(contact.Street, readContact.Street);
            Assert.Equal(contact.City, readContact.City);
            Assert.Equal(contact.Country, readContact.Country);
            Assert.Equal(contact.PostalCode, readContact.PostalCode);
            Assert.Equal(contact.CanMailshot, readContact.CanMailshot);
            Assert.Equal(contact.CanEmail, readContact.CanEmail);
            Assert.Equal(contact.CanPhone, readContact.CanPhone);
        }
        public ActionResult Create([Bind(Include = "Id,FirstName, LastName, EmailAddresses")] MyContact myContact)
        {
            ContactList myContactList = new ContactList();

            myContactList.Id   = "1977064675";
            myContactList.Name = "General Interest";
            myContact.Lists.Add(myContactList);
            if (ModelState.IsValid)
            {
                Contact newContact = contactService.AddContact(myContact, false);
                return(RedirectToAction("Index"));
            }

            return(View(myContact));
        }
Пример #14
0
        public async Task AddAsync(MyContact entity)
        {
            var count = 0;

            count = Uow.Repository <User>().Count(t => t.UserMobileNumber == 7405755503);
            var temp = Uow.Repository <User>().SingleOrDefault(t => t.UserMobileNumber == 1233);

            if (count != 0)
            {
                entity.UsercontactId = temp.UserId;
                await Uow.RegisterNewAsync(entity);

                await Uow.CommitAsync();
            }
        }
        public async Task <ActionResult> Create(MyContact myContact)
        {
            // if a contact was submitted, create it
            if (Request.HttpMethod == "POST")
            {
                MyContactRepository contactRepository = new MyContactRepository();
                await contactRepository.AddContact(myContact);

                return(Redirect("/"));
                // else create a empty model & return to the create page view
            }
            else
            {
                return(View(myContact));
            }
        }
Пример #16
0
        public async Task <ActionResult> Edit(string Id, MyContact contact)
        {
            MyContactRepository repo = new MyContactRepository();

            if (Request.HttpMethod == "POST")
            {
                await repo.UpdateContact(contact);

                return(Redirect("/Contacts"));
            }
            else
            {
                contact = await repo.GetContact(Id);

                return(View(contact));
            }
        }
        // GET: Contact/Details/5
        public ActionResult Details(int?id)
        {
            Contact contact;

            try
            {
                contact = contactService.GetContact(id.ToString());
            }
            catch (Exception)
            {
                return(Content("No results"));
            }
            var       serializedParent = JsonConvert.SerializeObject(contact);
            MyContact myContact        = JsonConvert.DeserializeObject <MyContact>(serializedParent);

            return(View(myContact));
        }
Пример #18
0
        public bool EFDelete(int contactId)
        {
            MyContact p = new MyContact();

            p = EFSelectRow(contactId);
            db.MyContacts.Remove(p);

            var res = db.SaveChanges();

            if (res == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #19
0
        public async Task Delete()
        {
            var layer = new SalesforceLayer <MyContact>(_forceClient, new MyContactObjectDescriptor());

            var contact = new MyContact
            {
                Forename   = Guid.NewGuid().ToString(),
                Surname    = Guid.NewGuid().ToString(),
                Street     = Guid.NewGuid().ToString(),
                City       = "Glasgow",
                Country    = "United Kingdom",
                PostalCode = "G12AB",
                CanEmail   = true
            };

            var postBasket = new PostBasket <MyContact, string>(contact);
            await layer.AddResultAsync(postBasket, new Visit("Post", VisitDirections.Down)).ConfigureAwait(false);

            var id = postBasket.AscentPayload;

            Assert.False(string.IsNullOrWhiteSpace(id));

            var deleteBasket = new DeleteBasket <string, MyContact, int>(id);
            await layer.AddResultAsync(deleteBasket, new Visit("Delete", VisitDirections.Down)).ConfigureAwait(false);

            Assert.Equal(1, deleteBasket.AscentPayload);

            Exception exception = null;

            try
            {
                var getBasket = new GetBasket <string, MyContact>(id);
                await layer.AddResultAsync(getBasket, new Visit("Get", VisitDirections.Down)).ConfigureAwait(false);
            }
            catch (InvalidOperationException ex)
            {
                exception = ex;
            }

            Assert.NotNull(exception);
            Assert.Contains("Done: True, Count: 0", exception.Message);
        }
Пример #20
0
        public bool EFUpdate(int contactId, string name, string family, string mobile, string email, string age, string address)
        {
            MyContact p = new MyContact();

            p         = EFSelectRow(contactId);
            p.Name    = name.ToString();
            p.Family  = family.ToString();
            p.Mobile  = mobile.ToString();
            p.Email   = email.ToString();
            p.Age     = Convert.ToInt32(age);
            p.Address = address.ToString();

            var res = db.SaveChanges();

            if (res == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #21
0
 public Task <object> GetBy(MyContact parameters)
 {
     throw new NotImplementedException();
 }
Пример #22
0
 public HashSet <string> UpdateValidation(MyContact entity)
 {
     return(ValidationMessages);
 }
    public async Task AddContact(MyContact myContact) {
      // acquire a O365 client to retrieve contacts
      var client = await EnsureClientCreated();

      // create new contact record
      var newContact = new Microsoft.Office365.OutlookServices.Contact {
        GivenName = myContact.GivenName,
        Surname = myContact.Surname,
        CompanyName = myContact.CompanyName
      };

      // add email address
      newContact.EmailAddresses.Add(new EmailAddress() {
        Address = myContact.EmailAddress,
        Name = myContact.EmailAddress
      });

      // add phone numbers to collections
      newContact.HomePhones.Add(myContact.HomePhone);
      newContact.BusinessPhones.Add(myContact.BusinessPhone);

      // create the contact in O365
      await client.Me.Contacts.AddContactAsync(newContact);
    }
Пример #24
0
        public async Task UpdateAsync(MyContact entity)
        {
            await Uow.RegisterDirtyAsync(entity);

            await Uow.CommitAsync();
        }
        public async Task <ActionResult> Create(MyContact myEvent)
        {
            await _repo.AddContact(myEvent);

            return(Redirect("/Contacts"));
        }
        public async Task <ActionResult> Create()
        {
            var myContact = new MyContact();

            return(View(myContact));
        }
        //////////////////////////////////////
        // Function runs in worker thread and emulates long process.
        //////////////////////////////////////
        public void Run()
        {
            String s;

            object missing = System.Reflection.Missing.Value;
            int    ii;

            // Create an instance of Outlook Application and Outlook Contacts folder.
            //try
            {
                //Monitor.Enter(this);

                s = "Opening Folder \"" + m_folderName + "\"";
                m_form.Invoke(m_form.m_Delegate_LoadContactsThread_AppendToLog, new Object[] { s });

                OutLook1.MAPIFolder   fldContacts = null;
                OutLook1._Application outlookObj  = new OutLook1.Application();

                //m_ContactList = new List<MyContact>();

                if (m_folderName == "Default")
                {
                    fldContacts = (OutLook1.MAPIFolder)outlookObj.Session.GetDefaultFolder(OutLook1.OlDefaultFolders.olFolderContacts);
                }
                else
                {
                    OutLook1.MAPIFolder contactsFolder = (OutLook1.MAPIFolder)
                                                         outlookObj.Session.GetDefaultFolder(OutLook1.OlDefaultFolders.olFolderContacts);

                    // Verify the custom folder in Outlook.
                    foreach (OutLook1.MAPIFolder subFolder in contactsFolder.Folders)
                    {
                        if (subFolder.Name == m_folderName)
                        {
                            fldContacts = subFolder;
                            break;
                        }
                    }
                }

                /////////////////////////////////
                // CountFields
                /////////////////////////////////
                //MyContact contact = new MyContact();
                MyFields flds = new MyFields(m_form);
                flds.ClearFieldCount();

                /////////////////////////////////
                // Load Contacts
                /////////////////////////////////
                s = "Load contacts from Folder \"" + m_folderName + "\"";
                m_form.Invoke(m_form.m_Delegate_LoadContactsThread_AppendToLog, new Object[] { s });

                // Loop through contact in specified folder.
                ii = 0;
                foreach (Microsoft.Office.Interop.Outlook._ContactItem OutlookContact in fldContacts.Items)
                {
                    ii++;
                    if (ii > m_MaxContactsToRead)
                    {
                        break;
                    }

                    // Count used fields
                    flds.AccumulateFields(OutlookContact);

                    // Add contact to list
                    MyContact contact = new MyContact();
                    contact.Clear();
                    contact.StoreContact(contact, ii, OutlookContact);

                    // Make synchronous call to main form.
                    // MainForm.AppendToLog function runs in main thread.
                    // (To make asynchronous call use BeginInvoke)

                    // Add line to log
                    //s = m_folderName + "[" + m_MaxContactsToRead + "] " + ii.ToString() + " read";
                    //m_form.Invoke(m_form.m_DelegateLoadContactsThreadAppendToLog, new Object[] {s});

                    // Update counter on main form
                    m_form.Invoke(m_form.m_Delegate_LoadContactsThread_UpdateCounter, new Object[] { ii });

                    // Build Contact List
                    m_form.Invoke(m_form.m_Delegate_LoadContactsThread_AddOneContact, new Object[] { contact });

                    // Check if thread is cancelled
                    if (m_EventStop.WaitOne(0, true))
                    {
                        // Clean-up operations may be placed here
                        // ...

                        // Inform main thread that this thread stopped
                        m_EventStopped.Set();
                        return;
                    }
                }
                // Build Field Occurance List
                flds.PrintFieldCount();

                s = "Done";
                m_form.Invoke(m_form.m_Delegate_LoadContactsThread_AppendToLog, new Object[] { s });

                // Inform the user of the status
                //m_NumberOfContactsRead = m_ContactList.Count;
                //m_ContactsInOutlook = m_ContactList.Count;
                //txtContactsInOutlook.Text = m_ContactList.Count.ToString();

                // Make synchronous call to main form
                // to inform it that thread finished
                m_form.Invoke(m_form.m_Delegate_LoadContactsThread_Finished, null);

                //Monitor.Exit(this);
            }

            //catch (System.Exception ex)
            //{
            //  throw new ApplicationException(ex.Message);
            //}
        }
Пример #28
0
 public HashSet <string> DeleteValidation(MyContact parameters)
 {
     return(ValidationMessages);
 }
Пример #29
0
 public Task DeleteAsync(MyContact parameters)
 {
     throw new NotImplementedException();
 }
Пример #30
0
 public UpdateContactPage(MyContact contactToUpdate)
 {
     InitializeComponent();
     BindingContext = new UpdateContactPageViewModel(contactToUpdate, Navigation);
 }
Пример #31
0
 public async Task <int> AddContact(MyContact contact)
 {
     return(await dbService.InsertItem(contact));
 }
Пример #32
0
 public async Task <int> DeleteContact(MyContact contact)
 {
     return(await dbService.DeleteItem(contact));
 }