/// <summary>
        /// Get All Facilities
        /// </summary>
        /// <param name="take"></param>
        /// <param name="skip"></param>
        /// <param name="isActive"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public ContentResult GetAllFacilities(int take, int skip, bool isActive, int userId)
        {
            FacilityContainer facilityInfo = new FacilityContainer
            {
                PageSetting = new PageSetting {
                    Skip = skip, Take = take
                },
                IsActive = isActive,
                UserId   = userId
            };

            FacilityContainer facilityContainer = PostApiResponse <FacilityContainer>(Constants.Facility, Constants.GetAllFacilities, facilityInfo, true);
            DataSourceResult  facilitiesData    = new DataSourceResult();

            if (facilityContainer != null && facilityContainer.Facilities != null && facilityContainer.Facilities.Any())
            {
                facilitiesData.Data  = Mapper.Map <List <Facility>, List <FacilityViewModel> >(facilityContainer.Facilities);
                facilitiesData.Total = facilityContainer.TotalRecords;
            }
            JavaScriptSerializer serializer = new JavaScriptSerializer {
                MaxJsonLength = Int32.MaxValue
            };

            return(new ContentResult
            {
                Content = serializer.Serialize(facilitiesData),
                ContentType = Constants.ContentTypeApplication
            });
        }
Beispiel #2
0
        /// <summary>
        /// Get All Facilities
        /// </summary>
        /// <param name="facilityInfo"></param>
        /// <returns></returns>
        public FacilityContainer GetAllFacilities(FacilityContainer facilityInfo)
        {
            var facility = new FacilityContainer();

            // Initialize the Stored Procedure
            _databaseCommand = _databaseObj.GetStoredProcCommand("GetAllFacilities");
            _databaseObj.AddInParameter(_databaseCommand, "@Take", DbType.String, facilityInfo.PageSetting.Take);
            _databaseObj.AddInParameter(_databaseCommand, "@Skip", DbType.String, facilityInfo.PageSetting.Skip);
            _databaseObj.AddInParameter(_databaseCommand, "@IsActive", DbType.Boolean, facilityInfo.IsActive);
            _databaseObj.AddInParameter(_databaseCommand, "@UserId", DbType.Int32, facilityInfo.UserId);

            // Retrieve the results of the Stored Procedure
            DataSet facilityDataSet = _databaseObj.ExecuteDataSet(_databaseCommand);

            if (facilityDataSet.IsTableDataPopulated())
            {
                DataRow[]       dataRows   = facilityDataSet.Tables[0].Select();
                List <Facility> facilities = new List <Facility>();
                facilities.AddRange(dataRows.Select(facilityRow => new Facility
                {
                    FacilityId   = Convert.ToInt32(facilityRow["FacilityId"]),
                    FacilityName = Convert.ToString(facilityRow["FacilityName"]),
                    SsiNo        = Convert.ToString(facilityRow["SSINumber"]),
                    City         = Convert.ToString(facilityRow["City"]),
                    StateId      = Convert.ToString(facilityRow["StateId"]),
                    IsActive     = Convert.ToBoolean(facilityRow["IsActive"]),
                    NoofUsers    = Convert.ToInt32(facilityRow["UserCount"])
                }));
                facility.Facilities   = facilities;
                facility.TotalRecords = Convert.ToInt32(facilityDataSet.Tables[1].Rows[0][0]);
            }
            return(facility);
        }
Beispiel #3
0
        public void GetAllFacilitiesUnitTestForNull()
        {
            // Arrange
            Mock <IFacilityRepository> mockFacilityDetails = new Mock <IFacilityRepository>();

            mockFacilityDetails.Setup(f => f.GetAllFacilities(It.IsAny <FacilityContainer>())).Returns((FacilityContainer)null);
            _target = new FacilityLogic(mockFacilityDetails.Object);

            // Act
            FacilityContainer actual = _target.GetAllFacilities(null);

            // Assert
            Assert.IsNull(actual);
        }
Beispiel #4
0
 public FacilityContainer GetAllFacilities(FacilityContainer facilityInfo)
 {
     return(_facilityLogic.GetAllFacilities(facilityInfo));
 }
Beispiel #5
0
        public void GetAllFacilitiesUnitTest()
        {
            // Arrange
            Mock <IFacilityRepository> mockFacilityRepository = new Mock <IFacilityRepository>();

            //Mock Input
            FacilityContainer facilityContainerInput = new FacilityContainer
            {
                PageSetting = new PageSetting
                {
                    Skip = 0,
                    Take = 50
                },
                IsActive = true
            };

            //Mock Output
            FacilityContainer expectedResult = new FacilityContainer
            {
                Facilities = new List <Facility>
                {
                    new Facility
                    {
                        FacilityId              = 12,
                        DisplayName             = "Facility",
                        FacilityName            = "Facility",
                        Address                 = "USA",
                        City                    = "Alabama",
                        StateId                 = "AL",
                        Zip                     = "635205",
                        Domains                 = "@ssigroup.com,@emids.com",
                        Phone                   = "321-321-321",
                        Fax                     = "321-654-987",
                        IsActive                = false,
                        EarlyStatementDate      = DateTime.Now,
                        PasswordExpirationDays  = 12,
                        InvalidPasswordAttempts = 4,
                        SsiNo                   = "321654,321654,9 87654",
                        FacilityBubbleId        = 1,
                        FacilityFeatureControl  = new List <FeatureControl>
                        {
                            new FeatureControl {
                                FeatureControlId = 1, IsSelected = true
                            },
                            new FeatureControl {
                                FeatureControlId = 2, IsSelected = true
                            }
                        }
                    }
                }
            };

            //Mock Setup
            mockFacilityRepository.Setup(f => f.GetAllFacilities(It.IsAny <FacilityContainer>())).Returns(expectedResult);
            _target = new FacilityLogic(mockFacilityRepository.Object);

            // Act
            FacilityContainer actual = _target.GetAllFacilities(facilityContainerInput);

            // Assert
            Assert.AreEqual(expectedResult, actual);
            Assert.AreEqual(expectedResult.Facilities[0].DisplayName, actual.Facilities[0].DisplayName);
            Assert.AreEqual(expectedResult.Facilities[0].FacilityName, actual.Facilities[0].FacilityName);
        }
 /// <summary>
 /// Get All Facilities
 /// </summary>
 /// <param name="facilityInfo"></param>
 /// <returns></returns>
 public FacilityContainer GetAllFacilities(FacilityContainer facilityInfo)
 {
     return(_facilityRepository.GetAllFacilities(facilityInfo));
 }