public virtual string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, DotNetNuke.Services.Tokens.Scope accessLevel, ref bool propertyNotFound) { switch (strPropertyName.ToLower()) { case "locationid": // Int return(LocationId.ToString(strFormat, formatProvider)); case "conferenceid": // Int return(ConferenceId.ToString(strFormat, formatProvider)); case "name": // NVarChar if (Name == null) { return(""); } ; return(PropertyAccess.FormatString(Name, strFormat)); case "description": // NVarCharMax if (Description == null) { return(""); } ; return(PropertyAccess.FormatString(Description, strFormat)); case "capacity": // Int if (Capacity == null) { return(""); } ; return(((int)Capacity).ToString(strFormat, formatProvider)); case "sort": // Int if (Sort == null) { return(""); } ; return(((int)Sort).ToString(strFormat, formatProvider)); case "backgroundcolor": // NVarChar if (BackgroundColor == null) { return(""); } ; return(PropertyAccess.FormatString(BackgroundColor, strFormat)); default: propertyNotFound = true; break; } return(Null.NullString); }
public void TryParse_Whitespace() { Assert.IsNull(Location_Id.TryParse(" ")); Assert.IsFalse(Location_Id.TryParse(" ").HasValue); Assert.IsFalse(Location_Id.TryParse(" ", out Location_Id LocationId)); Assert.IsTrue(LocationId.IsNullOrEmpty); Assert.AreEqual(0, LocationId.Length); Assert.AreEqual("", LocationId.ToString()); }
public List <KeyValuePair <string, string> > GetAsPropertyList() { return(new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>(nameof(DisplayName), DisplayName), new KeyValuePair <string, string>(nameof(FeatureId), FeatureId.ToString()), new KeyValuePair <string, string>(nameof(LocationId), LocationId.ToString()), new KeyValuePair <string, string>(nameof(Scope), Definition.Scope.ToString()), new KeyValuePair <string, string>(nameof(TimeActivated), TimeActivated.ToString()), new KeyValuePair <string, string>(nameof(Version), Version.ToString()), new KeyValuePair <string, string>(nameof(Faulty), Faulty.ToString()), new KeyValuePair <string, string>(nameof(SandBoxedSolutionLocation), SandBoxedSolutionLocation), new KeyValuePair <string, string>(nameof(Properties), Common.StringUtilities.PropertiesToString(Properties)) }); }
public PartnerServiceTestsFixture() { var mapper = MapperHelper.CreateAutoMapper(); PartnerRepositoryMock = new Mock <IPartnerRepository>(MockBehavior.Strict); LocationServiceMock = new Mock <ILocationService>(MockBehavior.Strict); CredentialsClientMock = new Mock <ICredentialsClient>(MockBehavior.Strict); CustomerProfileClientMock = new Mock <ICustomerProfileClient>(MockBehavior.Strict); LocationsRepositoryMock = new Mock <ILocationRepository>(MockBehavior.Strict); PartnerCreatedPublisherMock = new Mock <IRabbitPublisher <PartnerCreatedEvent> >(MockBehavior.Strict); PartnerService = new PartnerService( PartnerRepositoryMock.Object, LocationServiceMock.Object, CredentialsClientMock.Object, CustomerProfileClientMock.Object, LocationsRepositoryMock.Object, PartnerCreatedPublisherMock.Object, mapper, EmptyLogFactory.Instance); Partner = new Partner { Id = Guid.NewGuid(), Name = "Partner 1", Description = "Partner 1 Desc", BusinessVertical = Vertical.Hospitality, ClientId = "clientId1", CreatedAt = DateTime.UtcNow, AmountInCurrency = 1, AmountInTokens = 2, Locations = new List <Location> { new Location { Id = LocationId, Name = "Holiday Inn", Address = "Dubai", CreatedAt = DateTime.UtcNow, ContactPerson = null }, new Location { Id = Guid.NewGuid(), Name = "Holiday Relax", Address = "Bahri", CreatedAt = DateTime.UtcNow, ContactPerson = null } } }; PartnerContactResponse = new PartnerContactResponse { PartnerContact = new PartnerContact { FirstName = "Owner", LastName = "Johnson", Email = "*****@*****.**", PhoneNumber = "123-123-123", LocationId = LocationId.ToString() } }; Partners = (new List <Partner> { Partner }.AsReadOnly(), 1); }
/// <summary> /// Return a JSON representation of this object. /// </summary> /// <param name="CustomSessionSerializer">A delegate to serialize custom session JSON objects.</param> /// <param name="CustomCDRTokenSerializer">A delegate to serialize custom charge detail record token JSON objects.</param> /// <param name="CustomEnergyMeterSerializer">A delegate to serialize custom energy meter JSON objects.</param> /// <param name="CustomTransparencySoftwareSerializer">A delegate to serialize custom transparency software JSON objects.</param> /// <param name="CustomChargingPeriodSerializer">A delegate to serialize custom charging period JSON objects.</param> /// <param name="CustomCDRDimensionSerializer">A delegate to serialize custom charge detail record dimension JSON objects.</param> /// <param name="CustomPriceSerializer">A delegate to serialize custom price JSON objects.</param> public JObject ToJSON(CustomJObjectSerializerDelegate <Session> CustomSessionSerializer = null, CustomJObjectSerializerDelegate <CDRToken> CustomCDRTokenSerializer = null, CustomJObjectSerializerDelegate <EnergyMeter> CustomEnergyMeterSerializer = null, CustomJObjectSerializerDelegate <TransparencySoftware> CustomTransparencySoftwareSerializer = null, CustomJObjectSerializerDelegate <ChargingPeriod> CustomChargingPeriodSerializer = null, CustomJObjectSerializerDelegate <CDRDimension> CustomCDRDimensionSerializer = null, CustomJObjectSerializerDelegate <Price> CustomPriceSerializer = null) { var JSON = JSONObject.Create( new JProperty("country_code", CountryCode.ToString()), new JProperty("party_id", PartyId.ToString()), new JProperty("id", Id.ToString()), new JProperty("start_date_time", Start.ToIso8601()), End.HasValue ? new JProperty("end_date_time", End.Value.ToIso8601()) : null, new JProperty("kwh", kWh), new JProperty("cdr_token", CDRToken.ToJSON(CustomCDRTokenSerializer)), new JProperty("auth_method", AuthMethod.ToString()), AuthorizationReference.HasValue ? new JProperty("authorization_reference", AuthorizationReference.ToString()) : null, new JProperty("location_id", LocationId.ToString()), new JProperty("evse_uid", EVSEUId.ToString()), new JProperty("connector_id", ConnectorId.ToString()), MeterId.HasValue ? new JProperty("meter_id", MeterId.ToString()) : null, EnergyMeter != null ? new JProperty("energy_meter", EnergyMeter.ToJSON(CustomEnergyMeterSerializer)) : null, TransparencySoftwares.SafeAny() ? new JProperty("transparency_softwares", new JArray(TransparencySoftwares.Select(software => software.ToJSON(CustomTransparencySoftwareSerializer)))) : null, new JProperty("currency", Currency.ToString()), ChargingPeriods.SafeAny() ? new JProperty("charging_periods", new JArray(ChargingPeriods.Select(chargingPeriod => chargingPeriod.ToJSON(CustomChargingPeriodSerializer, CustomCDRDimensionSerializer)))) : null, TotalCosts.HasValue ? new JProperty("total_cost", TotalCosts.Value.ToJSON(CustomPriceSerializer)) : null, new JProperty("status", Status.ToString()), new JProperty("last_updated", LastUpdated.ToIso8601()) ); return(CustomSessionSerializer != null ? CustomSessionSerializer(this, JSON) : JSON); }
/// <summary> /// Get active or inactive Users by Client id /// </summary> /// <param name="ClientId">Id of the Client</param> /// <param name="search">search string</param> /// <param name="IsActive">TRUE OR FALSE</param> /// <param name="pagingInfo">pagingInfo object</param> /// <returns> Returns Active or Inactive user list </returns> public static List <UserDTO> GetUsersbyClientIdWithIsActive(int ClientId, string search, bool IsActive, PagingInfo pagingInfo) { List <UserDTO> UserDTOList = new List <UserDTO>(); try { UnitOfWork uow = new UnitOfWork(); int skip = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage; int take = pagingInfo.ItemsPerPage; IQueryable <User> User = uow.UserRepo.GetAll().Where(e => e.ClientId == ClientId && e.IsActive == IsActive).OrderBy(e => e.Name).AsQueryable();// .ToList().Skip(skip).Take(take); User = PagingService.Sorting <User>(User, pagingInfo.SortBy, pagingInfo.Reverse); User = User.Skip(skip).Take(take); if (User != null) { foreach (var user in User) { UserDTO UserDTO = new UserDTO(); UserDTO = Transform.UserToDTO(user); LocationDTO LocationDTO = new LocationDTO(); UserDTO.Location = LocationService.GetById(UserDTO.LocationId).Name; UserDTOList.Add(UserDTO); } if (search != "" && search != null) { //int LocationId = LocationService.GetByLocationName(search, ClientId); string LocationIdString = LocationService.GetLocationIdarrayByName(search, ClientId); bool IsDate = CommonService.IsDate(search); if (IsDate != true) { // string search List <UserDTO> UserDTOListSearch = new List <UserDTO>(); IQueryable <User> UserSearch = uow.UserRepo.GetAll().Where(e => (e.Email.ToLower().Contains(search.ToLower()) || e.Name.ToLower().Contains(search.ToLower()) || e.FirstName.ToLower().Contains(search.ToLower()) || e.LastName.ToLower().Contains(search.ToLower()) || (e.Mobile != null ? (e.Mobile.Contains(search)) : false) || (LocationIdString != null ? (e.LocationId.ToString().Split(',').Any(LocationId => LocationIdString.Contains(LocationId.ToString()))) : false)) && e.IsActive == IsActive && e.ClientId == ClientId).AsQueryable();//.OrderBy(e => e.Name).ToList().Skip(skip).Take(take); //(e.Location != null ? (e.Location.ToLower().Contains(search.ToLower())) : false) UserSearch = PagingService.Sorting <User>(UserSearch, pagingInfo.SortBy, pagingInfo.Reverse); UserSearch = UserSearch.Skip(skip).Take(take); foreach (var user in UserSearch) { UserDTO UserDTO = new UserDTO(); UserDTO = Transform.UserToDTO(user); LocationDTO LocationDTO = new LocationDTO(); UserDTO.Location = LocationService.GetById(UserDTO.LocationId).Name; UserDTOListSearch.Add(UserDTO); } return(UserDTOListSearch); } else { } } ////else ////{ //// ////foreach (var item in User) //// ////{ //// //// //UserDTO UserDTO = new UserDTO(); //// //// UserDTOList.Add(Transform.UserToDTO(item)); //// ////} ////} } return(UserDTOList); } catch (Exception) { throw; } }
public override string ToString() => Id.ToString();