Esempio n. 1
0
        public async Task ClubLogbookContextTest()
        {
            ImportDataTest import = new ImportDataTest();

            import.InitContext();
            try
            {
                _context = import._context;
                var          membersVar = _context.Members;
                List <Pilot> members    = await _context.Members.ToListAsync();


                List <Club> list2 = await _context.Clubs.Include(a => a.Members).ThenInclude(a => a.Contact).ToListAsync();

                List <Club> list = await _context.Clubs.Include(a => a.Aircrafts).ThenInclude(a => a.AirCraftModel).ToListAsync();

                var cl    = list.FirstOrDefault();
                var list1 = await _context.Clubs.ToListAsync();

                ContactBook contactBooks = await _context.ContactBooks.Include(i => i.Contacts).ThenInclude(ii => ii.Addresses).SingleOrDefaultAsync();

                contactBooks = await _context.ContactBooks.Include(i => i.Contacts).ThenInclude(ii => ii.Phones).SingleOrDefaultAsync();

                List <Address> addresses = contactBooks.Contacts.SelectMany(i => i.Addresses).ToList();
                List <Phone>   phones    = contactBooks.Contacts.SelectMany(i => i.Phones).ToList();
                var            clmem     = cl.Members;

                //cl.Members = members;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
        public ContactENT UpdateSelectSingle(ContactENT Obj)
        {
            NbkDbEntities dbcontext = new NbkDbEntities();
            ContactBook   Data      = new ContactBook()
            {
                Id          = Obj.Id,
                Name        = Obj.Name,
                CompanyName = Obj.CompanyName,
                ContactNo   = Obj.ContactNo,
                Email       = Obj.Email
            };


            dbcontext.ContactBook.Attach(Data);
            var update = dbcontext.Entry(Data);

            update.Property(x => x.Name).IsModified        = true;
            update.Property(x => x.CompanyName).IsModified = true;
            update.Property(x => x.ContactNo).IsModified   = true;
            update.Property(x => x.Email).IsModified       = true;

            dbcontext.SaveChanges();

            return(Obj);
        }
 public void Given_my_contact_book_is_filled_with_many_contacts()
 {
     for (var i = 0; i < 10000; ++i)
     {
         ContactBook.AddContact(i.ToString(CultureInfo.InvariantCulture), i.ToString(CultureInfo.InvariantCulture));
     }
 }
Esempio n. 4
0
        public void _AddContactBook(ContactBook newContactBook)
        {
            ucContact newUcContact = new ucContact(newContactBook, this, mainForm);

            listContact.Add(newUcContact);
            this.pnListContact.Controls.Add(newUcContact);
        }
Esempio n. 5
0
        public IActionResult About()
        {
            var person = new Person()
            {
                Name     = "Christian",
                Email    = "*****@*****.**",
                Password = "******",
                Username = "******"
            };

            var contact = new Contact()
            {
                FirstName  = "Christian",
                Surname    = "Rocha",
                Birthday   = new DateTime(1993, 12, 18),
                Profession = "Student",
                Email      = "*****@*****.**",
                Phone      = "987654321",
                Address    = "Street X"
            };

            var contactBook = new ContactBook()
            {
                Name           = "PersonalContacts",
                Type           = "Personal",
                Size           = 100,
                UsernamePerson = "christian",
            };

            contactBook.Contacts.Add(contact);

            person.ContactBooks.Add(contactBook);

            return(View(person));
        }
        public async Task <IActionResult> ContactAdd(ContactBook contactBook)
        {
            db.ContactBooks.Add(contactBook);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
 public void When_I_remove_one_contact()
 {
     RemovedContacts = ContactBook.Contacts.Take(1).ToArray();
     foreach (var contact in RemovedContacts)
     {
         ContactBook.Remove(contact.Name);
     }
 }
 public void When_I_clear_it()
 {
     foreach (var contact in ContactBook.Contacts.ToArray())
     {
         ContactBook.Remove(contact.Name);
     }
     StepExecution.Current.Bypass("Contact book clearing is not implemented yet. Contacts are removed one by one.");
 }
Esempio n. 9
0
        public void DeleteSingle(int Id)
        {
            NbkDbEntities dbcontext = new NbkDbEntities();
            ContactBook   Obj       = dbcontext.ContactBook.Where(x => x.Id == Id).FirstOrDefault();

            dbcontext.ContactBook.Remove(Obj);
            dbcontext.SaveChanges();
        }
Esempio n. 10
0
        public ProjectENT UpdateSelectSingle(ProjectENT Obj)
        {
            NbkDbEntities dbcontext = new NbkDbEntities();


            Project Data = new Project()
            {
                Id                 = Obj.Id,
                Title              = Obj.Id + " - " + Obj.Address + " - " + Obj.GardsNo + "/" + Obj.Bruksnmmer,
                Address            = Obj.Address,
                CustomerId         = Obj.CustomerId,
                ContactPersonId    = Obj.ContactPersonId,
                BuildingSupplierId = Obj.BuildingSupplierId,
                GardsNo            = Obj.GardsNo,
                Bruksnmmer         = Obj.Bruksnmmer,
                PostNo             = Obj.PostNo,
                Poststed           = Obj.Poststed,
                Kommune            = Obj.Kommune,
                Description        = Obj.Description
            };

            dbcontext.Project.Attach(Data);
            var update = dbcontext.Entry(Data);

            update.Property(x => x.Title).IsModified              = true;
            update.Property(x => x.CustomerId).IsModified         = true;
            update.Property(x => x.ContactPersonId).IsModified    = true;
            update.Property(x => x.BuildingSupplierId).IsModified = true;
            update.Property(x => x.GardsNo).IsModified            = true;
            update.Property(x => x.PostNo).IsModified             = true;
            update.Property(x => x.Poststed).IsModified           = true;
            update.Property(x => x.Kommune).IsModified            = true;
            update.Property(x => x.Bruksnmmer).IsModified         = true;
            update.Property(x => x.Description).IsModified        = true;
            update.Property(x => x.Address).IsModified            = true;
            dbcontext.SaveChanges();


            //Services add
            Obj.ProjectService = InsertProjectServicesList(Obj.ProjectService, Obj.Id);

            //Adding Default partytype into projectparty table
            List <ServiceWorkflowCategory> DataServiceWorkflowCatagory = GetServiceWorkflowCategoryByServiceID(Obj.ProjectService);


            List <PartyType> DefaultPartyTypes = DefaultPartyTypesList(DataServiceWorkflowCatagory);
            ContactBook      Dummy             = GetDummyContact();

            foreach (var item in DefaultPartyTypes)
            {
                AddProjectParty(Obj.Id, Dummy.Id, item.Id);
            }

            //Project checklist creation
            ProjectChecklistsOnUpdateCreate(Obj.Id, Obj.ProjectService);

            return(Obj);
        }
Esempio n. 11
0
        public ProjectENT CreateSingle(ProjectENT Obj)
        {
            NbkDbEntities dbcontext = new NbkDbEntities();

            //changes for adding id manually
            if (Obj.Id == 0)
            {
                int maxId = Convert.ToInt32(ProjectsMaxId());
                Obj.Id = maxId + 1;
            }

            Project Data = new Project()
            {
                Id                 = Obj.Id,
                Title              = Obj.Id + " - " + Obj.Address + " - " + Obj.GardsNo + "/" + Obj.Bruksnmmer,
                Address            = Obj.Address,
                Dated              = DateTime.Today,
                CustomerId         = Obj.CustomerId,
                ContactPersonId    = Obj.ContactPersonId,
                BuildingSupplierId = Obj.BuildingSupplierId,
                GardsNo            = Obj.GardsNo,
                Bruksnmmer         = Obj.Bruksnmmer,
                PostNo             = Obj.PostNo,
                Poststed           = Obj.Poststed,
                Kommune            = Obj.Kommune,
                Description        = Obj.Description
                                     //CreateChecklistCdate= Obj.CreateChecklistCdate,
                                     //AddPartiesCdate= Obj.AddPartiesCdate
            };

            dbcontext.Project.Add(Data);
            dbcontext.SaveChanges();

            //Services add
            InsertProjectServicesList(Obj.ProjectService, Obj.Id);

            //Adding Default partytype into projectparty table
            List <ServiceWorkflowCategory> DataServiceWorkflowCatagory = GetServiceWorkflowCategoryByServiceID(Obj.ProjectService);

            //Get project services and workflow list
            Obj = GetProjectServiceAndWorkflowList(Obj);

            List <PartyType> DefaultPartyTypes = DefaultPartyTypesList(DataServiceWorkflowCatagory);
            ContactBook      Dummy             = GetDummyContact();

            foreach (var item in DefaultPartyTypes)
            {
                AddProjectParty(Obj.Id, Dummy.Id, item.Id);
            }

            //Project checklist creation
            ProjectChecklistsCreate(Obj.Id);


            Obj.Title = Obj.Id + " - " + Obj.Address + " - " + Obj.GardsNo + "/" + Obj.Bruksnmmer;
            return(Obj);
        }
Esempio n. 12
0
 public ucContact(ContactBook contactBook, FrmContactBook frmContactBook, FrmMain mainForm)
 {
     this.contactBook    = contactBook;
     this.mainForm       = mainForm;
     this.FrmContactBook = frmContactBook;
     this.Dock           = DockStyle.Top;
     listContact__User   = new List <ucContact__User>();
     InitializeComponent();
     _InitControls();
     _LoadContact();
 }
Esempio n. 13
0
        public async Task <Guid> GetContactBookIdByUser(Guid userId)
        {
            ContactBook contactBook = await _uow.ContactBooksRepository.GetContactBookByUser(userId);

            if (null != contactBook)
            {
                return(contactBook.Id);
            }

            return(Guid.Empty);
        }
        public async Task <IActionResult> ConfirmDelete(int?id)
        {
            if (id != null)
            {
                ContactBook contactBook = await db.ContactBooks.FirstOrDefaultAsync(p => p.Id == id);

                if (contactBook != null)
                {
                    return(View(contactBook));
                }
            }
            return(NotFound());
        }
Esempio n. 15
0
        public static void Show(ContactBook book)
        {
            while (true)
            {
                PromptE.Menu("[UVV Contacts] Pick an option")
                .Action(new AddContactButton(book))
                .Action("List contacts", () => ContactsMenu.Show(book))
                .Action(new ExitApplicationAction())
                .Show();
            }

            // ReSharper disable once FunctionNeverReturns
        }
        private void AddSomeContacts()
        {
            AddedContacts = new[]
            {
                new Contact("Jack", "123-456-789"),
                new Contact("Samantha", "321-654-987"),
                new Contact("Josh", "132-465-798")
            };

            foreach (var contact in AddedContacts)
            {
                ContactBook.AddContact(contact.Name, contact.PhoneNumber);
            }
        }
Esempio n. 17
0
        public static void Show(ContactBook book)
        {
            var contact = ContactSelectorMenu.Show(book);

            if (contact == null)
            {
                return;
            }

            PromptE.Menu($"[name: {contact.DisplayName} | email: {contact.Email} | cell: {contact.CellphoneNumber}]")
            .Action(new UpdateContactAction(book, contact))
            .Action("Delete", () => book.Remove(contact))
            .Action("[Cancel]", null)
            .Show();
        }
Esempio n. 18
0
        public ContactENT SelectSingle(int Id)
        {
            NbkDbEntities dbcontext = new NbkDbEntities();
            ContactBook   Obj       = dbcontext.ContactBook.Where(x => x.Id == Id).FirstOrDefault();
            ContactENT    Data      = new ContactENT()
            {
                Id          = Obj.Id,
                Name        = Obj.Name,
                CompanyName = Obj.CompanyName,
                ContactNo   = Obj.ContactNo,
                Email       = Obj.Email
            };

            return(Data);
        }
Esempio n. 19
0
        public void DisplayMenu()
        // Welcome to your address book.
        // ----------------------------------
        // 1. View all contacts
        //     1a. View Contact Details
        //         1aa. Update Contact
        //         1ab.Remove Contact
        // 2. View only specific group of contacts (eg, CoWorkers, Friends, FamilyMembers)
        //     2a. View Contact Details
        //         2aa. Update Contact
        //         2ab.Remove Contact
        // 3. Get Contact by name
        // 4. Add new Contact
        // 5. Quit the application
        {
            Console.WriteLine("Welcome to the Contact Book!");
            System.Console.WriteLine("-----------------------------------");
            System.Console.WriteLine("What would you like to do?");
            System.Console.WriteLine(("1. View all Contacts\n2. View Specific Group\n3.Search Contact\n4. Add New Contact\n5. Quit!"));
            switch (Console.ReadLine())
            {
            case "1":
                ContactBook.ListContacts();
                break;

            case "2":
                Console.WriteLine("Which Group\n1 - Coworkers\n2 - Friends\n3 - Family Members\n4 - Go Back");
                ContactBook.ListContacts(Console.ReadLine());
                break;

            case "3":
                Console.WriteLine("Enter Name:");
                ContactBook.GetContactByName();
                break;

            case "4":
                ContactBook.CreateContact();
                break;

            case "5":
                UsingContactBook = false;
                break;

            default:
                Console.WriteLine("Invalid Entry");
                break;
            }
        }
        public async Task <IActionResult> Delete(int?id)
        {
            if (id != null)
            {
                ContactBook contactBook = await db.ContactBooks.FirstOrDefaultAsync(p => p.Id == id);

                if (contactBook != null)
                {
                    db.ContactBooks.Remove(contactBook);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            return(NotFound());
        }
Esempio n. 21
0
        public void Setup()
        {
            UsingContactBook = true;

            ContactBook = new ContactBook("CodeWorks");

            Friend       friend1       = new Friend("Tom", "Jones", "Boise", "Tommy");
            FamilyMember familyMember1 = new FamilyMember("Peter", "Parker", "Queens", "Spidey");
            CoWorker     coWorker1     = new CoWorker("Charles", "Xavier", "Manhattan", "School of Gifted Students", "Professor");

            friend1.DisplayContactDetails();

            ContactBook.Contacts.Add(friend1);
            ContactBook.Contacts.Add(familyMember1);
            ContactBook.Contacts.Add(coWorker1);
        }
Esempio n. 22
0
        public ActionResult Save(ContactBook con)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (ContactBookEntities dc = new ContactBookEntities())
                {
                    if (con.ContactID > 0)
                    {
                        //Edit
                        var v = dc.ContactBooks.Where(a => a.ContactID == con.ContactID).FirstOrDefault();
                        if (v != null)
                        {
                            v.FirstName = con.FirstName;
                            v.LastName  = con.LastName;
                            v.EmailID   = con.EmailID;
                            v.City      = con.City;
                            v.Country   = con.Country;
                        }
                        dc.SaveChanges();
                    }
                    else
                    {
                        //Save
                        try
                        {
                            dc.ContactBooks.Add(con);
                            dc.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            return(new JavaScriptResult()
                            {
                                Script = "alert('Duplicate EmailID Found.');"
                            });
                        }
                    }

                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Esempio n. 23
0
        public ContactENT CreateSingle(ContactENT Obj)
        {
            NbkDbEntities dbcontext = new NbkDbEntities();
            ContactBook   Data      = new ContactBook()
            {
                Name        = Obj.Name,
                CompanyName = Obj.CompanyName,
                ContactNo   = Obj.ContactNo,
                Email       = Obj.Email
            };


            dbcontext.ContactBook.Add(Data);
            dbcontext.SaveChanges();

            Obj.Id = Data.Id;

            return(Obj);
        }
        public Task <bool> Handle(CreateNewContactBookCommand request, CancellationToken cancellationToken)
        {
            try
            {
                if (!request.IsValid())
                {
                    return(Task.FromResult(false));
                }

                ContactBook contactBook = new ContactBook(new Guid(), request.UserId);
                _contactUnitOfWork.ContactBooksRepository.CreateContactBook(contactBook);
                _contactUnitOfWork.Commit();
                return(Task.FromResult(true));
            }
            catch (Exception)
            {
                DeleteUser(request.UserId);
                throw;
            }
        }
Esempio n. 25
0
        public UserProfileENT SearchUserByEmail(string email)
        {
            NbkDbEntities dbcontext   = new NbkDbEntities();
            Project       ObjProj     = dbcontext.Project.FirstOrDefault();
            ContactBook   UserContact = dbcontext.ContactBook.Where(x => x.Email == email).FirstOrDefault();

            Users          Obj  = dbcontext.Users.Where(x => x.ContactId == UserContact.Id).FirstOrDefault();
            UserProfileENT Data = new UserProfileENT()
            {
                Id          = Obj.Id,
                Designation = Obj.Designation,
                IsActive    = Obj.IsActive,
                Password    = Obj.Password,
                Picture     = Obj.Picture,
                UserName    = Obj.UserName,
                UserTypeId  = Obj.UserTypeId,
                ContactId   = Obj.ContactId
            };

            return(Data);
        }
        public ActionResult Create(ContactBook c)
        {
            Uri uri = new Uri("http://localhost:51598/api/");

            using (var client = new HttpClient())
            {
                client.BaseAddress = uri;
                var result = client.PostAsJsonAsync("PhoneBookapi/AddContact", c).Result;
                // var lstcat = JsonConvert.DeserializeObject<List<CategoryMVC>>(result);
                if (result.IsSuccessStatusCode == true)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewData.Add("msg", "Record is not inserted some error is getting");
                }

                return(View("Index"));
            }
        }
Esempio n. 27
0
        public static Contact Show(ContactBook book)
        {
            var orderingField = OrderingMethodMenu.Show();

            if (orderingField == null)
            {
                return(null);
            }

            var contacts = book.OrderBy(orderingField);

            var builder = PromptE.Select <Contact>("Select contact");

            foreach (var contact in contacts)
            {
                builder.Option(contact.DisplayName, contact);
            }

            builder.Option("[Cancel]", null);

            return(builder.Show());
        }
        public ActionResult Edit(ContactBook con)
        {
            Uri uri = new Uri("http://localhost:51598/api/");

            using (var client = new HttpClient())
            {
                client.BaseAddress = uri;
                var result = client.PutAsJsonAsync("PhoneBookapi/" + con.ContactId, con).Result;
                // var lstcat = JsonConvert.DeserializeObject<List<CategoryMVC>>(result);
                if (result.IsSuccessStatusCode == true)
                {
                    return(RedirectToAction("Index"));

                    ViewData.Add("msg", "Record Not Updated Successfully");
                }
                else
                {
                    ViewData.Add("msg", "Record Not Updated Successfully");
                }

                return(View());
            }
        }
Esempio n. 29
0
        static void Main(string[] args)
        {
            ContactBook cb = new ContactBook();

            cb.loadContacts();

            while (true)
            {
                Console.Clear();

                Console.WriteLine("Welcome to your Contact Book");
                Console.WriteLine("1 - Show all Contacts");
                Console.WriteLine("2 - Delete a Person by Name");
                Console.WriteLine("3 - Select a person by Name");
                Console.WriteLine("4 - Create a new Person");
                Console.WriteLine("5 - Exit the Application\n");

                Console.Write("Your choice: ");
                string selectionStr = Console.ReadLine();

                int selection = 0;
                if (Int32.TryParse(selectionStr, out selection))
                {
                    selection = Convert.ToInt32(selectionStr);
                }

                string name = "";

                switch (selection)
                {
                case 1:
                    Console.WriteLine("Print all:");
                    cb.printEntries();
                    break;

                case 2:
                    Console.WriteLine("Delete:");
                    Console.Write("Please enter the name of the person you want to delete: ");
                    name = Console.ReadLine();
                    cb.deleteEntryByName(name);
                    cb.saveContacts();
                    break;

                case 3:
                    Console.WriteLine("Select:");
                    name = Console.ReadLine();
                    cb.printEntryByName(name);
                    break;

                case 4:
                    Console.WriteLine("Create:");
                    cb.createEntry();
                    cb.saveContacts();
                    break;

                case 5:
                    Console.WriteLine("Exiting...");
                    cb.saveContacts();
                    return;

                default:
                    Console.WriteLine("This is not a valid Option!");
                    break;
                }

                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();

                System.Threading.Thread.Sleep(50);
            }
        }
 public ScenarioContext()
 {
     ContactBook     = new ContactBook();
     AddedContacts   = new Contact[0];
     RemovedContacts = new Contact[0];
 }