コード例 #1
0
 private HourCode FindDuplicateOf(HourCode hourCode)
 {
     return HourCodes
         .FirstOrDefault(code =>
             code.Code.Equals(hourCode.Code) &&
             code.Name.Equals(hourCode.Name));
 }
コード例 #2
0
        public void Should()
        {
            var hourCode = new HourCode();
            var hourUsage = new HourUsage();
            hourUsage.SetHourCode(hourCode);

            Assert.That(hourUsage.HourCode, Is.EqualTo(hourCode));
            Assert.That(hourCode.Usages, Contains.Item(hourUsage));
        }
コード例 #3
0
        public HourCode AddHourCode(string code, string name)
        {
            if (string.IsNullOrWhiteSpace(code) || string.IsNullOrWhiteSpace(name))
            {
                throw new HourGlassUserException(ExceptionType.InvalidHourCode, code, name);
            }

            var hourCode = new HourCode {Code = code.Trim(), Name = name.Trim()};
            var duplicate = FindDuplicateOf(hourCode);
            if (duplicate != null)
            {
                return duplicate;
            }

            _repo.Save(hourCode);
            HourCodes.Add(hourCode);
            return hourCode;
        }
コード例 #4
0
 public HourCode Save(HourCode hourCode)
 {
     return _repo.Save(hourCode);
 }
コード例 #5
0
 public HourCode Remove(HourCode hourCode)
 {
     HourCodes.Remove(hourCode);
     return _repo.Delete(hourCode);
 }
コード例 #6
0
 public HourCodeViewModel(IHourCodeProvider hourCodeProvider, HourCode hourCode)
 {
     HourCode = hourCode;
     _hourCodeProvider = hourCodeProvider;
     SaveCommand = new DelegateCommand(Save);
 }