Ejemplo n.º 1
0
 internal void HandleAddSkillCommand(SkillViewModel parameter)
 {
     if (parameter != null &&
         !String.IsNullOrEmpty(parameter.SkillName) &&
         !personalSkillset.Any(x => (x.SkillName == parameter.SkillName)))
     {
         personalSkillset.Add(parameter);
         this.NewSkill = new SkillViewModel();
         DataPersister.AddSkill(personalSkillestFilename, parameter);
     }
 }
Ejemplo n.º 2
0
        //Update
        //public static async Task<IEnumerable<JobViewModel>> UpdateJobs(string fileName)
        //{
        //    var jobOffersDocumentRoot = await GetXmlDocFromFile(fileName);

        //    var jobsVMs =
        //                   from jobElement in jobOffersDocumentRoot.Elements("job")
        //                   select new JobViewModel()
        //                   {
        //                       JobID = jobElement.Element("jobid").Value,
        //                       JobTitle = jobElement.Element("jobtitle").Value,
        //                       JobDescription = (jobElement.Element("jobdescription").Value),
        //                       JobDate = (jobElement.Element("jobdate").Value),
        //                       JobCity = (jobElement.Element("jobcity").Value),
        //                       Company = new CompanyViewModel()
        //                       {
        //                           CompanyID = jobElement.Element("company").Element("companyid").Value,
        //                           CompanyName = jobElement.Element("company").Element("companyname").Value,
        //                           CompanyLogoURL = jobElement.Element("company").Element("companylogourl").Value,
        //                       }
        //                   };
        //    return jobsVMs;
        //}



        //Add / Remove

        internal static async void AddSkill(string fileName, SkillViewModel skill)
        {
            var file = await GetFileFromFileName(fileName);

            using (var readStream = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                var xmldoc = XDocument.Load(readStream.AsStreamForRead());

                var root = xmldoc.Root;
                root.Add(new XElement("skill",
                                      new XElement("skillname", skill.SkillName),
                                      new XElement("skillcolorname", skill.SkillColorName)
                                      ));
                //await readStream.FlushAsync();
                readStream.Size = 0;
                readStream.Seek(0);
                root.Document.Save(readStream.AsStreamForWrite());
                //root.Document.Save(readStream.AsStreamForWrite());
            }
        }
Ejemplo n.º 3
0
        //Update
        //public static async Task<IEnumerable<JobViewModel>> UpdateJobs(string fileName)
        //{
        //    var jobOffersDocumentRoot = await GetXmlDocFromFile(fileName);

        //    var jobsVMs =
        //                   from jobElement in jobOffersDocumentRoot.Elements("job")
        //                   select new JobViewModel()
        //                   {
        //                       JobID = jobElement.Element("jobid").Value,
        //                       JobTitle = jobElement.Element("jobtitle").Value,
        //                       JobDescription = (jobElement.Element("jobdescription").Value),
        //                       JobDate = (jobElement.Element("jobdate").Value),
        //                       JobCity = (jobElement.Element("jobcity").Value),
        //                       Company = new CompanyViewModel()
        //                       {
        //                           CompanyID = jobElement.Element("company").Element("companyid").Value,
        //                           CompanyName = jobElement.Element("company").Element("companyname").Value,
        //                           CompanyLogoURL = jobElement.Element("company").Element("companylogourl").Value,
        //                       }
        //                   };
        //    return jobsVMs;
        //}



        //Add / Remove
 
        internal static async void AddSkill(string fileName, SkillViewModel skill)
        {
            var file = await GetFileFromFileName(fileName);

            using (var readStream = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                var xmldoc = XDocument.Load(readStream.AsStreamForRead());

                var root = xmldoc.Root;
                root.Add(new XElement("skill",
                   new XElement("skillname", skill.SkillName),
                   new XElement("skillcolorname", skill.SkillColorName)
                   ));
                //await readStream.FlushAsync();
                readStream.Size = 0;
                readStream.Seek(0);
                root.Document.Save(readStream.AsStreamForWrite());
                //root.Document.Save(readStream.AsStreamForWrite());
            }

        }