示例#1
0
        /// <summary>
        /// Creates a closeout
        /// </summary>
        /// <param name="closeout">Close out</param>
        public void CreateCloseout(Closeout closeout)
        {
            // Validate input
            if (closeout.IsValid())
            {
                // Retrieve room details
                Model.Room.Room room = roomDao.GetByKey(closeout.RoomId, closeout.BusinessId);

                if (room == null)
                {
                    throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30016,
                                                                                 "CloseoutManager.CreateCloseout",
                                                                                 additionalDescriptionParameters:
                                                                                     (new object[] {closeout.RoomId})));
                }

                // Check if the room is active.
                if (room.RoomStatus.Code != RoomStatusCodes.ACTIVE)
                {
                    throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30015,
                                                                                 "CloseoutManager.CreateCloseout",
                                                                                 arguments: new object[] {this}));
                }

                // Create closeout
                closeoutDao.Create(closeout);
            }
        }
示例#2
0
            public void CreateCloseoutValidBusinessSuccess()
            {
                // Arrange
                var mockCloseoutDao = MockRepository.GenerateMock<ICloseoutDao>();
                var stubRoomDao = MockRepository.GenerateStub<IRoomDao>();

                Closeout closeout = new Closeout()
                                        {
                                            BusinessId = 1,
                                            RoomId = 1,
                                            StartDate = DateTime.UtcNow,
                                            EndDate = DateTime.UtcNow.AddDays(1),
                                            Description = "Test Closeout",
                                            CloseoutReasonId = 1
                                        };
                mockCloseoutDao.Expect(x => x.Create(closeout)).WhenCalled(delegate { closeout.Id = 1; });
                closeoutManager.CloseoutDao = mockCloseoutDao;

                Room room = new Room()
                                {
                                    Id = 1,
                                    BusinessId = 1,
                                    IsCombined = false,
                                    RoomStatus = new RoomStatus { Code = RoomStatusCodes.ACTIVE } 
                                };
                stubRoomDao.Stub(r => r.GetByKey(1, 1)).Return(room);
                closeoutManager.RoomDao = stubRoomDao;

                // Act
                closeoutManager.CreateCloseout(closeout);

                // Assert
                Assert.IsNotNull(closeout.Id, "Id attribute is not populated.");
                mockCloseoutDao.VerifyAllExpectations();
            }
示例#3
0
 /// <summary>
 /// Map the basic fields for the Closeout table to the Closeout model object
 /// </summary>
 /// <param name="record">The SqlDataReader with the executed query result</param>
 /// <param name="prefix">a prefix used to identify fields for the Closeout model  in the resultset if required</param>        
 /// <returns>An instance of Model.Booking.Closeout</returns>
 internal static Closeout MapRecord(IDataRecord record, string prefix = "")
 {
     var closeout = new Closeout
     {
         Id = DbHelper.ConvertValue<int>(record[prefix + Parameters.Id]),
         BusinessId = DbHelper.ConvertValue<long>(record[prefix + Parameters.BusinessId]),
         RoomId = DbHelper.ConvertValue<int>(record[prefix + Parameters.RoomId]),
         StartDate = DbHelper.ConvertValue<DateTime>(record[prefix + Parameters.StartDate], true),
         EndDate = DbHelper.ConvertValue<DateTime>(record[prefix + Parameters.EndDate], true),
         Description = DbHelper.ConvertValue<string>(record[prefix + Parameters.Description]),
         IsDeleted = DbHelper.ConvertValue<bool>(record[prefix + Parameters.IsDeleted]),
         CloseoutReasonId = DbHelper.ConvertValue<int>(record[prefix + Parameters.CloseoutReasonId])
     };
     
     return AuditFieldsHelper.MapRecord(closeout, record, prefix);
 }
示例#4
0
        /// <summary>
        /// Create Closeout
        /// </summary>
        /// <param name="closeout">Closeout to insert</param>
        public void Create(Closeout closeout)
        {
            const string QUERY = @"INSERT INTO Booking.Closeout(BusinessId, RoomId, StartDate, EndDate, Description, CloseoutReasonId, UpdatedByUserId)
                                 VALUES(@BusinessId,@RoomId,@StartDate,@EndDate,@Description,@CloseoutReasonId,@UpdatedByUserId)
                                SELECT SCOPE_IDENTITY()";

            var parameters = new List<SqlParameter>
                {
                    DbHelper.CreateParameter(CloseoutMapper.Parameters.BusinessId, closeout.BusinessId),
                    DbHelper.CreateParameter(CloseoutMapper.Parameters.RoomId, closeout.RoomId),
                    DbHelper.CreateParameter(CloseoutMapper.Parameters.StartDate, closeout.StartDate),
                    DbHelper.CreateParameter(CloseoutMapper.Parameters.EndDate, closeout.EndDate),
                    DbHelper.CreateParameter(CloseoutMapper.Parameters.Description, closeout.Description),
                    DbHelper.CreateParameter(CloseoutMapper.Parameters.CloseoutReasonId, closeout.CloseoutReasonId)
                };

            AuditFieldsHelper.PopulateAuditFields(parameters);

            closeout.Id = DbHelper.ExecuteScalar<int>(QUERY, parameters: parameters);

            CreateCloseoutEvent(closeout.Id.Value);
        }
示例#5
0
            public void ModifyNonExistingCloseOutThrowsValidationException()
            {
                // Arrange
                ICloseoutDao closeoutDao = MockRepository.GenerateMock<ICloseoutDao>();
                closeoutManager = new CloseoutManager();
                closeoutManager.CloseoutDao = closeoutDao;
                closeoutDao.Expect(c => c.GetByKey(1, 1)).Return(null);
                
                // CloseOut Record
                Closeout updatecloseOut = new Closeout()
                {
                    Id = 1,
                    BusinessId = 1,
                    RoomId = 1,
                    StartDate = new DateTime(2020, 5, 3, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2020, 5, 4, 0, 0, 0, DateTimeKind.Utc),
                    Description = "Updated",
                    CloseoutReasonId = 1
                };

                closeoutDao.Stub(x => x.Modify(updatecloseOut));
                try
                {
                   
                    //Act
                    // Modify closeOut Record
                    closeoutManager.Modify(updatecloseOut);
                    Assert.Fail("And exception SRVEX30024 of type ValidationException should have been thrown");
                }
                catch(ValidationException ex)
                {
                    //Assert
                    Assert.AreEqual("SRVEX30024", ex.Code, "The Validation exception SRVEX30024 is not returned");
                }
            }
示例#6
0
            public void ModifyCloseoutWithCorrectInfoIsSuccessful()
            {
                // Arrange
                ICloseoutDao closeoutDao = MockRepository.GenerateMock<ICloseoutDao>();
                closeoutManager = new CloseoutManager();
                closeoutManager.CloseoutDao = closeoutDao;
                closeoutDao.Expect(c => c.GetByKey(1, 1)).Return(new Closeout()
                {
                    Id=1,
                    BusinessId = 1,
                    RoomId = 1,
                    StartDate = new DateTime(2020, 5, 1, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2020, 5, 2, 0, 0, 0, DateTimeKind.Utc),
                    CloseoutReasonId = 1
                });
                // CloseOut Record
                Closeout updatecloseOut = new Closeout() 
                { 
                    Id = 1, 
                    BusinessId = 1, 
                    RoomId = 1, 
                    StartDate = new DateTime(2020, 5, 3, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2020, 5, 4, 0, 0, 0, DateTimeKind.Utc),
                    Description = "",
                    CloseoutReasonId = 1
                };
                
                closeoutDao.Expect(x => x.Modify(updatecloseOut));
                
                // Act
                // Modify closeOut Record
                closeoutManager.Modify(updatecloseOut);

                // Assert
                closeoutDao.VerifyAllExpectations();
            }
示例#7
0
            public void CreateWithAdditionalData()
            {
                using (new TestDataHelper(GetTestQuery(TestQueryLimited.PopulateCreateCloseoutTestData), GetTestQuery(TestQuery.CleanupUnitTestData)))
                {
                    // Arrange
                    const long BUSINESS_ID = 1;
                    const int ROOM_ID = 1;
                    const int CLOSEOUTREASON_ID = 1;

                    // Create Closeout entity with description
                    var closeout = new Closeout
                    {
                        BusinessId = BUSINESS_ID,
                        RoomId = ROOM_ID,
                        StartDate = DateTime.UtcNow,
                        EndDate = DateTime.UtcNow.AddDays(1),
                        Description = "Test Closeout",
                        CloseoutReasonId = CLOSEOUTREASON_ID
                    };

                    // Act
                    closeoutDao.Create(closeout);

                    // Assert
                    Assert.IsNotNull(closeout.Id, "Id attribute is not populated.");
                }
            }
示例#8
0
            public void CreateWithMinimumData()
            {
                using (new TestDataHelper(GetTestQuery(TestQueryLimited.PopulateCreateCloseoutTestData), GetTestQuery(TestQuery.CleanupUnitTestData)))
                {
                    // Arrange
                    const long BUSINESS_ID = 1;
                    const int ROOM_ID = 1;
                    const int CLOSEOUTREASON_ID = 1;

                    // Create Closeout entity
                    var closeout = new Closeout
                    {
                        BusinessId = BUSINESS_ID,
                        RoomId = ROOM_ID,
                        StartDate = DateTime.UtcNow,
                        EndDate = DateTime.UtcNow.AddDays(1),
                        CloseoutReasonId = CLOSEOUTREASON_ID
                    };

                    // Act
                    closeoutDao.Create(closeout);

                    // Assert
                    Assert.IsNotNull(closeout.Id, "Id attribute is not populated.");

                    // Check if the closeout event details have been created
                    Closeout createdCloseOut = closeoutDao.GetByKey(closeout.Id.Value, BUSINESS_ID);

                    Assert.AreEqual(TEST_USER_ID, createdCloseOut.CreatedByUserId, "The CloseoutEvent CreatedByUserId was not updated correctly");
                }
            }
示例#9
0
            public void ModifyExistingCloseoutWithInvalidCloseoutReasonIdThrowsValidationException()
            {
                // Arrange
                // CloseOut Record
                Closeout updatecloseOut = new Closeout()
                {
                    Id = 1,
                    BusinessId = 1,
                    RoomId = 1,
                    StartDate = new DateTime(2020, 5, 3, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2020, 5, 4, 0, 0, 0, DateTimeKind.Utc),
                    Description = "Updated"
                };

                try
                {
                    //Act
                    // Modify closeOut Record
                    closeoutManager.Modify(updatecloseOut);

                    Assert.Fail("This SRVEX30044 Exception should be thrown ");
                }
                catch (ValidationException ex)
                {
                    //Assert
                    Assert.AreEqual("SRVEX30044", ex.Code, "The Validation exception SRVEX30044 is not being returned");
                }
            }
示例#10
0
            public void CreateCloseoutNonExistingRoomThrowsValidationException()
            {
                // Arrange
                var stubRoomDao = MockRepository.GenerateStub<IRoomDao>();

                stubRoomDao.Stub(r => r.GetByKey(1, 1)).Return(null);
                closeoutManager.RoomDao = stubRoomDao;

                Closeout closeout = new Closeout()
                                        {
                                            BusinessId = 1,
                                            RoomId = 1,
                                            StartDate = DateTime.UtcNow,
                                            EndDate = DateTime.UtcNow.AddDays(1),
                                            Description = "Test Closeout",
                                            CloseoutReasonId = 1
                                        };

                try
                {
                    // Act
                    closeoutManager.CreateCloseout(closeout);

                    // Assert
                    Assert.Fail("An exception SRVEX30016 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30016", ex.Code, "The Validation exception is not returning the right error code");
                }
            }
示例#11
0
        /// <summary>
        /// Create block room using test schema
        /// </summary>
        /// <param name="userId">user to create under</param>
        /// <param name="closeout"></param>
        /// <returns></returns>
        public static bool CreateBlockRoom(Guid userId, Closeout closeout)
        {
            var sbSqlStatement = new StringBuilder();
            sbSqlStatement.Append("INSERT INTO Booking.Closeout");
            sbSqlStatement.Append("(");
            sbSqlStatement.Append("     BusinessId,");
            sbSqlStatement.Append("     RoomId,");
            sbSqlStatement.Append("     StartDate,");
            sbSqlStatement.Append("     EndDate,");
            sbSqlStatement.Append("     Description,");
            sbSqlStatement.Append("     CloseoutReasonId,");
            sbSqlStatement.Append("     UpdatedByUserId");
            sbSqlStatement.Append(")");
            sbSqlStatement.Append("VALUES");
            sbSqlStatement.Append("(");
            sbSqlStatement.AppendFormat("     @{0},", BookingMapper.BUSINESSID);
            sbSqlStatement.AppendFormat("     @{0},", BookingMapper.ROOMID);
            sbSqlStatement.AppendFormat("     @{0},", BookingMapper.STARTDATE);
            sbSqlStatement.AppendFormat("     @{0},", BookingMapper.ENDDATE);
            sbSqlStatement.AppendFormat("     @{0},", DESCRIPTION);
            sbSqlStatement.AppendFormat("     @{0},", CLOSEOUTREASONID);
            sbSqlStatement.AppendFormat("     @{0}", AuditFieldsHelper.UPDATEDBYUSERID);
            sbSqlStatement.Append(") ");
            sbSqlStatement.Append("SELECT SCOPE_IDENTITY()");

            var parameters = new List<SqlParameter>
                {
                    DbHelper.CreateParameter(BookingMapper.BUSINESSID, closeout.BusinessId),
                    DbHelper.CreateParameter(BookingMapper.ROOMID, closeout.RoomId),
                    DbHelper.CreateParameter(BookingMapper.STARTDATE, closeout.StartDate),
                    DbHelper.CreateParameter(BookingMapper.ENDDATE, closeout.EndDate),
                    DbHelper.CreateParameter(DESCRIPTION, closeout.Description),
                    DbHelper.CreateParameter(CLOSEOUTREASONID, closeout.CloseoutReasonId),
                    DbHelper.CreateParameter(UPDATED_BY_USERID, userId)
                };

            closeout.Id = DbHelper.ExecuteScalar<int>(sbSqlStatement.ToString(), parameters: parameters);

            return SyncAvailability(closeout.BusinessId, closeout.RoomId, closeout.StartDate, closeout.EndDate, userId);
        }
示例#12
0
        /// <summary>
        /// Modify a Closeout
        /// </summary>
        /// <param name="closeout">Closeout object</param>
        public void Modify(Closeout closeout)
        {
            if(closeout.IsValid())
            {
                // Retrieve room details
                Model.Room.Room room = roomDao.GetByKey(closeout.RoomId, closeout.BusinessId);

                if (room == null)
                {
                    throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30016,
                                                                                 "CloseoutManager.Modify",
                                                                                 additionalDescriptionParameters:
                                                                                     (new object[] { closeout.RoomId })));
                }

                // Check if the room is active.
                if (room.RoomStatus.Code != RoomStatusCodes.ACTIVE)
                {
                    throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30015,
                                                                                 "CloseoutManager.Modify",
                                                                                 arguments: new object[] { this }));
                }
                // CurrentCloseOut to compare
                Closeout currentCloseout = closeoutDao.GetByKey(closeout.Id.Value, closeout.BusinessId);
                if(currentCloseout == null)
                {
                    throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30024,
                                                                                 "CloseoutManager.Modify",
                                                                                 additionalDescriptionParameters:
                                                                                     (new object[] { closeout.Id, closeout.BusinessId }),
                                                                                 arguments:
                                                                                     new object[] { closeout.Id, closeout.BusinessId }));
                } 
                
                closeoutDao.Modify(closeout);
 
            }
            
        }
 ///<summary>
 /// Converts Closeout to Dto
 ///</summary>
 ///<param name="closeout">Closeout object to convert</param>
 ///<returns>Closeout Dto</returns>
 public static CloseoutDto ConvertCloseoutToDto(Closeout closeout)
 {
     return new CloseoutDto
     {
         BusinessId = closeout.BusinessId,
         Description = closeout.Description,
         EndDateUTC = closeout.EndDate,
         StartDateUTC = closeout.StartDate,
         Id = closeout.Id,
         RoomId = closeout.RoomId,
         CreatedByUserId = closeout.CreatedByUserId,
         CreatedDateTimeUTC = closeout.CreatedDateTimeUTC
     };
 }
示例#14
0
            public void ModifyExistingCloseoutSetDurationMoreThan365DaysThrowsValidationException()
            {
                // Arrange
                // Closeout Record
                Closeout updatecloseOut = new Closeout() 
                { 
                    Id = 1, 
                    BusinessId = 1,
                    RoomId = 1, 
                    StartDate = new DateTime(2022, 5, 1, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2023, 5, 2, 0, 0, 0, DateTimeKind.Utc),
                    Description = "Updated",
                    CloseoutReasonId = 1
                };
                try
                {
                    //Act
                    // Modify closeout Record
                    closeoutManager.Modify(updatecloseOut);
                    Assert.Fail("This Exception should be thrown SRVEX30029");
                    
                }
                catch (ValidationException ex)
                {
                    //Assert
                    Assert.AreEqual("SRVEX30029", ex.Code, "The Validation exception SRVEX30029 is not being returned");
                }


            }
示例#15
0
            public void CreateCloseoutWithInvalidEndDateThrowsValidationException()
            {
                // Arrange
                Closeout closeout = new Closeout()
                                        {
                                            BusinessId = 1,
                                            RoomId = 1,
                                            StartDate = DateTime.UtcNow,
                                            EndDate = DateTime.MinValue,
                                            Description = "Test Closeout",
                                            CloseoutReasonId = 1
                                        };

                try
                {
                    // Act
                    closeoutManager.CreateCloseout(closeout);

                    // Assert
                    Assert.Fail("An exception SRVEX30002 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30002", ex.Code, "The Validation exception is not returning the right error code");
                }
            }
示例#16
0
            public void ModifyExistingCloseOutNonExistingRoomThrowsValidationException()
            {
                // Arrange
                // CloseOut Record
                Closeout updatecloseOut = new Closeout()
                {
                    Id = 1,
                    BusinessId = 1,
                    RoomId = -999,
                    StartDate = new DateTime(2022, 5, 1, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2022, 5, 2, 0, 0, 0, DateTimeKind.Utc),
                    Description = "Updated",
                    CloseoutReasonId = 1
                };

                try
                {
                    // Act
                    // Modify closeOut Record
                    closeoutManager.Modify(updatecloseOut);
                    Assert.Fail("Validationexception SRVEX30016 should be thrown.");
                
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30016", ex.Code,
                                    "The Validation exception SRVEX30016 should be thrown.");
                    
                }
            }
示例#17
0
            public void CheckCloseoutOf365DaysIsValid()
            {
                // Arrange
                // Stub the CloseoutDao
                var stubCloseoutDao = MockRepository.GenerateStub<ICloseoutDao>();
                var stubRoomDao = MockRepository.GenerateStub<IRoomDao>();
                Room room = new Room { BusinessId = 1, Id = 1, RoomStatus = new RoomStatus { Code = RoomStatusCodes.ACTIVE } };

                // Configure stubs
                closeoutManager.CloseoutDao = stubCloseoutDao;
                closeoutManager.RoomDao = stubRoomDao;
                stubCloseoutDao.Stub(c => c.Create(Arg<Closeout>.Is.Anything)).WhenCalled(x => ((Closeout)x.Arguments[0]).Id = 1);
                stubRoomDao.Stub(r => r.GetByKey(Arg<int>.Is.Anything, Arg<long>.Is.Anything)).Return(room);
                                            
                // Create a 365 day closeout
                Closeout validCloseout = new Closeout()
                                             {
                                                 BusinessId = 1,
                                                 RoomId = 1,
                                                 StartDate = new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc),
                                                 EndDate = new DateTime(2015, 12, 31, 0, 0, 0, DateTimeKind.Utc),
                                                 Description = "Test Closeout",
                                                 CloseoutReasonId = 1
                                             };

                // Act
                closeoutManager.CreateCloseout(validCloseout);

                // Assert
                Assert.IsNotNull(validCloseout.Id, "Check that an id as been assigned to the closeout which would indicate it was created in the db");
            }
示例#18
0
            public void ModifyNonExistingCloseOutThrowsExpectedResultException()
            {
                const int ROOM_ID = 21;
                const int CLOSEOUTREASON_ID = 1;

                // Create closeOut record
                Closeout closeout = new Closeout();

                // Update CloseOut details
                closeout.RoomId = ROOM_ID;
                closeout.StartDate = new DateTime(2019, 9, 12, 0, 0, 0, DateTimeKind.Utc);
                closeout.EndDate = new DateTime(2019, 9, 14, 0, 0, 0, DateTimeKind.Utc);
                closeout.Description = closeout.Description + "UPDATED";
                closeout.CloseoutReasonId = CLOSEOUTREASON_ID;

                try
                {
                    // Modify CloseOut Details
                    closeoutDao.Modify(closeout);

                    Assert.Fail("An exception of type ExpectedResultException SRVEX30027 should have been thrown");
                }
                catch(ExpectedResultException ex)
                {
                    Assert.AreEqual(ex.Code, "SRVEX30027", "Exception code returned is incorrect");
                }
            }
示例#19
0
            public void CheckCloseoutOver365DaysFails()
            {
                // Arrange
                // Stub the CloseoutDao
                var stubCloseoutDao = MockRepository.GenerateStub<ICloseoutDao>();
                var stubRoomDao = MockRepository.GenerateStub<IRoomDao>();
                Room room = new Room { BusinessId = 1, Id = 1, RoomStatus = new RoomStatus { Code = RoomStatusCodes.ACTIVE } };

                // Configure stubs
                closeoutManager.CloseoutDao = stubCloseoutDao;
                closeoutManager.RoomDao = stubRoomDao;                
                stubCloseoutDao.Stub(c => c.Create(Arg<Closeout>.Is.Anything)).WhenCalled(x => ((Closeout)x.Arguments[0]).Id = 1);
                stubRoomDao.Stub(r => r.GetByKey(Arg<int>.Is.Anything, Arg<long>.Is.Anything)).Return(room);

                // Create closeout longer than 365 days
                Closeout invalidCloseout = new Closeout()
                {
                    BusinessId = 1,
                    RoomId = 1,
                    StartDate = new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2016, 1, 3, 0, 0, 0, DateTimeKind.Utc),
                    Description = "Test Closeout",
                    CloseoutReasonId = 1
                };

                try
                {
                    // Act
                    closeoutManager.CreateCloseout(invalidCloseout);

                    // Assert
                    Assert.Fail("Validation Exception SRVEX30029 expected and was not thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30029", ex.Code, "Check that the correct error code has been thrown");
                }
            }
示例#20
0
            public void CreatedCloseOutUpdatesAuditFields()
            {
                using (new TestDataHelper(GetTestQuery(TestQueryLimited.PopulateModifyCloseOutTestData), GetTestQuery(TestQuery.CleanupUnitTestData)))
                {
                    // Arrange
                    const int ROOM_ID = 1;
                    const int CLOSEOUTREASON_ID = 1;
                    const long BUSINESS_ID = 1;

                    // Arrange
                    // Create Closeout entity
                    var closeout = new Closeout
                    {
                        BusinessId = BUSINESS_ID,
                        RoomId = ROOM_ID,
                        StartDate = DateTime.UtcNow.AddDays(10),
                        EndDate = DateTime.UtcNow.AddDays(11),
                        CloseoutReasonId = CLOSEOUTREASON_ID
                    };

                    DateTime dateTimeBefore = DateTime.UtcNow.AddSeconds(-10);

                    // Act
                    // Modify CloseOut record
                    closeoutDao.Create(closeout);

                    DateTime dateTimeAfter = DateTime.UtcNow.AddSeconds(10);

                    // Assert
                    Assert.IsNotNull(closeout.Id, "Id attribute is not populated.");

                    Closeout createdCloseOut = closeoutDao.GetByKey(closeout.Id.Value, BUSINESS_ID);

                    Assert.AreEqual(TEST_USER_ID, createdCloseOut.CreatedByUserId, "CreatedByUserId was not updated");
                    Assert.IsTrue(createdCloseOut.CreatedDateTime >= dateTimeBefore && createdCloseOut.CreatedDateTime <= dateTimeAfter, "UpdatedDateTime was not updated");
                    Assert.AreEqual(TEST_USER_ID, createdCloseOut.UpdatedByUserId, "UpdatedByUserId was not updated");
                    Assert.IsTrue(createdCloseOut.UpdatedDateTime >= dateTimeBefore && createdCloseOut.UpdatedDateTime <= dateTimeAfter, "UpdatedDateTime was not updated");

                }
            }
示例#21
0
            public void RemoveCloseout()
            {
                // Arrange
                const int CLOSEOUT_ID = 1;
                const long BUSINESS_ID = 1;
                
                var closeout = new Closeout
                {
                    Id = 1,
                    BusinessId = 1,
                    RoomId = 1,
                    StartDate = DateTime.Now,
                    EndDate = DateTime.Now.AddDays(1),
                    CloseoutReasonId = 1
               };
                

                var closeoutDao = MockRepository.GenerateMock<ICloseoutDao>();
                closeoutManager.CloseoutDao = closeoutDao;

                closeoutDao.Expect(c => c.GetByKey(CLOSEOUT_ID, BUSINESS_ID)).Return(closeout);

                closeoutDao.Expect(c => c.Modify(Arg<Closeout>.Matches(x => x.Id == closeout.Id && 
                    x.BusinessId == closeout.BusinessId && x.RoomId == closeout.RoomId && x.IsDeleted == true)));
                
                // Act
                closeoutManager.Remove(CLOSEOUT_ID, BUSINESS_ID);

                // Assert
                closeoutDao.VerifyAllExpectations();
            }
示例#22
0
 /// <summary>
 /// This method checks Object's Start And End Dates are within the search date range
 /// </summary>
 /// <param name="closeout">Closeout object</param>
 /// <param name="startDate">Start Date</param>
 /// <param name="endDate">End Date</param>
 /// <returns>A boolean indicating if the closeouts are within search dates.</returns>
 private bool AreObjectDatesWithinSearchDates(Closeout closeout, DateTime startDate, DateTime endDate)
 {
     return closeout.StartDate.Date <= endDate.Date && closeout.EndDate.Date >= startDate.Date;
 }
示例#23
0
        /// <summary>
        /// Modify Closeout 
        /// </summary>
        /// <param name="closeout">Closeout</param>
        public void Modify(Closeout closeout)
        {
            // Update the closeout
            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(CloseoutMapper.Parameters.Id, closeout.Id),
                DbHelper.CreateParameter(CloseoutMapper.Parameters.BusinessId, closeout.BusinessId),
                DbHelper.CreateParameter(CloseoutMapper.Parameters.RoomId, closeout.RoomId),
                DbHelper.CreateParameter(CloseoutMapper.Parameters.StartDate, closeout.StartDate),
                DbHelper.CreateParameter(CloseoutMapper.Parameters.EndDate, closeout.EndDate),
                DbHelper.CreateParameter(CloseoutMapper.Parameters.Description, closeout.Description),
                DbHelper.CreateParameter(CloseoutMapper.Parameters.IsDeleted, closeout.IsDeleted),
                DbHelper.CreateParameter(CloseoutMapper.Parameters.CloseoutReasonId, closeout.CloseoutReasonId)
            };

            // Add auditing parameters
            AuditFieldsHelper.PopulateAuditFields(parameters);

            int rowsAffected = DbHelper.ExecuteNonQueryCommand("Booking.UpdateCloseout", CommandType.StoredProcedure, parameters);

            // Check if the Update was successful and return
            if (rowsAffected == 0)
            {
                throw new ExpectedResultException(ErrorFactory.CreateAndLogError(Errors.SRVEX30027, "CloseoutDao.Modify",
                    additionalDescriptionParameters: new object[] { typeof(Closeout).Name, closeout.Id },
                    arguments: new object[] { typeof(Closeout).Name, closeout.Id }));
            }
        }