public async Task <IEnumerable <IClientValidationDto> > GetAllAsync(ServiceArgs args = null) { var validationDto = new ClientValidationDto(); if (args != null) { if (args.ContainsKey("ShopName")) { var shopName = args["ShopName"].ToString(); validationDto.IsValid = await Db.Shops.CountAsync(x => x.Name == shopName) == 0; } if (args.ContainsKey("AccountName")) { var shopName = args["AccountName"].ToString(); validationDto.IsValid = await Db.Accounts.CountAsync(x => x.Name == shopName) == 0; } if (args.ContainsKey("UserEmail")) { var email = args["UserEmail"].ToString(); var registrationCheckQuery = Db.Registrations.Where(x => x.Email == email); if (args.ContainsKey("RegistrationId")) { var registrationId = Guid.Parse(args["RegistrationId"].ToString()); registrationCheckQuery = registrationCheckQuery.Where(x => x.RegistrationId != registrationId); } validationDto.IsValid = await Db.Users.Where(x => x.Email == email).CountAsync() == 0 && await registrationCheckQuery.CountAsync() == 0; } } return(new List <IClientValidationDto> { validationDto }); }
public IEnumerable <KeyValuePair <string, string> > GetDisplayList(ServiceArgs args = null) { // Create Tools List. var tools = new List <AirProToolEntityModel>(); var toolTypes = new List <ToolType> { ToolType.AirPro }; if (args != null && args.ContainsKey("ToolTypes")) { toolTypes = args["ToolTypes"].ToString().Split(',').Select(x => (ToolType)Enum.Parse(typeof(ToolType), x)).ToList(); } // Check for Shop Guid Filter. if (args != null && args.ContainsKey("ShopGuid") && Guid.TryParse(args["ShopGuid"].ToString(), out var shopGuid)) { // Select Tools Based on Shop. tools.AddRange(Db.AirProToolShops.Where(s => s.ShopGuid == shopGuid && toolTypes.Any(y => y == s.Tool.Type)).Select(t => t.Tool) .Union(Db.AirProToolAccounts.Where(a => a.Account.Shops.Any(s => s.ShopGuid == shopGuid) && toolTypes.Any(y => y == a.Tool.Type)) .Select(t => t.Tool)).ToList()); } else { // Load All. tools.AddRange(Db.AirProTools.Where(x => toolTypes.Any(y => y == x.Type)).ToList()); } // Return Tools. return(tools.Select(t => new KeyValuePair <string, string>(t.ToolId.ToString(), t.ToolName)).ToList()); }
public IEnumerable <IShopDto> GetAll(ServiceArgs args = null) { var result = new List <IShopDto>(); if (!UserHasRoles(ApplicationRoles.ShopView, ApplicationRoles.ShopEdit)) { return(result); } if (AllowedShops != null) { string shopName = null; Guid? notShopGuid = null; if (args != null && args.ContainsKey("ShopName") && args["ShopName"] != null) { shopName = args["ShopName"].ToString(); } if (args != null && args.ContainsKey("NotShopGuid") && Guid.TryParse(args["NotShopGuid"].ToString(), out var nsg)) { notShopGuid = nsg; } result.AddRange(GetShops(shopName: shopName, notShopGuid: notShopGuid)); } return(result); }
public IEnumerable <IDiagnosticResultDto> GetAll(ServiceArgs args = null) { // Check Args. if (args == null) { return(null); } try { // Shop Guid. Guid shopGuid = new Guid(); if (args.ContainsKey("ShopGuid")) { Guid.TryParse(args["ShopGuid"].ToString(), out shopGuid); } // Request Id. int requestId = 0; if (args.ContainsKey("RequestId")) { int.TryParse(args["RequestId"].ToString(), out requestId); } // Load Params. var param = new { ShopGuid = shopGuid, RequestId = requestId }; // Load Diagnostics. var resultDictionary = new Dictionary <int, DiagnosticResultDto>(); var result = Conn .Query <DiagnosticResultDto, DiagnosticControllerDto, DiagnosticTroubleCodeDto, dynamic, DiagnosticResultDto>("Diagnostic.usp_GetDiagnosticResults", (r, c, tc, ff) => MapDiagnosticResult(resultDictionary, r, c, tc, ff), param: param, transaction: null, buffered: true, splitOn: "ControllerId,DiagnosticTroubleCodeId,FreezeFrameDiagnosticTroubleCode", commandTimeout: null, commandType: CommandType.StoredProcedure) .Distinct().ToList <IDiagnosticResultDto>(); // Return Results. return(result); } catch (Exception e) { Logger.LogException(e); } return(null); }
private static object ParamsFromArgs(Guid userGuid, ServiceArgs args = null) { var sort = (args != null && args.ContainsKey("SortOrder") ? args["SortOrder"].ToString() : string.Empty).Replace(",", "").Split(' '); return(new { UserGuid = userGuid, CompletedInd = args != null && args.ContainsKey("CompletedInd") && bool.TryParse(args["CompletedInd"].ToString(), out var completed) && completed, Search = args != null && args.ContainsKey("SearchPhrase") ? args["SearchPhrase"].ToString() : string.Empty, CurrentPage = args != null && args.ContainsKey("CurrentPage") && int.TryParse(args["CurrentPage"].ToString(), out var page) ? page : 1, RowCount = args != null && args.ContainsKey("RowCount") && int.TryParse(args["RowCount"].ToString(), out var rows) ? rows : 25, SortCol = sort.Length > 0 ? sort[0] : "RequestCreatedDt", SortDir = sort.Length > 1 ? sort[1] : "ASC", });
public IEnumerable <IUploadDto> GetAll(ServiceArgs args = null) { // Create Result. var result = new List <UploadDto>(); // Load Uploads. var query = Db.Uploads.Where(u => !u.UploadDeletedInd); // Check Upload Type & Key. if (!(args?.ContainsKey("UploadTypeId") ?? false) || !args.ContainsKey("UploadKey") || !int.TryParse(args["UploadTypeId"]?.ToString(), out var type)) { return(result); } // Query Data. var key = args["UploadKey"].ToString(); query = query.Where(u => u.UploadTypeId == type && u.UploadKey == key); // Load Uploads. var uploads = query.ToList(); // Convert to Dto. var mapped = uploads.Select(u => Mapper.Map <UploadEntityModel, UploadDto>(u, opts => opts.AfterMap((src, dest) => dest.UploadedDateTime = src.CreatedDt.ConvertToUserTime(User.TimeZoneInfoId)))).ToList(); // Load Result. result.AddRange(mapped); // Return. return(result); }
public IGridPageDto <IInvoiceDto> GetAllByGridPage(ServiceArgs args = null) { // Load Status. var status = 3; if ((args?.ContainsKey("StatusFilter") ?? false) && Enum.TryParse(args["StatusFilter"]?.ToString(), out RepairStatuses statusFilter)) { if (statusFilter == RepairStatuses.Completed || statusFilter == RepairStatuses.Invoiced) { status = (int)statusFilter; } } // Load Grid Items. var query = Conn.Query <InvoiceDto>("Billing.usp_GetBillingInvoiceGrid", new { UserGuid = User.UserGuid, Search = args?["SearchPhrase"]?.ToString(), Status = status }, null, true, null, CommandType.StoredProcedure).ToList(); // Set Default Sort. args?.SetDefaultSort("InvoicedDt DESC, RepairLastUpdatedDt ASC"); // Load Grid Page. var result = query.ToList <IInvoiceDto>().GetGridPageFromCollection(args); // Return. return(result); }
public IEnumerable <KeyValuePair <string, string> > GetDisplayList(ServiceArgs args = null) { if (args != null && args.ContainsKey("RepairId") && int.TryParse(args["RepairId"].ToString(), out var repairId) && args.ContainsKey("ShopGuid") && Guid.TryParse(args["ShopGuid"].ToString(), out var shopGuid)) { var users = Conn.Query <UserEntityModel>("Access.usp_GetUsersByRepairId", new { RepairId = repairId == 0 ? null : new int?(repairId), ShopGuid = shopGuid == Guid.Empty ? null : new Guid?(shopGuid) }, null, true, null, CommandType.StoredProcedure); return(users.Select(x => new KeyValuePair <string, string>(x.Id.ToString(), x.GetDisplayName))); } return(AllowedUsers?.OrderBy(u => u.LastName).ThenBy(u => u.FirstName).AsEnumerable() .Select(u => new KeyValuePair <string, string>(u.Id.ToString(), u.GetDisplayName))); }
public IGridPageDto <IOutstandingInvoiceDto> GetAllByGridPage(ServiceArgs args = null) { Guid shopGuid = Guid.Empty; if ((args?.ContainsKey("ShopGuid") ?? false) && Guid.TryParse(args["ShopGuid"]?.ToString(), out shopGuid)) { } int currencyId = 0; if ((args?.ContainsKey("CurrencyId") ?? false) && int.TryParse(args["CurrencyId"]?.ToString(), out currencyId)) { } var shopParam = shopGuid == Guid.Empty ? new SqlParameter("@ShopGuid", DBNull.Value) : new SqlParameter("@ShopGuid", shopGuid); var currencyParam = currencyId <= 0 ? new SqlParameter("@CurrencyId", DBNull.Value) : new SqlParameter("@CurrencyId", currencyId); var search = args?["SearchPhrase"]?.ToString(); var sqlParams = new[] { shopParam, currencyParam, new SqlParameter("@Search", search) }; var unpaidInvoices = Db.Database.SqlQuery <OutstandingInvoice>("Billing.usp_GetOutstandingInvoices @ShopGuid, @CurrencyId, @Search", sqlParams).ToList(); // Localize Invoiced Date. unpaidInvoices.ForEach(e => e.InvoiceDateTime = e.InvoiceDateTime.ConvertToUserTime(User.TimeZoneInfoId)); // Localize Repair Date. unpaidInvoices.ForEach(e => e.RepairCreatedDateTime = e.RepairCreatedDateTime.ConvertToUserTime(User.TimeZoneInfoId)); return(unpaidInvoices.ToList <IOutstandingInvoiceDto>().GetGridPageFromCollection(args)); }
public IEnumerable <IUserPreferenceDto> GetAll(ServiceArgs args = null) { if (args != null && args.ContainsKey("ControlId") && args.ContainsKey("UserGuid")) { var controlId = args["ControlId"].ToString(); var userGuid = Guid.Parse(args["UserGuid"].ToString()); var sql = @"SELECT * FROM Access.UserPreferences WHERE UserGuid = @UserGuid AND ControlId = @ControlId"; var param = new { UserGuid = userGuid, ControlId = controlId }; var result = Conn.Query <UserPreferenceDto>(sql, param, null, true, null, CommandType.Text).ToList <IUserPreferenceDto>(); return(result); } throw new NotImplementedException(); }
public IEnumerable <IReleaseNoteDto> GetAll(ServiceArgs args = null) { string version = null, userGuid = null; if (args != null && args.ContainsKey("Version")) { version = args["Version"].ToString(); } if (args != null && args.ContainsKey("UserGuid")) { userGuid = args["UserGuid"].ToString(); } var query = GetReleaseNoteQuery(userGuid); if (!string.IsNullOrWhiteSpace(version)) { query = query.Where(x => x.Version == version); } return(query.ToList()); }
public async Task <IEnumerable <KeyValuePair <string, string> > > GetDisplayListAsync(ServiceArgs args = null) { // Load Arguments. bool?selfScan = null; if (args != null && args.ContainsKey("AllowSelfScan") && bool.TryParse(args["AllowSelfScan"].ToString(), out var self)) { selfScan = self; } bool?selfAnalysis = null; if (args != null && args.ContainsKey("AllowScanAnalysis") && bool.TryParse(args["AllowScanAnalysis"].ToString(), out var analysis)) { selfAnalysis = analysis; } bool?hideFromReports = null; if (args != null && args.ContainsKey("HideFromReports") && bool.TryParse(args["HideFromReports"].ToString(), out var hide)) { hideFromReports = hide; } // Load Parameter. var param = new { User.UserGuid, AllowSelfScan = selfScan, AllowScanAnalysis = selfAnalysis, HideFromReports = hideFromReports }; // Return Display List. return((await Conn.QueryAsync(sql: "Access.usp_GetShopDisplayList", param: param, commandType: CommandType.StoredProcedure)) .Select(s => new KeyValuePair <string, string>(s.ShopGuid.ToString(), s.ShopName)).ToList()); }
private static object ParamsFromArgs(Guid userGuid, ServiceArgs args = null) { var sort = (args != null && args.ContainsKey("SortOrder") ? args["SortOrder"].ToString() : string.Empty).Replace(",", "").Split(' '); return(new { UserGuid = userGuid, RepairId = args != null && args.ContainsKey("RepairId") && int.TryParse(args["RepairId"].ToString(), out var repairId) ? repairId : 0, AgingRepairs = args != null && args.ContainsKey("AgingRepairs") && bool.TryParse(args["AgingRepairs"].ToString(), out var isAgingRepairs) && isAgingRepairs, Search = args != null && args.ContainsKey("SearchPhrase") ? args["SearchPhrase"].ToString() : string.Empty, RepairStatusId = args != null && args.ContainsKey("StatusFilter") && Enum.TryParse(args["StatusFilter"].ToString(), out RepairStatuses status) ? status : RepairStatuses.Active, ShopGuid = args != null && args.ContainsKey("ShopGuid") && Guid.TryParse(args["ShopGuid"].ToString(), out var shopGuid) ? shopGuid : Guid.Empty, CurrentPage = args != null && args.ContainsKey("CurrentPage") && int.TryParse(args["CurrentPage"].ToString(), out var page) ? page : 1, RowCount = args != null && args.ContainsKey("RowCount") && int.TryParse(args["RowCount"].ToString(), out var rows) ? rows : 25, SortCol = sort.Length > 0 ? sort[0] : "CreatedDt", SortDir = sort.Length > 1 ? sort[1] : "DESC", });
public IEnumerable <IAccountDto> GetAll(ServiceArgs args = null) { var result = new List <IAccountDto>(); if (!UserHasRoles(ApplicationRoles.AccountView, ApplicationRoles.AccountEdit)) { return(result); } if (AllowedAccounts != null) { var query = AllowedAccounts .Include(a => a.State) .Include(a => a.AccountUsers) .Include(a => a.AccountUsers.Select(au => au.User)); if (args != null && args.ContainsKey("Light") && bool.TryParse(args["Light"].ToString(), out var light) && light) { query = AllowedAccounts; } if (args != null && args.ContainsKey("AccountName") && args["AccountName"] != null) { var shopName = args["AccountName"].ToString(); query = query.Where(x => x.Name == shopName); } if (args != null && args.ContainsKey("NotAccountGuid") && Guid.TryParse(args["NotAccountGuid"].ToString(), out var notAccountGuid)) { query = query.Where(x => x.AccountGuid != notAccountGuid); } result.AddRange(query.ToList().Select(Mapper.Map <AccountDto>)); } return(result); }
public IEnumerable <ITechnicianProfileDto> GetAll(ServiceArgs args = null) { if (args != null && args.ContainsKey("ProfileCoverage")) { return(AvailableProfiles .Include(d => d.Schedules) .Include(d => d.TimeOffEntries) .ToList().Select(p => Mapper.Map <TechnicianProfileEntityModel, TechnicianProfileDto>(p, opts => opts.Items["TimeZoneInfoId"] = User.TimeZoneInfoId))); } return(AvailableProfiles .Include(d => d.User) .Include(d => d.VehicleMakes) .Include(d => d.VehicleMakes.Select(m => m.VehicleMake)) .Include(d => d.Schedules) .Include(d => d.TimeOffEntries) .ToList().Select(p => Mapper.Map <TechnicianProfileEntityModel, TechnicianProfileDto>(p, opts => opts.Items["TimeZoneInfoId"] = User.TimeZoneInfoId))); }
public IEnumerable <IDiagnosticQueueDto> GetAll(ServiceArgs args = null) { // Create Result. var result = new List <IDiagnosticQueueDto>(); // Check Args. if (args == null) { return(result); } try { // Shop Guid. Guid shopGuid = new Guid(); if (args.ContainsKey("ShopGuid")) { Guid.TryParse(args["ShopGuid"].ToString(), out shopGuid); } // Load Params. var param = new { ShopGuid = shopGuid, User.UserGuid }; // Load Scan Queue. result.AddRange(Conn.Query <DiagnosticQueueDto>("Diagnostic.usp_GetDiagnosticQueueByShop", param, commandType: CommandType.StoredProcedure).ToList()); } catch (Exception e) { Logger.LogException(e); } return(result); }
public async Task <IEnumerable <INoteDto> > GetAllAsync(ServiceArgs args = null) { // Create Result. var result = new List <NoteDto>(); // Load Uploads. var query = Db.Notes.Where(u => !u.NoteDeletedInd); // Check Upload Type & Key. if (!(args?.ContainsKey("NoteTypeId") ?? false) || !args.ContainsKey("NoteKey") || !int.TryParse(args["NoteTypeId"]?.ToString(), out var type)) { return(result); } // Query Data. var key = args["NoteKey"].ToString(); query = query.Where(u => u.NoteTypeId == type && u.NoteKey == key).OrderByDescending(x => x.NoteId); // Load Uploads. var notes = await query.ToListAsync(); // Convert to Dto. var mapped = notes.Select(u => Mapper.Map <NoteEntityModel, NoteDto>(u, opts => opts.AfterMap((src, dest) => { dest.UpdatedDateTime = src.UpdatedDt == null ? src.CreatedDt.ConvertToUserTime(User.TimeZoneInfoId) : src.UpdatedDt.Value.ConvertToUserTime(User.TimeZoneInfoId); dest.UpdatedByUser = src.UpdatedByUserGuid == null ? src.CreatedBy.GetDisplayName : src.UpdatedBy.GetDisplayName; }))).ToList(); // Load Result. result.AddRange(mapped); // Return. return(result); }