public void RunNestedListCreateExample(AerospikeClient client, Arguments args) { Key key = new Key(args.ns, args.set, "mapkey3"); string binName = args.GetBinName("mapbin"); // Delete record if it already exists. client.Delete(args.writePolicy, key); IList <Value> l1 = new List <Value>(); l1.Add(Value.Get(7)); l1.Add(Value.Get(9)); l1.Add(Value.Get(5)); IDictionary <Value, Value> inputMap = new Dictionary <Value, Value>(); inputMap[Value.Get("key1")] = Value.Get(l1); // Create maps. client.Put(args.writePolicy, key, new Bin(binName, inputMap)); // Create ordered list at map's "key2" only if list does not exist. // Append 2,1 to ordered list. CTX ctx = CTX.MapKey(Value.Get("key2")); Record record = client.Operate(args.writePolicy, key, ListOperation.Create(binName, ListOrder.ORDERED, false, ctx), ListOperation.Append(binName, Value.Get(2), ctx), ListOperation.Append(binName, Value.Get(1), ctx), Operation.Get(binName) ); record = client.Get(args.policy, key); console.Info("Record: " + record); }
public AccountController(UserManager <User> userManager, SignInManager <User> signInManager, CTX context) { _context = context; _userManager = userManager; _signInManager = signInManager; }
public override async Task <bool> ExecuteCheckAsync(CommandContext ctx, bool help) { CannotBeUsedInDMAttribute checkDM = new CannotBeUsedInDMAttribute(); if (!await checkDM.ExecuteCheckAsync(ctx, help)) { return(false); } var app = ctx.Client.CurrentApplication; if (app != null) { bool success = help || ctx.Member == ctx.Guild.Owner || app.Owners.Any(x => x.Id == ctx.User.Id); if (!success && !string.IsNullOrWhiteSpace(failMessage)) { await CTX.RespondSanitizedAsync(ctx, failMessage); } return(success); } var me = ctx.Client.CurrentUser; return(ctx.User.Id == me.Id); }
public override void Process(opis message) { //CTX.Handle(CTX.GoUp()); //message.body = CTX.organizer; message.body = CTX.GoUp().V(context.Organizer); }
void DrawArrayProperty(string key, ParserItem it) { if (CanDraw) { // Create Key Item var KeyItem = CreateTextLayout(string.Format("\"{0}\"", key)); // Create rectangle var rect = new Rectangle(X, Y, KeyItem.GetSize().Width, KeyItem.GetSize().Height).Inflate(0.2, 0.2); // Clikable item CreateClickableItem((double)X, (double)Y, KeyItem.GetSize().Width, KeyItem.GetSize().Height, it); // Draw rect CTX.SetColor(Colors.DarkGreen); CTX.Rectangle(rect); CTX.Fill(); CTX.SetLineWidth(1); CTX.Stroke(); CTX.SetColor(Colors.White); CTX.DrawTextLayout(KeyItem, X, Y); CTX.SetColor(Colors.Black); // Draw [ double newX = X + KeyItem.GetSize().Width + 0.2; CTX.DrawTextLayout(CreateTextLayout(" : ["), newX, Y); } }
protected private Web GetWorkingWeb() { if (MyInvocation.BoundParameters.ContainsKey("InputObject")) { if (!((Web)this.InputObject.ShowOriginal()).Lists.AreItemsAvailable) { this.InputObject.LoadProperty("Lists"); } return(this.InputObject.ShowOriginal() as Web); } else if (MyInvocation.BoundParameters.ContainsKey("Web")) { if (!this.Web.Lists.AreItemsAvailable) { CTX.Lae(this.Web.Lists); } return(this.Web); } else { if (!CTX.SP1.Web.Lists.AreItemsAvailable) { CTX.Lae(CTX.SP1.Web.Lists); } return(CTX.SP1.Web); } }
public override async Task <bool> ExecuteCheckAsync(CommandContext ctx, bool help) { var app = ctx.Client.CurrentApplication; if (app == null) { return(false); } if (help || app.Owners.Any(x => x.Id == ctx.User.Id)) { return(true); } var userLevel = ctx.Member != null? UserLevels.GetMemberLevel(ctx.Member) : UserLevels.GetLevel(ctx.User.Id, ctx.Guild.Id); if (ctx.Member == ctx.Guild.Owner && userLevel < (int)ShimaConsts.UserPermissionLevel.DEFAULT_SERVER_OWNER) { userLevel = (int)ShimaConsts.UserPermissionLevel.DEFAULT_SERVER_OWNER; } if (userLevel < level) { if (!string.IsNullOrWhiteSpace(failMessage)) { await CTX.RespondSanitizedAsync(ctx, failMessage); } return(false); } return(true); }
public override void Process(opis message) { bool pass = (CTX.CheckParentOrder(o, message["original_msg_context"])); if (pass) { message["run_on_this_context"].body = "yepp"; } }
void DrawText(string data) { if (CanDraw) { var text = new TextLayout(); text.Font = this.Font.WithSize(12); text.Text = data; CTX.DrawTextLayout(text, X, Y); } }
public override async Task <bool> ExecuteCheckAsync(CommandContext ctx, bool help) { if (ctx.Guild != null || help) { return(true); } await CTX.RespondSanitizedAsync(ctx, failMessage); return(false); }
protected private SPListCollection GetAllLists(Web web) { var tempCol = web.Lists; if (!tempCol.AreItemsAvailable) { CTX.Lae(tempCol, true); } return((SPListCollection)tempCol); }
public override async Task <bool> ExecuteCheckAsync(CommandContext ctx, bool help) { CannotBeUsedInDMAttribute checkDM = new CannotBeUsedInDMAttribute(); if (!await checkDM.ExecuteCheckAsync(ctx, help)) { return(false); } var user = ctx.Member; if (user == null) { return(false); } var pUser = ctx.Channel.PermissionsFor(user); var bot = await ctx.Guild.GetMemberAsync(ctx.Client.CurrentUser.Id).ConfigureAwait(false); if (bot == null) { return(false); } if (help) { return(true); } var pBot = ctx.Channel.PermissionsFor(bot); var userSuccess = user.Id == ctx.Guild.Owner.Id || ((pUser & Permissions.Administrator) != 0 || (pUser & permissions) == permissions); var botSuccess = (pBot & Permissions.Administrator) != 0 || (pBot & permissions) == permissions; string failMessage = ""; if (!userSuccess) { failMessage += $"**Permissions missing for {user.DisplayName}:** " + $"{((pUser & permissions) ^ permissions).ToPermissionString()}\n"; } if (!botSuccess) { failMessage += $"**Permissions missing for {bot.DisplayName}:** " + $"{((pBot & permissions) ^ permissions).ToPermissionString()}"; } if (!string.IsNullOrWhiteSpace(failMessage)) { await CTX.RespondSanitizedAsync(ctx, failMessage); } return(userSuccess && botSuccess); }
public async Task <ActionResult <Product> > Edit(int id, [FromBody] ProductModel model) { Product product = _context.Products.Include("Photos").FirstOrDefault(x => x.ID == id); using (CTX db = _context) { if (product != null) { List <Photo> added_photos = new List <Photo>(); try { foreach (var x in product.Photos) { InitStaticFiles.DeleteImageByFileName(_env, _configuration, new string[] { "ImagesPath", "ImagesPathProduct" }, x.Path); } foreach (var photo in model.ImgsBase64) { string imageName = Path.GetRandomFileName() + ".jpg"; string pathSaveImages = InitStaticFiles .CreateImageByFileName(_env, _configuration, new string[] { "ImagesPath", "ImagesPathProduct" }, imageName, photo); added_photos.Add(new Photo { Path = imageName }); } } catch (Exception) { return(BadRequest()); } product.Name = model.Name; product.Description = model.Description; product.Price = model.Price; product.Photos.Clear(); product.Photos = added_photos; db.SaveChanges(); return(Ok(product)); } else { return(BadRequest()); } } }
public override void Process(opis message) { // !string.IsNullOrEmpty(message["original_msg_context"].V("ID")); // is wery important, because it remove situations when sentence context stub is empty // then ewery context accept inject msg, this is wrong bool pass = (CTX.CheckParentOrder(message["original_msg_context"], o)) && !string.IsNullOrEmpty(message["original_msg_context"].V("ID")); if (pass) { message["run_on_this_context"].body = "yepp"; } }
public override async Task <bool> ExecuteCheckAsync(CommandContext ctx, bool help) { CannotBeUsedInDMAttribute checkDM = skipDMMessage ? new CannotBeUsedInDMAttribute("") : new CannotBeUsedInDMAttribute(); if (!await checkDM.ExecuteCheckAsync(ctx, help)) { return(false); } var user = ctx.Member; if (user == null) { return(false); } var app = ctx.Client.CurrentApplication; if (app == null) { return(false); } if (help || user.Id == ctx.Guild.Owner.Id || app.Owners.Any(x => x.Id == ctx.User.Id)) { return(true); } var pUser = ctx.Channel.PermissionsFor(user); if ((pUser & Permissions.Administrator) != 0) { return(true); } if (!string.IsNullOrWhiteSpace(failMessage)) { await CTX.RespondSanitizedAsync(ctx, failMessage); } return(false); }
public async Task <IActionResult> markAsDone(int id) { Order order = _context.Order.FirstOrDefault(x => x.ID == id); using (CTX db = _context) { // Редактирование if (order != null) { order.isDone = true; db.SaveChanges(); return(Ok()); } else { return(BadRequest()); } // выводим данные после обновления } }
public async Task <IActionResult> AddInvoice([FromBody] InvoiceModel invoice) { Order order = _context.Order.FirstOrDefault(x => x.ID == invoice.ID); using (CTX db = _context) { // Редактирование if (order != null) { order.Invoice = invoice.Invoice; db.SaveChanges(); return(Ok(invoice)); } else { return(BadRequest()); } // выводим данные после обновления } }
void DrawColorProperty(string key, string value, Color c, ParserItem item, bool comma = true) { if (CanDraw) { double newX = X; if (key != null) { var Item = CreateTextLayout(string.Format("\"{0}\" : ", key)); CTX.DrawTextLayout(Item, X, Y); newX = X + Item.GetSize().Width; } if (DrawVisibleProperty == false) { CTX.DrawTextLayout(CreateTextLayout(value), newX, Y); return; } // Create value var Value = new TextLayout(); Value.Font.WithSize(10); Value.Text = value; var s = Value.GetSize(); var rect = new Rectangle(newX, Y, s.Width, s.Height).Inflate(0.2, 0.2); CreateClickableItem((double)newX, (double)Y, s.Width, s.Height, item); CTX.SetColor(c); CTX.Rectangle(rect); CTX.Fill(); CTX.SetLineWidth(1); CTX.Stroke(); CTX.SetColor(Colors.White); CTX.DrawTextLayout(Value, newX, Y); CTX.SetColor(Colors.Black); if (comma) { var end = CreateTextLayout(","); CTX.DrawTextLayout(end, newX + s.Width + 8, Y); } } }
//void IRep_Base<Cliente>.UpDateAsync(Cliente Entity) public async Task UpDateAsync(Cliente cliente) { CTX.Entry(cliente).State = EntityState.Modified; try { await CTX.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClienteExists(cliente.Id)) { throw new ArgumentException( $"Nada encontrado para o cliente {cliente.Nome}.", nameof(cliente.Nome)); } else { throw; } } }
public void RunNestedMapCreateExample(AerospikeClient client, Arguments args) { Key key = new Key(args.ns, args.set, "mapkey2"); string binName = args.GetBinName("mapbin"); // Delete record if it already exists. client.Delete(args.writePolicy, key); IDictionary <Value, Value> m1 = new Dictionary <Value, Value>(); m1[Value.Get("key21")] = Value.Get(7); m1[Value.Get("key22")] = Value.Get(6); IDictionary <Value, Value> m2 = new Dictionary <Value, Value>(); m2[Value.Get("a")] = Value.Get(3); m2[Value.Get("c")] = Value.Get(5); IDictionary <Value, Value> inputMap = new Dictionary <Value, Value>(); inputMap[Value.Get("key1")] = Value.Get(m1); inputMap[Value.Get("key2")] = Value.Get(m2); // Create maps. client.Put(args.writePolicy, key, new Bin(binName, inputMap)); // Create key ordered map at "key2" only if map does not exist. // Set map value to 4 for map key "key21" inside of map key "key2". CTX ctx = CTX.MapKey(Value.Get("key2")); Record record = client.Operate(args.writePolicy, key, MapOperation.Create(binName, MapOrder.KEY_VALUE_ORDERED, ctx), MapOperation.Put(MapPolicy.Default, binName, Value.Get("b"), Value.Get(4), ctx), Operation.Get(binName) ); record = client.Get(args.policy, key); console.Info("Record: " + record); }
protected override void ProcessRecord() { bool result = false; switch (ParameterSetName) { case "ByAzureLogin": result = CTX.Login(TenantName, DestinationSite, PromptBehavior); break; default: result = CTX.Login(TenantName, DestinationSite, Credential); break; } if (!result) { throw new Exception("Something went trying to authenticate!"); } else if (PassThru) { } }
public override async Task <bool> ExecuteCheckAsync(CommandContext ctx, bool help) { if (help) { return(false); } var app = ctx.Client.CurrentApplication; if (app != null) { bool success = app.Owners.Any(x => x.Id == ctx.User.Id); if (!success && !string.IsNullOrWhiteSpace(failMessage)) { await CTX.RespondSanitizedAsync(ctx, failMessage); } return(success); } var me = ctx.Client.CurrentUser; return(ctx.User.Id == me.Id); }
public Repository(CTX _db) { db = _db; dbSet = _db.Set <TEntity>(); }
public void RemoveAsync(Cliente cliente) { CTX.Clientes.Remove(cliente); CTX.SaveChanges(); }
/// <summary> /// Operate on a map of maps. /// </summary> private void RunNestedExample(AerospikeClient client, Arguments args) { Key key = new Key(args.ns, args.set, "mapkey2"); string binName = args.GetBinName("mapbin"); // Delete record if it already exists. client.Delete(args.writePolicy, key); IDictionary <Value, Value> m1 = new Dictionary <Value, Value>(); m1[Value.Get("key11")] = Value.Get(9); m1[Value.Get("key12")] = Value.Get(4); IDictionary <Value, Value> m2 = new Dictionary <Value, Value>(); m2[Value.Get("key21")] = Value.Get(3); m2[Value.Get("key22")] = Value.Get(5); IDictionary <Value, Value> inputMap = new Dictionary <Value, Value>(); inputMap[Value.Get("key1")] = Value.Get(m1); inputMap[Value.Get("key2")] = Value.Get(m2); // Create maps. client.Put(args.writePolicy, key, new Bin(binName, inputMap)); // Set map value to 11 for map key "key21" inside of map key "key2" // and retrieve all maps. Record record = client.Operate(args.writePolicy, key, MapOperation.Put(MapPolicy.Default, binName, Value.Get("key21"), Value.Get(11), CTX.MapKey(Value.Get("key2"))), Operation.Get(binName) ); record = client.Get(args.policy, key); console.Info("Record: " + record); }
public void OperateListCreateContext() { Key key = new Key(args.ns, args.set, "oplkey20"); client.Delete(null, key); IList <Value> l1 = new List <Value>(); l1.Add(Value.Get(7)); l1.Add(Value.Get(9)); l1.Add(Value.Get(5)); IList <Value> l2 = new List <Value>(); l2.Add(Value.Get(1)); l2.Add(Value.Get(2)); l2.Add(Value.Get(3)); IList <Value> l3 = new List <Value>(); l3.Add(Value.Get(6)); l3.Add(Value.Get(5)); l3.Add(Value.Get(4)); l3.Add(Value.Get(1)); List <Value> inputList = new List <Value>(); inputList.Add(Value.Get(l1)); inputList.Add(Value.Get(l2)); inputList.Add(Value.Get(l3)); // Create list. Record record = client.Operate(null, key, ListOperation.AppendItems(new ListPolicy(ListOrder.ORDERED, 0), binName, inputList), Operation.Get(binName) ); // Append value to new list created after the original 3 lists. record = client.Operate(null, key, ListOperation.Append(binName, Value.Get(2), CTX.ListIndexCreate(3, ListOrder.ORDERED, false)), //ListOperation.Create(binName, ListOrder.ORDERED, false, CTX.ListIndex(3)), //ListOperation.Append(binName, Value.Get(2), CTX.ListIndex(3)), Operation.Get(binName) ); AssertRecordFound(key, record); IList results = record.GetList(binName); int i = 0; long count = (long)results[i++]; Assert.AreEqual(1, count); IList list = (IList)results[i++]; Assert.AreEqual(4, list.Count); // Test last nested list. list = (IList)list[1]; Assert.AreEqual(1, list.Count); Assert.AreEqual(2, (long)list[0]); }
public void OperateNestedList() { Key key = new Key(args.ns, args.set, "oplkey18"); client.Delete(null, key); IList <Value> l1 = new List <Value>(); l1.Add(Value.Get(7)); l1.Add(Value.Get(9)); l1.Add(Value.Get(5)); IList <Value> l2 = new List <Value>(); l2.Add(Value.Get(1)); l2.Add(Value.Get(2)); l2.Add(Value.Get(3)); IList <Value> l3 = new List <Value>(); l3.Add(Value.Get(6)); l3.Add(Value.Get(5)); l3.Add(Value.Get(4)); l3.Add(Value.Get(1)); List <Value> inputList = new List <Value>(); inputList.Add(Value.Get(l1)); inputList.Add(Value.Get(l2)); inputList.Add(Value.Get(l3)); // Create list. client.Put(null, key, new Bin(binName, inputList)); // Append value to last list and retrieve all lists. Record record = client.Operate(null, key, ListOperation.Append(binName, Value.Get(11), CTX.ListIndex(-1)), Operation.Get(binName) ); AssertRecordFound(key, record); IList results = record.GetList(binName); int i = 0; long count = (long)results[i++]; Assert.AreEqual(5, count); IList list = (IList)results[i++]; Assert.AreEqual(3, list.Count); // Test last nested list. list = (IList)list[2]; Assert.AreEqual(5, list.Count); Assert.AreEqual(6, (long)(long?)list[0]); Assert.AreEqual(5, (long)(long?)list[1]); Assert.AreEqual(4, (long)(long?)list[2]); Assert.AreEqual(1, (long)(long?)list[3]); Assert.AreEqual(11, (long)(long?)list[4]); }
public BlogRepository(CTX dbContext) : base(dbContext) { }
public UserRepository(CTX db) : base(db) { }
public void OperateNestedListMap() { Key key = new Key(args.ns, args.set, "oplkey19"); client.Delete(null, key); IList <Value> l11 = new List <Value>(); l11.Add(Value.Get(7)); l11.Add(Value.Get(9)); l11.Add(Value.Get(5)); IList <Value> l12 = new List <Value>(); l12.Add(Value.Get(13)); IList <Value> l1 = new List <Value>(); l1.Add(Value.Get(l11)); l1.Add(Value.Get(l12)); IList <Value> l21 = new List <Value>(); l21.Add(Value.Get(9)); IList <Value> l22 = new List <Value>(); l22.Add(Value.Get(2)); l22.Add(Value.Get(4)); IList <Value> l23 = new List <Value>(); l23.Add(Value.Get(6)); l23.Add(Value.Get(1)); l23.Add(Value.Get(9)); IList <Value> l2 = new List <Value>(); l2.Add(Value.Get(l21)); l2.Add(Value.Get(l22)); l2.Add(Value.Get(l23)); Dictionary <Value, Value> inputMap = new Dictionary <Value, Value>(); inputMap[Value.Get("key1")] = Value.Get(l1); inputMap[Value.Get("key2")] = Value.Get(l2); // Create list. client.Put(null, key, new Bin(binName, inputMap)); // Append value to last list and retrieve map. Record record = client.Operate(null, key, ListOperation.Append(binName, Value.Get(11), CTX.MapKey(Value.Get("key2")), CTX.ListRank(0)), Operation.Get(binName) ); AssertRecordFound(key, record); IList results = record.GetList(binName); int i = 0; long count = (long)results[i++]; Assert.AreEqual(3, count); IDictionary map = (IDictionary)results[i++]; Assert.AreEqual(2, map.Count); // Test affected nested list. IList list = (IList)map["key2"]; Assert.AreEqual(3, list.Count); list = (IList)list[1]; Assert.AreEqual(3, list.Count); Assert.AreEqual(2, (long)(long?)list[0]); Assert.AreEqual(4, (long)(long?)list[1]); Assert.AreEqual(11, (long)(long?)list[2]); }