Exemplo n.º 1
0
        public void ServiceDeskService_Create_CallInsertServiceDeskAndCallsSaveChanges()
        {
            #region Arrange

            var dateTimeNow = DateTime.Now;

            var serviceDesk = new ServiceDesk
            {
                Id           = 3,
                DeskName     = "A New ServiceDesk MJJ",
                CustomerId   = 1,
                InsertedBy   = UserNameOne,
                InsertedDate = dateTimeNow,
                UpdatedBy    = UserNameOne,
                UpdatedDate  = dateTimeNow,
            };

            #endregion

            #region Act

            var response = _serviceDeskService.Create(serviceDesk);

            #endregion

            #region Assert

            _mockServiceDeskRepository.Verify(x => x.Insert(It.IsAny <ServiceDesk>()), Times.Once());
            _mockUnitOfWork.Verify(x => x.Save(), Times.Exactly(1));

            Assert.IsNotNull(response);
            Assert.AreEqual(3, response);

            #endregion
        }
Exemplo n.º 2
0
        public ActionResult Add(string level, string deskName, int[] deskInputTypes)
        {
            if (_appUserContext.Current.CurrentCustomer == null || _appUserContext.Current.CurrentCustomer.Id <= 0)
            {
                // No context
                return(RedirectToAction("Index", "ServiceDesk", new { level = level }));
            }

            // Create Service Desk
            var serviceDesk = new ServiceDesk();
            var now         = DateTime.Now;
            var user        = _contextManager.UserManager.Name;

            serviceDesk.CustomerId     = _appUserContext.Current.CurrentCustomer.Id;
            serviceDesk.DeskName       = deskName;
            serviceDesk.DeskInputTypes = new List <DeskInputType>();

            if (deskInputTypes != null && deskInputTypes.Length > 0)
            {
                // Add Desk Input Types
                foreach (var deskInputTypeId in deskInputTypes)
                {
                    serviceDesk.DeskInputTypes.Add(new DeskInputType
                    {
                        InputTypeRefData = _inputTypeRefDataService.GetById(deskInputTypeId)
                    });
                }
            }

            serviceDesk.InsertedBy   = user;
            serviceDesk.InsertedDate = now;
            serviceDesk.UpdatedBy    = user;
            serviceDesk.UpdatedDate  = now;

            _serviceDeskService.Create(serviceDesk);

            return(RedirectToAction("Index", "ServiceDesk", new { level = level }));
        }