Example #1
0
        public ActionResult Add(ExchangeServiceModel model)
        {
            if (model == null)
            {
                return(RedirectToAction("Add", new { msg = "提交的数据为空,请重新提交" }));
            }

            ExchangeService es = new ExchangeService();

            es.Id          = Guid.NewGuid();
            es.ImagePath   = model.ImagePath;
            es.IsDeleted   = false;
            es.Name        = model.Name;
            es.Notes       = model.Notes;
            es.Price       = model.Price;
            es.Code        = "ExchangeService_" + TimeManager.GetCurrentTimestamp();
            es.CreatedTime = DateTime.Now;
            es.DeletedTime = DateTime.MinValue.AddHours(8);
            es.Credit      = model.Credit;

            if (_exchangeServiceBLL.Add(es))
            {
                return(RedirectToAction("Add", new { msg = "添加成功" }));
            }
            else
            {
                return(RedirectToAction("Add", new { msg = "添加失败" }));
            }
        }
        public void ExchangeServiceModel_Validate_RetrieveSources()
        {
            var guid = Guid.NewGuid();

            var mockServer = new Mock <IServer>();

            mockServer.Setup(server => server.EnvironmentID).Returns(guid);

            var mockQueryManager   = new Mock <IQueryManager>();
            var mockExchangeSource = new Mock <IExchangeSource>().Object;
            var exchangeSources    = new List <IExchangeSource> {
                mockExchangeSource
            };

            mockQueryManager.Setup(query => query.FetchExchangeSources()).Returns(exchangeSources);

            mockServer.Setup(server => server.QueryProxy).Returns(mockQueryManager.Object);

            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(shell => shell.SetActiveServer(guid));

            var exchangeServiceModel = new ExchangeServiceModel(mockServer.Object, mockShellViewModel.Object);

            mockShellViewModel.Verify(model => model.SetActiveServer(guid), Times.Once());

            var sources = exchangeServiceModel.RetrieveSources();

            Assert.AreEqual(mockExchangeSource, sources[0]);
            mockQueryManager.Verify(model => model.FetchExchangeSources(), Times.Once());
        }
Example #3
0
        public ActionResult Update(ExchangeServiceModel model)
        {
            if (model == null)
            {
                return(RedirectToAction("List", new { msg = "更新失败" }));
            }

            ExchangeService es = _exchangeServiceBLL.GetNoDeletedExchangeServiceByCode(model.Code);

            es.Credit    = model.Credit;
            es.ImagePath = model.ImagePath;
            es.Name      = model.Name;
            es.Notes     = model.Notes;
            es.Price     = model.Price;
            es.Credit    = model.Credit;

            if (_exchangeServiceBLL.Update(es))
            {
                return(RedirectToAction("List", new { msg = "更新成功" }));
            }
            else
            {
                return(RedirectToAction("List", new { msg = "更新失败" }));
            }
        }
Example #4
0
        public ActionResult ConsumeExchangeService(Guid esrId)
        {
            if (esrId == null)
            {
                return(RedirectToAction("Error"));
            }
            ExchangeServiceRecord esr = _exchangeServiceRecordBLL.GetESRById(esrId);
            ExchangeServiceModel  esm = new ExchangeServiceModel();

            esm.MemberName          = _memberBLL.GetMemberById(esr.MemberId).NickeName;
            esm.ExchangeServiceId   = esr.Id;
            esm.ExchangeServiceName = _exchangeServiceBLL.GetNoDeletedExchangeServiceById(esr.ExchangeSerivceId).Name;

            return(View(esm));
        }
        public void ExchangeServiceModel_Validate_CreateNewSource()
        {
            var guid = Guid.NewGuid();

            var mockServer = new Mock <IServer>();

            mockServer.Setup(server => server.EnvironmentID).Returns(guid);

            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(shell => shell.SetActiveServer(guid));
            mockShellViewModel.Setup(shell => shell.NewExchangeSource(string.Empty));

            var exchangeServiceModel = new ExchangeServiceModel(mockServer.Object, mockShellViewModel.Object);

            mockShellViewModel.Verify(model => model.SetActiveServer(guid), Times.Once());

            exchangeServiceModel.CreateNewSource();
            mockShellViewModel.Verify(model => model.NewExchangeSource(string.Empty), Times.Once());
        }
        public void ExchangeServiceModel_Validate_UpdateRepository()
        {
            var guid = Guid.NewGuid();

            var mockStudioUpdateManager = new Mock <IStudioUpdateManager>().Object;

            var mockServer = new Mock <IServer>();

            mockServer.Setup(server => server.EnvironmentID).Returns(guid);
            mockServer.Setup(server => server.UpdateRepository).Returns(mockStudioUpdateManager);

            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(shell => shell.SetActiveServer(guid));

            var exchangeServiceModel = new ExchangeServiceModel(mockServer.Object, mockShellViewModel.Object);

            mockShellViewModel.Verify(model => model.SetActiveServer(guid), Times.Once());

            Assert.AreEqual(mockStudioUpdateManager, exchangeServiceModel.UpdateRepository);
        }
        public void ExchangeServiceModel_Validate_EditSource()
        {
            var guid = Guid.NewGuid();

            var mockServer = new Mock <IServer>();

            mockServer.Setup(server => server.EnvironmentID).Returns(guid);

            var mockExchangeSource = new Mock <IExchangeSource>().Object;

            var mockShellViewModel = new Mock <IShellViewModel>();

            mockShellViewModel.Setup(shell => shell.SetActiveServer(guid));
            mockShellViewModel.Setup(shell => shell.EditResource(mockExchangeSource));

            var exchangeServiceModel = new ExchangeServiceModel(mockServer.Object, mockShellViewModel.Object);

            mockShellViewModel.Verify(model => model.SetActiveServer(guid), Times.Once());

            exchangeServiceModel.EditSource(mockExchangeSource);
            mockShellViewModel.Verify(model => model.EditResource(mockExchangeSource), Times.Once());
        }
        public ExchangeNewEmailDesignerViewModel(ModelItem modelItem, IAsyncWorker asyncWorker, IServer server, IEventAggregator eventPublisher, IShellViewModel shellViewModel, IActiveDataList activeDataList)
            : base(modelItem)
        {
            VerifyArgument.IsNotNull("asyncWorker", asyncWorker);
            VerifyArgument.IsNotNull("eventPublisher", eventPublisher);
            _asyncWorker    = asyncWorker;
            _server         = server;
            _eventPublisher = eventPublisher;
            _eventPublisher.Subscribe(this);

            AddTitleBarLargeToggle();

            TestEmailAccountCommand  = new RelayCommand(o => TestEmailAccount(), o => CanTestEmailAccount);
            ChooseAttachmentsCommand = new DelegateCommand(o => ChooseAttachments());

            _shellViewModel = shellViewModel;
            _activeDataList = activeDataList;
            var model = new ExchangeServiceModel(_server, _shellViewModel);

            Model = model;
            SetupCommonProperties();
            HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_Email_Exchange_Send;
        }