Example #1
0
        public bool DeleteWarrior(int id)
        {
            try
            {
                WarriorRepository.Delete(id);

                var warriors = GetAllWarriors();
                if (warriors.Count == 0)
                {
                    ClearSchedule();
                }
                else
                {
                    var deletedWarrior = GetWarriorById(id);
                    warriors.Add(deletedWarrior);
                    warriors = warriors.OrderBy(w => w.Name).ToList();
                    ScheduleRepository.ArrangeSchedule(deletedWarrior, warriors);
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #2
0
 public List <WarriorSpecies> GetWarriorSpecies()
 {
     try
     {
         var entities = WarriorRepository.GetSpecies();
         return(entities);
     }
     catch
     {
         return(new List <WarriorSpecies>());
     }
 }
Example #3
0
 public Warrior GetWarriorById(int id)
 {
     try
     {
         var entity = WarriorRepository.GetById(id);
         return(entity);
     }
     catch
     {
         return(null);
     }
 }
Example #4
0
 public List <Warrior> GetAllWarriors()
 {
     try
     {
         var entities = WarriorRepository.GetAll();
         return(entities);
     }
     catch
     {
         return(new List <Warrior>());
     }
 }
Example #5
0
 public bool AssignAdditionalDay(int id)
 {
     try
     {
         var warrior = WarriorRepository.GetById(id);
         ScheduleRepository.AssignAdditionalDay(warrior);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Example #6
0
        public bool CreateWarrior(Warrior warrior)
        {
            try
            {
                int id = WarriorRepository.Create(warrior);
                warrior.Id = id;
                var warriors = GetAllWarriors();
                ScheduleRepository.ArrangeSchedule(warrior, warriors);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #7
0
        private static void DoWork()
        {
            try
            {
                var time = DateTime.Now.TimeOfDay;
                if (time.Hours == 15 && time.Minutes == 0)
                {
                    var warriorRepo  = new WarriorRepository();
                    var scheduleRepo = new ScheduleRepository();

                    var warriorName = scheduleRepo.GetResponsibleWarriorName();
                    var mails       = warriorRepo.GetEmails();
                    if (mails.Count > 0)
                    {
                        EmailService.SendMail(warriorName, mails);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"An exception occurred (ex:'{ex.Message}')");
                return;
            }
        }
Example #8
0
 public WebService()
 {
     WarriorRepository  = new WarriorRepository();
     ScheduleRepository = new ScheduleRepository();
 }