Ejemplo n.º 1
0
        private void Save()
        {
            string message = "";

            try
            {
                var validator = NinjectBinder.GetValidator <TimeZoneViewModelValidator>();
                var results   = validator.Validate(this);
                if (!results.IsValid)
                {
                    message = string.Join("\n", results.Errors);
                    SendMessage(message);
                    return;
                }

                CurrentTimeZone.TimeZoneName          = Name;
                CurrentTimeZone.TimeZoneCode          = Code;
                CurrentTimeZone.Status                = GeneralStatus.Enabled;
                CurrentTimeZone.TimeGroupAssociations = GetTimeGroupAssociations();

                if (CurrentTimeZone.TimeZoneID == 0)
                {
                    CurrentTimeZone.CreateUserID = ApplicationManager.GetInstance().CurrentOperatorInfo.OperatorID;
                    CurrentTimeZone.CreateDate   = DateTime.Now;
                    CurrentTimeZone = _timeZoneRepo.Insert(CurrentTimeZone);
                    message         = "增加时间区成功!";
                }
                else
                {
                    CurrentTimeZone.UpdateUserID = ApplicationManager.GetInstance().CurrentOperatorInfo.OperatorID;
                    CurrentTimeZone.UpdateDate   = DateTime.Now;
                    _timeZoneRepo.Update(CurrentTimeZone);
                    message = "修改时间区成功!";
                }
            }
            catch (BusinessException ex)
            {
                Log.Error("Update timezone fails.", ex);
                SendMessage(ex.Message);
                return;
            }
            catch (Exception ex)
            {
                Log.Error("Update timezone fails.", ex);
                message = "保存时间区失败";
                SendMessage(message);
                return;
            }

            ViewModelAttachment.CoreModel            = CurrentTimeZone;
            ViewModelAttachment.LastOperationSuccess = true;
            RaisePropertyChanged(null);
            Close(message);
        }
Ejemplo n.º 2
0
 public void Load(ITimeZoneRepository timeZoneRepository, IDaylightSavingsAdjustmentRepository daylightSavingsAdjustmentRepository)
 {
     string[] supportedIanaIds = _tzMapper.GetAvailableTZIDs();
     foreach (DbTimeZone timeZone in timeZoneRepository.GetAll())
     {
         if (supportedIanaIds.Any(ianaId => ianaId == timeZone.IanaId))
         {
             TimeZoneInfo timeZoneInfo = _tzMapper.MapTZID(timeZone.IanaId);
             string       microsoftId  = timeZoneInfo.Id;
             timeZone.UpdateMicrosoftId(microsoftId);
             timeZoneRepository.Update(timeZone);
         }
     }
 }
Ejemplo n.º 3
0
 void ITimeZoneService.Update(TimeZone timeZone)
 {
     _repository.Update(timeZone);
 }