Esempio n. 1
0
        public int AddCollections <T>(List <T> entities)
        {
            var entityType = Master.Model.FindEntityType(typeof(T));
            var primaryKey = entityType.FindPrimaryKey();
            var keyValues  = new object[primaryKey.Properties.Count];

            foreach (T e in entities)
            {
                for (int i = 0; i < keyValues.Length; i++)
                {
                    keyValues[i] = primaryKey.Properties[i].GetGetter().GetClrValue(e);
                }

                var obj = Master.Find(typeof(T), keyValues);

                if (obj == null)
                {
                    Master.Add(e);
                }
                else
                {
                    Master.Entry(obj).CurrentValues.SetValues(e);
                }
            }
            return(Master.SaveChanges());
        }
        /// <summary>
        /// Method for adding user
        /// </summary>
        /// <param name="user">user</param>
        /// <returns>id</returns>
        public int Add(UserDataContract user)
        {
            if (user.DateOfBirth == null)
            {
                throw new ArgumentNullException();
            }

            return(master.Add(Mapper.UserContractToUser(user)));
        }
Esempio n. 3
0
        public int AddUserRoleJurisdiction(UserRoleJurisdiction urj)
        {
            int id = 0;

            try
            {
                var entity = Master.Add(urj);
                Master.SaveChanges();
                id = urj.Id;
            }
            catch (Exception ex)
            {
            }
            return(id);
        }
Esempio n. 4
0
        private void DistributeFilesNames()
        {
            string fileName;
            string versionMarker;

            foreach (string filePath in InitialPaths)
            {
                fileName      = Path.GetFileName(filePath);
                versionMarker = fileName.Substring(0, 1);

                if (versionMarker == "[")
                {
                    Master.Add(fileName);
                }
                else if (versionMarker == "]")
                {
                    Test.Add(fileName);
                }
                else
                {
                    Common.Add(fileName);
                }
            }
        }
Esempio n. 5
0
 public void CreateNew(Banner banner)
 {
     Master.Add(banner);
 }
Esempio n. 6
0
 public virtual bool Add(T entity)
 {
     Master.Add(entity);
     return(Master.SaveChanges() > 0);
 }
 public void Add(UserDataContract userDC) => master.Add(userDC.ToUser());
Esempio n. 8
0
    static void Main(string[] args)
    {
        Console.WriteLine("1 : Add ContactDetails");
        Console.WriteLine("2 : Delete ContactDetails");
        Console.WriteLine("3 : Display ContactDetails");
        Console.WriteLine("4 : Exit");
        int UserInput = Int32.Parse(Console.ReadLine());

        if (UserInput == 1)
        {
            AddContact();
        }
        else if (UserInput == 2)
        {
            DeleteContact();
        }
        else if (UserInput == 3)
        {
            ShowContact();
        }
        else
        {
            Console.WriteLine("You have entered a wrong option.Please try again with different option.");
            Main();
        }
        void AddContact()
        {
            Contact Contact = new Contact();

            Console.WriteLine("Enter firstName : ");
            Contact.firstName = Console.ReadLine();
            Console.WriteLine("Enter lastName : ");
            Contact.lastName = Console.ReadLine();
            Console.WriteLine("Enter phoneNumber : ");
            Contact.phoneNumber = Console.ReadLine();
            Console.WriteLine("Enter emailId : ");
            Contact.emailId = Console.ReadLine();
            Master.Add(Contact);
            Console.WriteLine("Details added successfully ");
            Main();
        }

        void DeleteContact()
        {
            Console.Write("Enter phone number you want to delete:");
            int phonenumber = Console.ReadLine();

            Contacts.RemoveAll(mobileNumber => mobileNumber.phoneNumber == phonenumber);
            Console.Write("Contact deleted successfully");
            Main();
        }

        void ShowContact()
        {
            foreach (var person in Contacts)
            {
                Console.WriteLine("Name : " + person.firstName + " " + person.lastName + ",PhoneNumber :" + person.phoneNumber + ", Email Id:" + person.emailId);
            }
            Main();
        }
    }
Esempio n. 9
0
 public int Add(UserDataContract user)
 => master.Add(user.ToUser());
Esempio n. 10
0
 public void AddMaster(string database)
 {
     Master.Add(database);
 }
        static void Main(string[] args)
        {
            try
            {
                User user1 = new User
                {
                    FirstName   = "Alice",
                    LastName    = "Smith",
                    DateOfBirth = new DateTime(1980, 12, 8)
                };
                User user2 = new User
                {
                    FirstName   = "Alice",
                    LastName    = "Cooper",
                    DateOfBirth = new DateTime(1960, 5, 14)
                };
                User user3 = new User
                {
                    FirstName   = "John",
                    LastName    = "Smith",
                    DateOfBirth = new DateTime(1991, 5, 28)
                };
                User user4 = new User
                {
                    FirstName   = "John",
                    LastName    = "Lennon",
                    DateOfBirth = new DateTime(1980, 12, 8)
                };

                UserService userService = new UserService(IdGenerator);
                Master      master      = new Master(userService);
                MasterDomain();
                List <Slave> slaves = new List <Slave>();

                for (int i = 0; i < SlavesNumber; i++)
                {
                    slaves.Add(new Slave());
                    slaves[i].Subscribe(master);
                    SlaveDomain("SlaveDomain" + i);
                }

                master.Add(user1);
                master.Add(user2);
                master.Add(user3);
                master.Add(user4);

                master.Remove(user4);

                //var serviceMaster = new UserService(IdGenerator);
                //var service2 = new UserService(IdGenerator);

                //service1.Add(user1);
                //service2.Add(user2);
                //service1.Add(user3);
                //service2.Add(user4);

                //service.Remove(user4);

                //Predicate<User> predicate1 = u => u.LastName == user1.LastName;
                //var search1 = service.Search(predicate1);

                //Predicate<User> predicate2 = u => u.FirstName == user1.FirstName;
                //var search2 = service.Search(predicate2);

                //service.Serialize();

                Console.WriteLine("\nPress any key to continue...");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }