public PaymentController(DapperService dapperService, IPaymentService paymentService, ICenterService centerService) { _dapperService = dapperService; _centerService = centerService; _paymentService = paymentService; }
public AddProductToOrderCommandTests() { _dapperService = A.Fake <DapperService>(); _addProductToOrderCommand = new AddProductToOrderCommand(A.Fake <IOptions <ApplicationConfiguration> >(), _dapperService); }
// ======================================================================================================================================= // Book people into the supplied meeting ID: // ======================================================================================================================================= public string AddPersonsMulti(int meetingId, Person[] persons) { try { var table = new DataTable(); table.Columns.Add("Row", typeof(int)); table.Columns.Add("Seat", typeof(int)); table.Columns.Add("Name", typeof(string)); table.Columns.Add("Email", typeof(string)); foreach (var p in persons) { table.Rows.Add(new object[] { p.Row, p.Seat, p.Name, p.Email }); } using (var db = new DapperService()) { var parameters = new DynamicParameters(new { @meetingId = meetingId, @persons = table.AsTableValuedParameter("PersonType") }); parameters.Add(name: "@message", dbType: DbType.String, size: 1000, direction: ParameterDirection.Output); var results = db.Connection.Query <Models.Person>(sql: "dbo.sp_person_add_multi", param: parameters, commandType: System.Data.CommandType.StoredProcedure); return(parameters.Get <string>("@message") ?? ""); } } catch (Exception e) { return(e.ToString()); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); //injeção de dependência dos bancos / connectionString Configuration = Injection.Configuration; var connectionString = Configuration["ConnectionStrings:SqlServer"]; //injetando serviço do dapper var dapperContext = new DapperContext(connectionString); var dapperRepository = new DapperRepository(dapperContext); var dapperService = new DapperService(dapperRepository); services.AddSingleton <DapperService>(dapperService); //injetando serviço do entity var entityContext = new EntityContext(connectionString); var entityRepository = new EntityRepository(entityContext); var entityService = new EntityService(entityRepository); services.AddSingleton <EntityService>(entityService); //injetando serviço do datareader var readerContext = new DataReaderContext(connectionString); var readerRepository = new DataReaderRepository(readerContext); var readerService = new DataReaderService(readerRepository); services.AddSingleton <DataReaderService>(readerService); }
public static bool checkForExists(DapperService db, int id) { RegionsModel ret = null; ret = db.QueryFirst(ret, "SELECT * FROM Regions where Id=@Id", new { Id = id }); return(ret != null); }
public static string GetRegionFullAreaName(DapperService db, int id) { RegionsModel ret2 = null; string ret = db.QueryFirst(ret2, "GetRegionFullAreaName", new { Id = id }, commandType: CommandType.StoredProcedure)?.Name.Trim(); return(ret); }
public ProfessorController( IProfessorService professorService , IProfessorScoreService professorScoreService , IEducationalGroupService educationalGroupService , ICollegeService collegeService , ITermService termService , IIndicatorService indicatorService , IRoleAccessService roleAccessService , IUserRoleService userRoleService , ILogService logService , IEducationalClassService educationalClassService ) { _professorService = professorService; _professorScoreService = professorScoreService; _educationalGroupService = educationalGroupService; _collegeService = collegeService; _termService = termService; _indicatorService = indicatorService; _roleAccessService = roleAccessService; _userRoleService = userRoleService; _reportService = new DapperService(educationalGroupService); _logService = logService; _educationalClassService = educationalClassService; }
public static IEnumerable <OrdersModel> GetOrdersByRegionId(DapperService db, int regionId) { List <OrdersModel> items = new List <OrdersModel>(); db.ClearParams(); db.AddParam("@regionId", DbType.Int32, regionId); string query = @" select distinct o.*, u.FirstName + ' ' + u.LastName as CustomerName from Orders o left join Users u on u.Id = o.UserId where o.RegionId = @regionId order by o.Id"; using (IDataReader reader = db.Select(query)) { while (reader.Read()) { OrdersModel ret = new OrdersModel(); ret.Id = (int)reader["Id"]; ret.Status = (int)reader["Status"]; ret.Sum = (decimal)reader["Sum"]; ret.CreatedTime = (DateTime)reader["CreatedTime"]; ret.UserId = ret.User.Id = (int)reader["UserId"]; ret.RegionId = ret.User.Id = (int)reader["RegionId"]; ret.Region.Name = RegionsService.GetRegionFullAreaName(db, ret.RegionId); ret.User.FullName = (string)reader["CustomerName"]; items.Add(ret); } } return(items); }
public CreateCustomerCommandTests() { _dapperService = A.Fake <DapperService>(); _createCustomerCommand = new CreateCustomerCommand(A.Fake <IOptions <ApplicationConfiguration> >(), _dapperService); }
public static List <ItemsModel> getValidItemsList(DapperService db, IEnumerable <int> Ids) { List <ItemsModel> items = new List <ItemsModel>(); items = (List <ItemsModel>)db.Query <ItemsModel>("SELECT * FROM Items where Id in (" + String.Join(",", Ids) + ")"); return(items); }
public GetProductsBundlesQueryTests() { _dapperService = A.Fake <DapperService>(); _getProductBundlesQuery = new GetProductBundlesQuery(A.Fake <IOptions <ApplicationConfiguration> >(), _dapperService); }
public static UsersModel GetAuthUser(DapperService db, string login, string pass) { UsersModel user = null; string hashPassword = MD5HAshing.Hash(pass); user = db.QueryFirst <UsersModel>(user, "select * from users where Login = @login and Password = @pass", new { login, pass = hashPassword }); return(user); }
public MainService( AccessFacadeService accessFacadeService, DapperService dapperService, AdoService adoService, EFCoreService eFCoreService) { this.accessFacadeService = accessFacadeService; this.dapperService = dapperService; this.adoService = adoService; this.eFCoreService = eFCoreService; }
public ActionResult Index() { using (IDbConnection conn = DapperService.MySqlConnection()) { var list = conn.Query <AreaDto>("SP_Area_QueryList", commandType: CommandType.StoredProcedure).ToList(); CommonHelp.list = list; ViewBag.date = DateTime.Now; } return(View()); }
public ValuesController( AccessFacadeService accessFacadeService, DapperService dapperService, AdoService adoService, EFCoreService eFCoreService) { this.accessFacadeService = accessFacadeService; this.dapperService = dapperService; this.adoService = adoService; this.eFCoreService = eFCoreService; }
public RegistrationEntranceFormBase(IWebHostEnvironment hostingEnvironment, ICenterService centerService, ProtectedSessionStorage protectedSessionStorage, UserManager <ApplicationUser> userManager, HttpClient httpClient, IJSRuntime js, DapperService dapperService, IPaymentService paymentService) { _paymentService = paymentService; _hostingEnvironment = hostingEnvironment; _httpClient = httpClient; CenterService = centerService; ProtectedSessionStorage = protectedSessionStorage; UserManager = userManager; Js = js; this.dapperService = dapperService; }
/// <summary> /// 登录 /// </summary> /// <param name="account">账号</param> /// <param name="pwd">密码</param> /// <returns>1=正确 0=密码错误 -1=无此账号 </returns> public string Login(User u) { List <User> user = DapperService <User> .QuerySqlString($"select * from user where Account='{u.Account}'"); if (user.Count != 0) { if (user[0].Password == u.Password) { return("1001"); } return("1002"); } return("1003"); }
public JsonResult Get(int id, [FromServices] DapperService db) { if (id < 1) { return(Json(new { message = "не найден" })); } IEnumerable <RegionsModel> regionsModel = RegionsService.GetFull(db, id); if (regionsModel == null || regionsModel.Count() == 0) { return(Json(new { message = "не найден" }));; } return(Json(new { message = regionsModel }));; }
public int InsertAuthorList(Author author) { List <Author> a = DapperService <Author> .QuerySqlString("select * from author where LongID='" + author.LongID + "'"); //user(Account, Password, CreateTime) values(@Account, @Password, @CreateTime) if (a.Count != 0) { return(0); } else { return(DapperService <Author> .ExcuteSqlString("INSERT INTO `codeshuai`.`author` (`LongID`,`Desc`,`Name`) VALUES ('" + author.LongID + "','" + author.Desc + "','" + author.Name + "');")); } }
// ======================================================================================================================================= // Clear all bookings from the supplied meeting ID. NOTE: This method has been written for testing purposes: // ======================================================================================================================================= public bool ResetMeeting(int meetingId) { try { using (var db = new DapperService()) { var parameters = new DynamicParameters(new { @meetingId = meetingId }); var results = db.Connection.Query <Models.Person>(sql: "dbo.sp_reset_meeting", param: parameters, commandType: System.Data.CommandType.StoredProcedure); return(true); } } catch (Exception) { return(false); } }
// ======================================================================================================================================= // Get the persons booked into the supplied meeting ID: // ======================================================================================================================================= public Person[] GetPersonsByMeetingId(int meetingId) { try { using (var db = new DapperService()) { var parameters = new DynamicParameters(new { @meetingId = meetingId }); var results = db.Connection.Query <Models.Person>(sql: "dbo.sp_persons_by_meetingid", param: parameters, commandType: System.Data.CommandType.StoredProcedure); return(results.ToArray()); } } catch (Exception) { throw; } }
// ======================================================================================================================================= // Get the meeting details for the supplied ID: // ======================================================================================================================================= public Models.Meeting GetMeetingById(int meetingId) { try { using (var db = new DapperService()) { var parameters = new DynamicParameters(new { @meetingId = meetingId }); var results = db.Connection.Query <Models.Meeting>(sql: "dbo.sp_meeting_by_id", param: parameters, commandType: System.Data.CommandType.StoredProcedure); return(results.FirstOrDefault()); } } catch (Exception) { throw; } }
public CollegeController( ICollegeService collegeService , ICollegeScoreService collegeScoreService , IEducationalGroupService educationalGroupService , ITermService termService , IRoleAccessService roleAccessService , IUserRoleService userRoleService , ILogService logService ) { _collegeService = collegeService; _collegeScoreService = collegeScoreService; _educationalGroupService = educationalGroupService; _termService = termService; _reportService = new DapperService(educationalGroupService); _roleAccessService = roleAccessService; _userRoleService = userRoleService; _logService = logService; }
static void Main(string[] args) { var customers = GenerateCustomers(1000); var efService = new EfService(); efService.AddRange(BenchmarkResults, customers); efService.Filtering(BenchmarkResults, customers); efService.UpdateRange(BenchmarkResults, customers); efService.RemoveRange(BenchmarkResults, customers); customers = GenerateCustomers(1000); var dapperService = new DapperService(); customers = dapperService.AddRange(BenchmarkResults, customers); dapperService.Filtering(BenchmarkResults, customers); customers = dapperService.UpdateRange(BenchmarkResults, customers); dapperService.RemoveRange(BenchmarkResults, customers); customers = GenerateCustomers(1000); var linq2DbService = new Linq2DbService(); customers = linq2DbService.AddRange(BenchmarkResults, customers); linq2DbService.Filtering(BenchmarkResults, customers); customers = linq2DbService.UpdateRange(BenchmarkResults, customers); linq2DbService.RemoveRange(BenchmarkResults, customers); customers = GenerateCustomers(1000); var nhService = new NHibernateService(); customers = nhService.AddRange(BenchmarkResults, customers); nhService.Filtering(BenchmarkResults, customers); customers = nhService.UpdateRange(BenchmarkResults, customers); nhService.RemoveRange(BenchmarkResults, customers); Console.Clear(); foreach (var result in BenchmarkResults) { Console.WriteLine($"{result.Action}\t {result.Entities}\t {result.Performance}"); } }
public EducationalGroupController( IEducationalGroupService educationalGroupService , ITermService termService , IIndicatorService indicatorService , IEducationalGroupScoreService educationalGroupScoreService , IScoreService scoreService , ICollegeService collegeService , IRoleAccessService roleAccessService , IUserRoleService userRoleService , ILogService logService ) { _educationalGroupService = educationalGroupService; _termService = termService; _indicatorService = indicatorService; _educationalGroupScoreService = educationalGroupScoreService; _scoreService = scoreService; _collegeService = collegeService; _reportService = new DapperService(educationalGroupService); _roleAccessService = roleAccessService; _userRoleService = userRoleService; _logService = logService; }
public static IEnumerable <RegionsModel> GetFull(DapperService db, int id) { IEnumerable <RegionsModel> ret = db.Query <RegionsModel>("GetRegionFullAreaName", new { Id = id }, commandType: CommandType.StoredProcedure); return(ret); }
public ReportsController(DapperService _dapperService) { dapperService = _dapperService; }
public RegionsService(DapperService db) { this.db = db; }
public GetProductBundlesQuery(IOptions <ApplicationConfiguration> applicationConfiguration, DapperService dapperService) { _applicationConfiguration = applicationConfiguration; _dapperService = dapperService; }
public OrdersController(IOrdersService service, DapperService _dapperService) { dapperService = _dapperService; ordersService = service; }