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);
        }
示例#3
0
        // =======================================================================================================================================
        // 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());
            }
        }
示例#4
0
        // 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);
        }
示例#5
0
        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);
        }
示例#6
0
        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;
 }
示例#8
0
        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);
        }
示例#9
0
        public CreateCustomerCommandTests()
        {
            _dapperService = A.Fake <DapperService>();

            _createCustomerCommand =
                new CreateCustomerCommand(A.Fake <IOptions <ApplicationConfiguration> >(), _dapperService);
        }
示例#10
0
        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);
        }
示例#12
0
        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);
        }
示例#13
0
 public MainService(
     AccessFacadeService accessFacadeService,
     DapperService dapperService,
     AdoService adoService,
     EFCoreService eFCoreService)
 {
     this.accessFacadeService = accessFacadeService;
     this.dapperService       = dapperService;
     this.adoService          = adoService;
     this.eFCoreService       = eFCoreService;
 }
示例#14
0
        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());
        }
示例#15
0
 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;
 }
示例#17
0
        /// <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");
        }
示例#18
0
        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 }));;
        }
示例#19
0
        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 + "');"));
            }
        }
示例#20
0
 // =======================================================================================================================================
 // 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);
     }
 }
示例#21
0
 // =======================================================================================================================================
 // 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;
     }
 }
示例#22
0
 // =======================================================================================================================================
 // 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;
 }
示例#24
0
        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;
 }
示例#26
0
        public static IEnumerable <RegionsModel> GetFull(DapperService db, int id)
        {
            IEnumerable <RegionsModel> ret = db.Query <RegionsModel>("GetRegionFullAreaName", new { Id = id }, commandType: CommandType.StoredProcedure);

            return(ret);
        }
示例#27
0
 public ReportsController(DapperService _dapperService)
 {
     dapperService = _dapperService;
 }
示例#28
0
 public RegionsService(DapperService db)
 {
     this.db = db;
 }
 public GetProductBundlesQuery(IOptions <ApplicationConfiguration> applicationConfiguration,
                               DapperService dapperService)
 {
     _applicationConfiguration = applicationConfiguration;
     _dapperService            = dapperService;
 }
示例#30
0
 public OrdersController(IOrdersService service, DapperService _dapperService)
 {
     dapperService = _dapperService;
     ordersService = service;
 }