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); } }
public List <WarriorSpecies> GetWarriorSpecies() { try { var entities = WarriorRepository.GetSpecies(); return(entities); } catch { return(new List <WarriorSpecies>()); } }
public Warrior GetWarriorById(int id) { try { var entity = WarriorRepository.GetById(id); return(entity); } catch { return(null); } }
public List <Warrior> GetAllWarriors() { try { var entities = WarriorRepository.GetAll(); return(entities); } catch { return(new List <Warrior>()); } }
public bool AssignAdditionalDay(int id) { try { var warrior = WarriorRepository.GetById(id); ScheduleRepository.AssignAdditionalDay(warrior); return(true); } catch { return(false); } }
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); } }
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; } }
public WebService() { WarriorRepository = new WarriorRepository(); ScheduleRepository = new ScheduleRepository(); }