public async Task <_ListViewModel <_KeyValuePairViewModel> > Get(string filter = null) { var model = new _ListViewModel <_KeyValuePairViewModel>(); try { model = await _context.GetCountriesAsync(filter); } catch (Exception ex) { if (model == null) { model = new _ListViewModel <_KeyValuePairViewModel>(); } if (model.Message.Length > 0) { model.Message += " | "; } else { model.Message = "Error: "; } model.Message += ex.Message; } return(model); }
public async Task <_ListViewModel <string> > Get(string countryCode, string stateCode, string filter = null) { var model = new _ListViewModel <string>(); try { model = await _context.GetCitiesAsync(countryCode, stateCode, filter); } catch (Exception ex) { if (model == null) { model = new _ListViewModel <string>(); } if (model.Message.Length > 0) { model.Message += " | "; } else { model.Message = "Error: "; } model.Message += ex.Message; } return(model); }
public async Task <_ListViewModel <ReferralViewModel> > UpdateReferral(int id, [FromBody] JArray value) { var model = new _ListViewModel <ReferralViewModel>(); try { List <ReferralViewModel> referral = value.ToObject <List <ReferralViewModel> >(); (bool isSuccess, string message) = await _context.AddUpdateReferralsAsync(id, referral); model = await _context.GetReferralsAsync(id); if (model == null) { model = new _ListViewModel <ReferralViewModel> { Message = "Error: No data returned" }; } else { model.Message = message; } } catch (Exception ex) { if (model == null) { model = new _ListViewModel <ReferralViewModel>(); } model.Message = $"Error: {ex.Message}"; } return(model); }
public async Task <_ListViewModel <ReferralViewModel> > Referral(int id) { var model = new _ListViewModel <ReferralViewModel>(); try { model = await _context.GetReferralsAsync(id); if (model == null) { model = new _ListViewModel <ReferralViewModel> { Message = "Error: No data returned" }; } } catch (Exception ex) { if (model == null) { model = new _ListViewModel <ReferralViewModel>(); } model.Message = $"Error: {ex.Message}"; } return(model); }
public async Task <_ListViewModel <_KeyValuePairViewModel> > GetOrganizationsAsync() { _ListViewModel <_KeyValuePairViewModel> model = new _ListViewModel <_KeyValuePairViewModel>(); try { List <_KeyValuePairViewModel> qry = await(from x in _context.Organizations select new _KeyValuePairViewModel { Key = x.OrganizationId.ToString(), Value = x.OrganizationName }).OrderBy(o => o.Value).ToListAsync(); model.Rows = qry; model.TotalCount = qry.Count(); model.Message = "Success"; //_context.Organizations.OrderBy(o => o.OrganizationName).ToListAsync(); } catch (Exception ex) { if (model == null) { model = new _ListViewModel <_KeyValuePairViewModel>(); } model.Message = $"Error: {ex.Message}"; } return(model); }
public async Task <_ListViewModel <UnitListViewModel> > GetUnits(UnitSearchViewModel search) { var model = new _ListViewModel <UnitListViewModel>(); try { var result = await _context.LoadStoredProc("dbo.apiUnitSearch") .WithSqlParam("ownerType", search.OwnerType) .WithSqlParam("inventoryID", null) .WithSqlParam("resortID", null) .WithSqlParam("startDate", search.CheckInStart) .WithSqlParam("endDate", search.CheckInEnd) .WithSqlParam("regionCode", search.RegionCode) .WithSqlParam("countryCode", search.CountryCode) .WithSqlParam("stateCode", search.StateCode) .WithSqlParam("city", search.City) .WithSqlParam("bedroomSize", (search.BedroomSize.HasValue) ? (int?)search.BedroomSize.Value : null) .WithSqlParam("inventoryType", (search.InventoryType.HasValue) ? search.InventoryType.Value.ToString() : null) .WithSqlParam("maximumRSICost", search.MaximumNetRate) .WithSqlParam("startRowIndex", search.StartRowIndex) .WithSqlParam("numberOfRows", search.NumberOfRows) .WithSqlParam("orderBy", search.SortColumn) .WithSqlParam("orderDirection", search.SortDirection) .ExecuteStoredProcAsync <apiUnitSearchResult>(); model.Rows = result.Select(u => new UnitListViewModel() { Description = u.description.Replace("\n", " "), ImageURL = $"http://accessrsi.com/dannoJR/ProductImageHandler.ashx?imageid={u.imageID}", LowestNetRate = u.lowest, OwnerId = u.ownerID, OriginalUnitId = u.origionalID, UnitId = u.unitID, UnitName = u.unitName, Address = new AddressViewModel() { City = u.city, CountryCode = u.countryCode, CountryFullName = u.countryFullName, PostalCode = u.postalCode, RegionCode = u.regionCode, RegionFullName = u.regionFullName, StateCode = u.stateCode, StateFullName = u.stateFullName, StreetAddress = u.address.Trim() }, MaxRows = u.maxrows }).ToList(); model.TotalCount = (model.RowCount > 0) ? model.Rows[0].MaxRows : 0; model.Message = "Success"; } catch (Exception ex) { model.Message = $"Error: {ex.Message}"; } return(model); }
public async Task <_ListViewModel <PackageListViewModel> > GetPackagesByRSIOrgIdAsync(int rsiOrgId) { _ListViewModel <PackageListViewModel> model = new _ListViewModel <PackageListViewModel>(); try { using (var conn = new SqlConnection(SqlHelper.GetConnectionString())) { var parameters = new[] { new SqlParameter("@RSIOrgId", rsiOrgId) }; var rdr = await SqlHelper.ExecuteReaderAsync( conn, CommandType.StoredProcedure, "[dbo].[GetPackagesByRSIOrgId]", parameters); if (rdr.HasRows) { while (rdr.Read()) { PackageListViewModel tmp = new PackageListViewModel() { PackageId = !rdr.IsDBNull(0) ? Decimal.ToInt32(rdr.GetDecimal(0)) : 0, Name = !rdr.IsDBNull(1) ? rdr.GetString(1) : "", CondoWeeks = !rdr.IsDBNull(2) ? rdr.GetInt32(2) : 0, RCIWeeks = !rdr.IsDBNull(3) ? rdr.GetInt32(3) : 0, Points = !rdr.IsDBNull(4) ? int.Parse(rdr.GetString(4)) : 0, IsUnlimitedPoints = !rdr.IsDBNull(5) ? Decimal.ToInt16(rdr.GetDecimal(5)) == 1 ? true : false : false }; model.Rows.Add(tmp); } model.TotalCount = model.Rows.Count; model.Message = "Success"; } } } catch (Exception ex) { if (model == null) { model = new _ListViewModel <PackageListViewModel>(); } model.Message = $"Error: {ex.Message}"; } return(model); }
public async Task <_ListViewModel <UnitListViewModel> > Get(OwnerType?ownerType, DateTime?checkInStart, DateTime?checkInEnd, string regionCode, string countryCode, string stateCode, string city, BedroomSize?bedroomSize, InventoryType?inventoryType, decimal?maximumNetRate, int?startRowIndex = 1, int?numberOfRows = 10, string orderBy = "price", string orderDirection = "asc") { var model = new _ListViewModel <UnitListViewModel>(); try { var search = new UnitSearchViewModel() { OwnerType = ownerType, CheckInStart = checkInStart, CheckInEnd = checkInEnd, RegionCode = regionCode, CountryCode = countryCode, StateCode = stateCode, City = city, BedroomSize = bedroomSize, InventoryType = inventoryType, MaximumNetRate = maximumNetRate, StartRowIndex = startRowIndex, NumberOfRows = numberOfRows, SortColumn = orderBy, SortDirection = orderDirection, ExactMatch = true, }; model = await _context.GetUnits(search); } catch (Exception ex) { if (model == null) { model = new _ListViewModel <UnitListViewModel>(); } if (model.Message.Length > 0) { model.Message += " | "; } else { model.Message = "Error: "; } model.Message += ex.Message; } return(model); }
public async Task <_ListViewModel <MemberListViewModel> > Get(int startRowIndex, int numberOfRows, string firstName, string lastName, string email, string phone, int organizationId, string catchAll , string sortColumn = "DEFAULT", string sortDirection = "ASC" , bool exactMatch = true, string clubReference = "BRIO") { var model = new _ListViewModel <MemberListViewModel>(); try { MemberSearchViewModel search = new MemberSearchViewModel() { CatchAll = catchAll, Email = email, ExactMatch = exactMatch, FistName = firstName, LastName = lastName, NumberOfRows = numberOfRows, OrganizationId = organizationId, Phone = phone, SortColumn = sortColumn, SortDirection = sortDirection, StartRowIndex = startRowIndex, ClubReference = clubReference }; model = await _context.GetMembersAsync(search); } catch (Exception ex) { if (model == null) { model = new _ListViewModel <MemberListViewModel>(); } if (model.Message.Length > 0) { model.Message += " | "; } else { model.Message = "Error: "; } model.Message += ex.Message; } return(model); }
public async Task <_ListViewModel <InventoryListViewModel> > GetInventory(InventorySearchViewModel search) { var model = new _ListViewModel <InventoryListViewModel>(); try { var result = await _legacyContext.LoadStoredProc("dbo.apiInventorySearch") .WithSqlParam("resortID", search.UnitId) .WithSqlParam("startDate", search.CheckInStart) .WithSqlParam("endDate", search.CheckInEnd) .WithSqlParam("bedroomSize", (search.BedroomSize.HasValue) ? (int?)search.BedroomSize.Value : null) .WithSqlParam("inventoryType", (search.InventoryType.HasValue) ? search.InventoryType.Value.ToString() : null) .WithSqlParam("maximumRSICost", search.MaximumNetRate) .WithSqlParam("startRowIndex", search.StartRowIndex) .WithSqlParam("numberOfRows", search.NumberOfRows) .WithSqlParam("orderBy", search.SortColumn) .WithSqlParam("orderDirection", search.SortDirection) .ExecuteStoredProcAsync <apiInventorySearchResult>(); model.Rows = result.Select(i => new InventoryListViewModel() { CheckInDate = i.checkInDate, CheckOutDate = i.checkOutDate, InventoryId = i.inventoryID, InventoryType = i.inventoryType, KitchenType = i.kitchenType, MaxGuests = i.maxGuests, NetRate = (string.IsNullOrEmpty(i.netRate)) ? 0 : Decimal.Parse(i.netRate), Privacy = i.adults, Quantity = i.quantity, BedroomSize = ((BedroomSize)Enum.Parse(typeof(BedroomSize), i.unitSize)).ToString().SplitCamelCase(), UnitId = i.unitID, MaxRows = i.maxrows //, //OwnerId = i.owner }).ToList(); model.TotalCount = (model.RowCount > 0) ? model.Rows[0].MaxRows : 0; model.Message = "Success"; } catch (Exception ex) { model.Message = $"Error: {ex.Message}"; } return(model); }
public async Task <_ListViewModel <string> > GetCitiesAsync(string countryCode, string stateCode, string filter) { var model = new _ListViewModel <string>(); try { if (!String.IsNullOrEmpty(countryCode)) { var tmp = from i in _context.Inventories join u in _context.Units on i.unitkeyid equals u.keyid where (u.country == countryCode) && (u.state == (string.IsNullOrEmpty(stateCode) ? u.state : stateCode)) && (DateTime.Now < i.finish) && (i.quantity - i.hold > 0) select new { u.city }; if (!String.IsNullOrEmpty(filter)) { tmp = tmp.Where(x => x.city.Contains(filter)); } tmp = tmp.Distinct(); //tmp.GroupBy(x=>x.city) model.TotalCount = tmp.Count(); model.Rows = await(from t in tmp orderby t.city select t.city).ToListAsync(); } model.Message = "Success"; } catch (Exception ex) { if (model == null) { model = new _ListViewModel <string>(); } model.Message = $"Error: {ex.Message}"; } return(model); }
public async Task <_ListViewModel <PackageListViewModel> > GetPackages(int rsiOrgId) { var model = new _ListViewModel <PackageListViewModel>(); try { model = await _packageService.GetPackagesByRSIOrgIdAsync(rsiOrgId); } catch (Exception ex) { if (model == null) { model = new _ListViewModel <PackageListViewModel>(); } model.Message = $"Error: {ex.Message}"; } return(model); }
public async Task <_ListViewModel <_KeyValuePairViewModel> > GetStatesAsync(string countryCode = null, string filter = null) { var model = new _ListViewModel <_KeyValuePairViewModel>(); try { if (!String.IsNullOrEmpty(countryCode)) { var tmp = from t in _context.Translators where t.Language == "EN" && t.Type == "_S_" + countryCode select new { t.Reference, t.Value }; if (!String.IsNullOrEmpty(filter)) { tmp = tmp.Where(x => x.Reference.Contains(filter) || x.Value.Contains(filter)); } model.TotalCount = tmp.Count(); model.Rows = await(from t in tmp orderby t.Value.ToString() select new _KeyValuePairViewModel { Key = t.Reference, Value = t.Value }).ToListAsync(); } model.Message = "Success"; } catch (Exception ex) { if (model == null) { model = new _ListViewModel <_KeyValuePairViewModel>(); } model.Message = $"Error: {ex.Message}"; } return(model); }
public async Task <_ListViewModel <_KeyValuePairViewModel> > GetRegionsAsync(string filter) { var model = new _ListViewModel <_KeyValuePairViewModel>(); try { var tmp = from r in _context.Regions select new { r.regioncode, r.regiondescription }; if (!String.IsNullOrEmpty(filter)) { tmp = tmp.Where(x => x.regioncode.Contains(filter) || x.regiondescription.Contains(filter)); } tmp = tmp.Distinct(); model.TotalCount = tmp.Count(); model.Rows = await(from t in tmp orderby t.regioncode select new _KeyValuePairViewModel { Key = t.regioncode, Value = t.regiondescription.Trim() }).ToListAsync(); model.Message = "Success"; } catch (Exception ex) { if (model == null) { model = new _ListViewModel <_KeyValuePairViewModel>(); } model.Message = $"Error: {ex.Message}"; } return(model); }
public async Task <_ListViewModel <TravelDetailViewModel> > Travel(int rsiId) { var model = new _ListViewModel <TravelDetailViewModel>(); try { (bool isSuccess, string message, List <TravelDetailViewModel> travels) = await _context.GetTravelInfoAsync(rsiId); model.Message = message; model.Rows = travels; } catch (Exception ex) { if (model == null) { model = new _ListViewModel <TravelDetailViewModel>(); } model.Message = $"Error: {ex.Message}"; } return(model); }