private static async void EseguiPartita() { using (DataBase db = new DataBase()) { await db.Database.EnsureCreatedAsync(); Tavolo tavolo = new Tavolo(); Orologio orologio = new Orologio(); tavolo.Orologio = orologio; Mossa mossa1 = new Mossa(); mossa1.Valore = "A2 A3"; mossa1.Tavolo = tavolo; Mossa mossa2 = new Mossa(); mossa2.Valore = "A1 H1"; mossa2.Tavolo = tavolo; db.Add(mossa1); db.Add(mossa2); await db.SaveChangesAsync(); Console.WriteLine("Dati inseriti"); } }
public void SendRegister(Action <DataBase> ac, string acc, string pw) { DataBase db = DataPool.Instance.Pop(CMD.Register); db.Add(acc); db.Add(pw); SendMessage(db, ac); }
public void SendCreateRole(Action <DataBase> ac, string roleName) { DataBase db = DataPool.Instance.Pop(CMD.CreateRole); db.Add(GameManager.Instance.userId); db.Add(roleName); SendMessage(db, ac); }
public void AddPersonOnNextPosition() { IPerson personToAdd = new Person(55, "BashIvan"); testDataBase.Add(personToAdd); IPerson[] result = testDataBase.Fetch(); IPerson lastElementInDb = result[result.Length - 1]; Assert.AreEqual(personToAdd, lastElementInDb); }
public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Genre,Price")] Movie movie) { if (ModelState.IsValid) { _context.Add(movie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public void RemoveElementShoudRemoveItOnlyLastElement() { var currentIndex = database.Index; database.Add(new Person(TestName, TestId)); var nextIndex = database.Index; Assert.AreEqual(currentIndex, nextIndex - 1); }
public bool CreateUser(string username, string rawPassword) { string hashedPassword = PasswordHasher.Hash(rawPassword); using (var db = new DataBase()) { // Check if username already exists on database int AlreadyExists = db.Users .Where(u => u.Username == username) .Count(); if (AlreadyExists > 0) { return(false); } // If above check passes, proceed to create new user db.Add(new UserInfo { Username = username, HashedPassword = hashedPassword }); db.SaveChanges(); return(true); } }
public override Task <SmtpResponse> SaveAsync(ISessionContext context, IMessageTransaction transaction, CancellationToken cancellationToken) { var textMessage = (ITextMessage)transaction.Message; var message = MimeKit.MimeMessage.Load(textMessage.Content); Log.Logs.Instance.Push($"[Mail Server] Mail received. from='{message.From}', to='{message.To}', title='{message.Subject}'"); var mailbox_path = Path.Combine(AppProvider.ApplicationPath, "mailbox"); if (!Directory.Exists(mailbox_path)) { Directory.CreateDirectory(mailbox_path); } var save_path = Path.Combine(mailbox_path, $"{DateTime.Now.Ticks}-{(message.Subject + Crypto.Random.RandomString(15)).GetHashMD5()}.mime"); File.WriteAllText(save_path, message.ToString()); DataBase.Add(new MailColumnModel { Title = message.Subject, DateTime = message.Date.UtcDateTime.Ticks.ToString(), From = message.From.ToString(), To = message.To.ToString(), FileName = save_path, }); return(Task.FromResult(SmtpResponse.Ok)); }
public void SendGetRole(Action <DataBase> ac) { DataBase db = DataPool.Instance.Pop(CMD.GetRole); db.Add(GameManager.Instance.userId); SendMessage(db, ac); }
protected XElement AddTable(string TableName, string TypeName, string CollectionName) { var table = new XElement("{http://schemas.microsoft.com/linqtosql/dbml/2007}Table"); EnsureSb(100); _sb.Append("\tnew Table('"); _sb.Append(TableName); _sb.AppendLine("')"); DataBase.Add(table); ActiveObject = TableName; SetAttributeValue(table, "Name", Scheme + "." + TableName); SetAttributeValue(table, "Member", CollectionName); var tableType = new XElement("{http://schemas.microsoft.com/linqtosql/dbml/2007}Type"); ActiveObject = TableName + ".Type"; table.Add(tableType); SetAttributeValue(tableType, "Name", TypeName); if (_tablesCache != null) { _tablesCache.Add((Scheme + "." + TableName).ToLower(), table); } return(table); }
public async Task <IActionResult> Create([Bind("Id,Codigo,Nome,Cpf,Senha,DataNascimento,PlanoDeSaudeId")] PacienteEntity pacienteEntity) { ViewData["errorMessage"] = ""; if (ModelState.IsValid) { //Validando o cadastro de pessoas maiores de idade. int idade = DateTime.Now.Year - pacienteEntity.DataNascimento.Year; if (idade >= 18) { //Utilizando o método para validar o CPF if (ValidaCPF.IsCpf(pacienteEntity.Cpf)) { _context.Add(pacienteEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } else { ViewData["errorMessage"] = "O CPF está inválido."; } } else { ViewData["errorMessage"] = "Não é permitido cadastrar menor de idade."; } } ViewData["PlanoDeSaudeId"] = new SelectList(_context.PlanoSaudes, "Id", "Nome", pacienteEntity.PlanoDeSaudeId); return(View(pacienteEntity)); }
public async void PrimiIteme(Artikal v) { DataBase koka = new DataBase(); koka.Add(v); koka.SaveChanges(); Console.WriteLine($"Sacuvani Artikal {v}"); }
public void Add_IfCountLessThan16_ShouldAddNumberAsLast() { var expectedNumber = 3; var db = new DataBase(1, 2); db.Add(3); Assert.AreEqual(expectedNumber, db.Fetch()[db.Count - 1]); }
public IActionResult add([FromBody] ClassTest test) { db.Add(new ClassTest() { Name = test.Name, Lastname = test.Lastname }); db.SaveChanges(); return(Ok()); }
public void CheckAddElementAboveCapacityThrowsException() { testDataBase = new DataBase(Enumerable.Range(1, 16).ToArray()); int testElementToAdd = 17; Assert.That(() => testDataBase.Add(testElementToAdd), Throws.InvalidOperationException .With.Message.EqualTo("Database is full!")); }
public ActionResult Index(FormCollection f) { User b = new User(); b.userbianhao = Int32.Parse(f["zhanghao"]); b.password = f["mima"]; dataBase.Add(b); System.Diagnostics.Debug.Write(b.userbianhao + "," + b.password); return(View(b)); }
public void CheckIfIndexChangesProperlyWhenRemoving() { DataBase db = new DataBase(); FieldInfo reflectedIndex = typeof(DataBase) .GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .First(f => f.Name == NameOfIndex); db.Add(1); db.Add(2); db.Add(3); db.Remove(); int actual = (int)(reflectedIndex.GetValue(db)); int expected = 1; Assert.AreEqual(expected, actual); }
public ActionResult InvitationForm(InvitationModel model) { if (ModelState.IsValid) { DataBase.Add(model); return(View("Thanks", model)); } return(View(model)); }
public void DataBaseShouldIncreaseElementsWhenAdd(int count) { //Arrange var db = new DataBase(new int[count]); //Act db.Add(17); //Assert Assert.AreEqual(db.Count, count + 1); }
public static void AddMessage(int forumId, HttpRequest request, string text) { try { DataBase.Add("INSERT INTO messages VALUES (" + forumId + ", " + request.Cookies["user_id"] + ", \'" + DataBase.ReplacingChars(text) + "\');"); } catch { throw new Exception("Invalid data entered!"); } }
public async Task <IActionResult> Create([Bind("Id,name,remark")] SuperStars superStars) { if (ModelState.IsValid) { _context.Add(superStars); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(superStars)); }
public void Remove() { try { DataBase.Add("DELETE FROM " + nameTable + " WHERE " + nameId1 + " = " + id1 + " AND " + nameId2 + " = " + id2 + ";"); } catch { throw new Exception("Invalid data was passed when calling the command!"); } }
public void Add() { try { DataBase.Add("INSERT INTO " + nameTable + " VALUES (" + id1 + ", " + id2 + ");"); } catch { throw new Exception("Invalid data was passed when calling the command!"); } }
private void button1_Click(object sender, EventArgs e) { if (author.Add(new Model.Author(textBox1.Text, textBox2.Text))) { MessageBox.Show(textBox1.Text + " Elave edildi!"); } else { MessageBox.Show("Xeta ad elave edilmedi"); } }
private void OnNewEntryAdded(object o) { if (Date == DateTime.Parse("01.06.1991") && !client.IsConnected) { client.StartConnect(); } else { LocalDataBase.Add(CompileEntry, Sellers, Assortment, EntryToUpdate); ResetEntry(); } }
public bool AddCcy(string newCcy, CurrencyStatics cs) { if (ContainsCcy(newCcy) || ContainsAsset(newCcy)) { return(false); } else { DataBase.Add(cs); return(true); } }
public static void Add(string login, string pas) { try { DataBase.Add("INSERT INTO users (login, salt, password) VALUES" + "(\'" + login + "\', \'" + Encoding.Unicode.GetString(DataBase.RandomSalt()) + "\', \'" + DataBase.GenerateHash(pas, DataBase.salt) + "\');"); } catch { throw new Exception("Invalid data entered!"); } }
public async Task <IActionResult> Create([Bind("Id,Sintomas,DoencasPreExistentes,ParteDoCorpoId")] AnamneseEntity anamneseEntity) { if (ModelState.IsValid) { _context.Add(anamneseEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ParteDoCorpoId"] = new SelectList(_context.Set <ParteDoCorpoEntity>(), "Id", "Nome", anamneseEntity.ParteDoCorpoId); return(View(anamneseEntity)); }
public async Task <IActionResult> Create([Bind("Id,DataConsulta,NomeProcedimeneto,HorarioConsulta,PacienteId,AnamneseId")] ConsultaEntity consultaEntity) { if (ModelState.IsValid) { _context.Add(consultaEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AnamneseId"] = new SelectList(_context.Anamneses, "Id", "Sintomas", consultaEntity.AnamneseId); ViewData["PacienteId"] = new SelectList(_context.Pacientes, "Id", "Nome", consultaEntity.PacienteId); return(View(consultaEntity)); }
public ActionResult Index(FormCollection f) { JieShu b = new JieShu(); b.shuhao = Int32.Parse(f["shuhao"]); b.shuming = f["shuming"]; b.jieshurenxuehao = Int32.Parse(f["jieshurenxuehao"]); b.jieshurenname = f["jieshurenxingming"]; b.jieshudate = f["jieshuriqi"]; dataBase.Add(b); System.Diagnostics.Debug.Write(b.shuhao + "," + b.shuming); return(View(b)); }