Exemplo n.º 1
0
        public bool Remove(int id)
        {
            var   awards = this.GetAll().ToList();
            Award award  = awards.FirstOrDefault(a => a.Id == id);

            if (award == null)
            {
                return(false);
            }

            var newUserAwards = new List <string>();

            string line = string.Empty;

            if (File.Exists(UserAwardsFilePath))
            {
                using (var reader = new StreamReader(UserAwardsFilePath))
                {
                    while (!reader.EndOfStream)
                    {
                        line = reader.ReadLine();

                        line = line.Replace($"{id}{AwardsSeparator}", string.Empty);

                        newUserAwards.Add(line);
                    }
                }
            }

            awards.Remove(award);
            ImageDao.RemoveAwardImage(award.Id, ImageFolder);

            File.WriteAllLines(UserAwardsFilePath, newUserAwards);
            File.WriteAllLines(AwardsFilePath, awards.Select(AwardAsTxt));

            return(true);
        }
Exemplo n.º 2
0
 public bool RemoveImage(int id)
 {
     return(ImageDao.RemoveAwardImage(id, ImageFolder));
 }
Exemplo n.º 3
0
 public void AddImage(int id, byte[] image)
 {
     ImageDao.AddAwardImage(id, image, ImageFolder);
 }