public void CreatePersonTest() { using (var context = new CoreContext()) { var person = new Person {Age = 25}; context.Entities.Add(person); context.SaveChanges(); Assert.IsTrue(person.Id > 0); person = context.People.FirstOrDefault(x => x.Id == person.Id); Assert.IsNotNull(person); } }
public UserRepository(CoreContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public static CoreEntity GetEntityWithId(this CoreContext context, int value) { return(((Entitas.PrimaryEntityIndex <CoreEntity, int>)context.GetEntityIndex(Contexts.Id)).GetEntity(value)); }
public RoleRepository(CoreContext context) : base(context) { }
public AutoStatusChangeCommandHandler(CoreContext context) { _context = context; }
public BaseDataAccess(CoreContext context) { _context = context; _entity = context.Set <T>(); }
public UpdateFunSystem(Contexts contexts) { context = contexts.core; entities = context.GetGroup(CoreMatcher.AllOf(CoreMatcher.Flatmate, CoreMatcher.Fun, CoreMatcher.ActiveAction)); }
public TaskService(CoreContext context, IUserProvider userProvider) { CaseNoteTasksService = new CaseNoteTasksService(context); ReferralNoteTasksService = new ReferralNoteTasksService(context); UserProvider = userProvider; }
//Must include a Configure method to create the app's request processing pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, CoreContext dbContext) { ApplicationDbContext.EntityContext = () => dbContext; //How to pipeline works //app.Use(async (context, next) => //{ // Console.WriteLine("Hello pipeline! {0}", context.Request.Path); // await next(); //}); loggerFactory.AddConsole(); //Log To Console loggerFactory.AddDebug(); //Log To Output //For Log To File: //loggerFactory.AddProvider(new NLogLoggerProvider()); //add NLog to ASP.NET Core //loggerFactory.AddNLog(); //add NLog.Web //app.AddNLogWeb(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler(); } //app.UseDefaultFiles(); app.UseStaticFiles(); // For the wwwroot folder app.UseStatusCodePages(); //Middleware pipeline //attribute base for routing! app.UseMvc();//Middleware pipeline //app.UseMvc(config => //{ // config.MapRoute( // name: "Default", // template: "{controller}/{action}/{id?}", // defaults: new { controller = "App", action = "Index" }, // constraints: new { id = @"\d+" } // ); //}); //app.Run((context) => //{ // throw new Exception("new exception!"); //}); //app.Run(async (context) => //{ // await context.Response.WriteAsync("Hello World!"); //}); }
/// <summary> /// Initializes a new instance of the <see cref="RoleController"/> class. /// </summary> /// <param name="dbContext">The dbContext.</param> /// <param name="mapper">The mapper.</param> public RoleController(CoreContext dbContext, IMapper mapper) : base(dbContext, mapper) { }
public GJournalRepository(CoreContext context) : base(context) { }
public CoreGetByIdQuery(CoreContext context) { _context = context; }
/// <summary> /// Use to get controller's instance from context you passed as parameter. /// </summary> /// <param name="_coreContext">Type of controller from which you want to get instance</param> /// <returns>Return instance of specific controller</returns> public static T GetController <T>(CoreContext _coreContext) where T : UiCoreController <TUiPanelElement, TUiContext> { return(coreInstances[_coreContext] as T); }
public PrivilegeRepository(CoreContext context) : base(context) { }
public VideoRepository(CoreContext dbContext) : base(dbContext) { }
public GenericRepository(CoreContext context) { _context = context; }
public AppController(CoreContext context, ILogger <AppController> logger) { _logger = logger; _context = context; _pageDataServices = new PageDataServices(context, logger); }
public MedicalExamRepository(CoreContext context) : base(context) { }
protected override CommandResult <Hashtable> OnExecute(object commandParameter) { var result = new CommandResult <Hashtable>(); var param = commandParameter as DrawPrizeParameter; result.Data = new Hashtable(); using (CoreContext context = new CoreContext()) { var act = context.ActivityInfo.Where(a => a.StartTime <= DateTime.Now && a.EndTime >= DateTime.Now && a.Status == 1 && a.Kind == param.Kind).FirstOrDefault(); if (act == null) { result.ErrorCode = -1; result.ErrorMessage = "活动已结束"; return(result); } Hashtable pconfig = JsonConvert.DeserializeObject <Hashtable>(act.ProductConfig); var zlopenid = context.MemberInfo.Where(m => m.AccountId == param.MemberAccount).Select(m => m.ZlOpenId).FirstOrDefault(); //扣减次数,使用数据库锁 if (context.Database.ExecuteSqlCommand(@"update member_draw_count set current_count=(current_count-1) where member_account=@p0 and current_count-1>=0", zlopenid) > 0) { var LogCount = context.ActivityLog.Where(l => l.MemberAccount == zlopenid && l.ActivityId == act.Recid).Count(); var res = new NewMemberSkillCommand().Execute(new NewMemberSkillParameter() { MemberAccount = zlopenid, LogCount = LogCount, Prize = pconfig }); Hashtable prize = null; if (res.ErrorCode == 0 && (Convert.ToBoolean(res.Data["isNew"]) || Convert.ToBoolean(res.Data["is30"]))) { result.ErrorCode = res.ErrorCode; result.ErrorMessage = res.ErrorMessage; prize = res.Data["Prize"] as Hashtable; } else { var connect = ConfigurationUtil.GetSection("ConnectionStrings")["ShopConnectString"]; decimal payFee = 0; using (MySqlConnection con = new MySqlConnection(connect)) { con.Open(); MySqlCommand com1 = new MySqlCommand("select sum(payment_fee) as PayFee from shop_order_info " + "where member_account=?acc and pay_status=1 and order_no like '%00' and date(payment_time)>='2018-11-01' and date(payment_time)<='2018-11-11' ", con); com1.Parameters.Add(new MySqlParameter("?acc", zlopenid)); var Reader1 = com1.ExecuteReader(); while (Reader1.Read()) { if (Reader1["PayFee"] != DBNull.Value) { payFee = Convert.ToDecimal(Reader1["PayFee"]); } } Reader1.Close(); con.Close(); } //遍历奖品规则 var redisdb = RedisClient.GetDatabase(1); foreach (var item in (pconfig["PayPrize"] as JArray).ToObject <List <Hashtable> >()) { JObject condiction = item["Condition"] as JObject; string key = "level:" + condiction["Fee"].Value <string>(); if (redisdb.HashExists(key, param.MemberAccount)) { continue; } if (payFee >= condiction["Fee"].Value <decimal>()) { prize = (item["Prize"] as JObject).ToObject <Hashtable>(); //处理实物奖品 if (prize["Kind"] as string == "RealPrize") { //var hash = (prize["RealPrize"] as JObject).ToObject<Hashtable>(); var _realprize = new List <PrizeModel>(); foreach (var hash in (prize["RealPrize"] as JArray).ToObject <List <Hashtable> >()) { if (DateTime.Parse(hash["start"] as string) <= DateTime.Now && DateTime.Parse(hash["end"] as string) >= DateTime.Now) { _realprize.Add(new PrizeModel() { PrizeCode = hash["PrizeCode"] as string, PrizeName = hash["PrizeName"] as string, Kind = prize["Kind"] as string }); } } string RealPrize = ""; if (_realprize.Count != 0) { var r = new Random(Guid.NewGuid().GetHashCode()); var index = r.Next(0, _realprize.Count); RealPrize = redisdb.ListLeftPop("Prize:" + _realprize[index].PrizeCode); } if (!string.IsNullOrEmpty(RealPrize)) { prize = JsonConvert.DeserializeObject <Hashtable>(RealPrize); } else { prize = null; } } if (prize != null) { redisdb.HashIncrementAsync(key, param.MemberAccount); } break; } } } if (prize != null) { result.Data = prize; var p = new PrizeInfo() { Status = 1, ActId = act.Recid, CouponId = Convert.ToInt32(prize["CouponId"]), CreateDate = DateTime.Now, MemberAccount = zlopenid, PrizeCode = prize["PrizeCode"] as string, PrizeName = prize["PrizeName"] as string, Kind = prize["Kind"] as string, }; context.PrizeInfo.Add(p); if (prize["Kind"] as string == "Coupon") { //调用获取优惠券 var url = ConfigurationUtil.GetSection("CouponUrl").Value as string; //领取抵扣优惠券 try { ActiveMQMessagePusher.Push("Command", new Dictionary <string, string> { { "caller", "Restful" }, { "url", url } }, new { MemberAccount = zlopenid, RuleId = Convert.ToInt32(prize["CouponId"]) } ); } catch (Exception) { } //var couponres = ZlanAPICaller.Call<CommandResult<string>>(url, new { MemberAccount = zlopenid, RuleId = Convert.ToInt32(prize["CouponId"]) }); //if (couponres.ErrorCode == 0) //{ // couponticket = couponres.Data; //} //else //{ // LogUtil.Log("DrawPrize_TakeCoupon", p.Recid.ToString(), $"input=>{JsonConvert.SerializeObject(new { MemberAccount = zlopenid, RuleId = Convert.ToInt32(prize["CouponId"]) })}#error=>{res.ErrorMessage}"); //} } } else { result.ErrorMessage = "未中奖,换个姿势再试试吧"; result.ErrorCode = -22; } } else { result.ErrorCode = -21; result.ErrorMessage = "每下单68元,即获得一次抽奖机会,上不封顶"; } context.ActivityLog.Add(new ActivityLog() { MemberAccount = zlopenid, ActivityId = act.Recid, CreateTime = DateTime.Now, Memo = result.Data.Keys.Count > 0 ? "抽中:" + result.Data["PrizeName"] as string : result.ErrorMessage }); context.SaveChanges(); } return(result); }
protected override string GetAccount(CoreContext coreContext, string openeId) { return(coreContext.MemberInfo.Where(m => m.XcxOpenId == openeId).Select(m => m.AccountId).FirstOrDefault()); }
public CoreEntityInsertCommand(CoreContext context) { _context = context; _dbset = context.Set <TMdl>(); }
public BaseRepository(CoreContext context) { _context = context; }
public DurationTimeoutSystem(Contexts contexts) { this.context = contexts.core; this.command = contexts.command; timedObjects = context.GetGroup(CoreMatcher.AllOf(CoreMatcher.ActionDuration, CoreMatcher.FlatmateId)); }
public UpdateEnterRoomCleanlinessOpinionSystem(Contexts contexts) : base(contexts.core) { coreContext = contexts.core; flatmates = coreContext.GetGroup(CoreMatcher.AllOf(CoreMatcher.FlatmateId)); }
protected RepoBase() { Db = new CoreContext(); Table = Db.Set <T>(); }
public SpecialtyRepository(CoreContext context) : base(context) { }
protected RepoBase(DbContextOptions <CoreContext> options) { Db = new CoreContext(options); Table = Db.Set <T>(); }
public LeaveGameCommandHandler(CoreContext context, IMediator mediator) { _context = context; _mediator = mediator; }
public CategoryComand(CoreContext CoreContext) { _CoreContext = CoreContext; }
public CaseNotesService(CoreContext context) : base(SourceType.Case, context, new CaseNoteTasksService(context)) { }
public SimplePlaceholderRepository(CoreContext context) : base(context) { }