/// <summary>
        /// Method for adding range of users
        /// </summary>
        /// <param name="list">list of users</param>
        /// <returns>list of id</returns>
        public IEnumerable <int> AddRange(List <UserDataContract> list)
        {
            var range = new List <User>();

            foreach (var user in list)
            {
                if (user.DateOfBirth == null)
                {
                    throw new ArgumentNullException();
                }

                range.Add(Mapper.UserContractToUser(user));
            }

            return(master.AddRange(range));
        }
        private void MetadataMerger_DragDrop(object sender, DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                return;
            }

            string[] filenames = e.Data.GetData(DataFormats.FileDrop) as string[];
            if (filenames.Length > 1 && Master == null)
            {
                MessageBox.Show("The first file must be dragged in by itself.");
                return;
            }

            foreach (string f in filenames)
            {
                FileInfo file = new FileInfo(f);
                if (file.Extension.ToLower() == ".lnk")
                {
                    file = new FileInfo(WindowsShell.Shortcut.Resolve(f));
                }

                if (!new List <string> {
                    ".xml", ".synthesia"
                }.Contains(file.Extension.ToLower()))
                {
                    Log($"SKIPPING file with unknown extension: {file.Name}");
                    continue;
                }

                RawMetadataFile metadata = new RawMetadataFile(file);
                if (Master == null)
                {
                    Master = metadata;
                    Log($"Setting \"{file.Name}\" as master ({metadata.Statistics})");
                }
                else
                {
                    Log($"Adding contents of \"{file.Name}\" to master ({metadata.Statistics})");
                    if (Master.AddRange(metadata, Log))
                    {
                        Dirty = true;
                    }
                }
            }
        }
Exemple #3
0
 public virtual bool AddRange(List <T> list)
 {
     Master.AddRange(list);
     return(Master.SaveChanges() > 0);
 }
Exemple #4
0
 public void AddRange(IEnumerable <UserDataContract> collection)
 => master.AddRange(collection.Select(u => u.ToUser()));