public void AddToSlot(Event eEvent, User user, string note, Slot chosenSlot) { // Create SignUp to be inserted into event. var slotSignUp = new SlotSignUp { Created = DateTimeOffset.Now, Note = note, User = user }; // Updates DB with new SignUp. var spot = eEvent.Roster.IndexOf(chosenSlot); // Test to see if .IndexOf finds the indext of slot. chosenSlot.SignUps.Add(slotSignUp); eEvent.Roster.Insert(spot, chosenSlot); // Test to see if .Insert removes the spot it is inserted to. _db.Update(eEvent); // Notify users involved var list = new List <User> { eEvent.Author, user }; _nService.NotifyUsers(new Notification { Message = _localizer["signUpMessage", user.Name, chosenSlot.Name], Subject = _localizer["signUpSubject", eEvent.Name] }, list); }
public int Update <T>(List <T> Data) { string CollectionName = typeof(T).Name; int _ret = -1; _ret = _repo.Update <T>(Data, CollectionName); return(_ret); }
/// <summary> /// Update a document into collection. Returns false if not found document in collection /// </summary> public bool Update <T>(T entity, string collectionName = null) { using (var db = new LiteRepository(_configService.ConnectionString)) { return(db.Update <T>(entity, collectionName)); } }
/// <summary> /// Stores a Key-Value pair to the /// persistence database. /// </summary> public static void SetConfigData(string key, string data) { if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException("key"); } using (var db = new LiteRepository(AppSettingsDBName)) { if (db.Query <AppSetting>().Where(p => p.Key == key).Exists()) { var existing = db.Query <AppSetting>().Where(p => p.Key == key).First(); existing.Value = data; db.Update <AppSetting>(existing); } else { db.Insert(new AppSetting() { Key = key, Value = data }); } } }
public void Save(Todo item) { using (var repo = new LiteRepository(_connectionString)) { repo.Update(item); } }
/// <summary> /// Update all documents /// </summary> public int Update <T>(IEnumerable <T> entities, string collectionName = null) { using (var db = new LiteRepository(_configService.ConnectionString)) { return(db.Update <T>(entities, collectionName)); } }
public bool Update(TModel model) { using (var db = new LiteRepository(_connectionString)) { return(db.Update(model)); } }
public void Update(UserProfile userProfile) { using (var db = new LiteRepository(_pathToDb)) { db.Update(userProfile, CollectionName); } }
static void Main(string[] args) { // Open database (or create if doesn't exist) using (var db = new LiteRepository(@"../../../Customer.litedb")) { var id = db.Insert(new Customer() { Name = "John Doe", Phones = new string[] { "8000-0000", "9000-0000" }, Age = 39, IsActive = true }); var customer = db.SingleById <Customer>(99); customer.Name = "Very Old"; customer.Age = 500; var zz = db.Update(customer); // query using fluent query var result = db.Query <Customer>() .Where(x => x.Age > 499) // used indexes query .ToList(); } }
public bool Update(T item) { using (var db = new LiteRepository(ConnectionString)) { return(db.Update(item)); } }
public IObservable <OperationResult> StopTimer() { return(Observable.Start(() => { if (!repo.Fetch <TimeEntry>().Exists(x => x.EntryTimeStart.Value.Date == DateTime.Now.Date)) { return OperationResult.NoStartedSession; } else { var entry = repo.Fetch <TimeEntry>().First(x => x.EntryTimeStart.Value.Date == DateTime.Now.Date); entry.EntryTimeEnd = DateTime.Now; currentSession = null; return repo.Update(entry) ? OperationResult.OK : OperationResult.NoStartedSession; } }, Scheduler.ThreadPool)); }
public void Update(Cliente entity) { using (var db = new LiteRepository(_db.Context)) { var dbModel = _mapper.Map <ClienteDbModel>(entity); db.Update(dbModel); } }
public void StartGame(int currentSessionId) { var currentSession = _db.SingleById <GameSession>(currentSessionId); currentSession.StartTime = DateTime.Now; _db.Update(currentSession); LeaderBoards(currentSessionId, _db, Clients, _logger); }
public UserModel Update(UserModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } return(_instance.Update <UserModel>(model) ? model : null); }
public void Update(Aluguel entity) { using (var db = new LiteRepository(_db.Context)) { var dbModel = _mapper.Map <AluguelDbModel>(entity); db.Update(dbModel); } _eventStream.AddToStream(entity); }
public bool AddItemsToOrder(Guid id, List <OrderItem> model) { using (var db = new LiteRepository(connectionString)) { var order = db.SingleOrDefault <Order>(x => x.OrderNumber == id); order.Items.AddRange(model); return(db.Update <Order>(order)); } }
public Result <bool> Update(T entity, string collectionName = null) { var result = new Result <bool>(); try { result.ResultObject = _liteRepository.Update(entity, collectionName); } catch (Exception ex) { result.ResultCode = (int)ResultStatusCode.InternalServerError; result.ResultMessage = "Hata Oluştu => " + ex; result.ResultInnerMessage = "Hata Oluştu => " + ex.InnerException; result.ResultStatus = false; } return(result); }
public bool ChangeStatus(Guid id, string status, string info) { using (var db = new LiteRepository(connectionString)) { var order = db.SingleOrDefault <Order>(x => x.OrderNumber == id); order.Status = status; order.Information += info; return(db.Update <Order>(order)); } }
public void Write(Poster poster) { try { repository.Insert(poster); } catch (LiteException) { repository.Update(poster); } }
public void IncreaseFailedGetTokenAttempts(Security security) { security.FailedGetTokenAttempts++; if (security.FailedGetTokenAttempts >= _webApiSettings.MaxFailedLoginAttempts) { security.ApiAccessDisabled = true; security.FailedGetTokenAttempts = 0; } _repository.Update(security); }
public void Write(Letter letter) { try { repository.Insert(letter); } catch (LiteException) { repository.Update(letter); } }
public ActionResult Edit(Event hggmEvent) { if (ModelState.IsValid) { _db.Update(hggmEvent); return(RedirectToAction(nameof(PublishedIndex))); } return(View(hggmEvent)); }
public void Write(Person person) { try { repository.Insert(person); } catch (LiteException) { repository.Update(person); } }
public bool Remove(int id) { using (var db = new LiteRepository(_connectionString)) { var entity = db.FirstOrDefault <TModel>(x => x.Id == id && !x.Removed); if (entity == null) { return(false); } entity.Removed = true; return(db.Update(entity)); } }
public ServiceModel Update(ServiceModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (_instance.Update <ServiceModel>(model)) { return(model); } return(null); }
public void Read_bson_with_more_fields_then_entity() { using var repo = new LiteRepository(dbFile).WithUtcDate(); repo.Insert(new BigEntity { Field1 = "111", Field2 = "222" }, "col"); var e = repo.Query <SmallEntity>("col").First(); e.Field1.Should().Be("111"); repo.Update(e, "col"); var e2 = repo.Query <BigEntity>("col").First(); e2.Field1.Should().Be("111"); e2.Field2.Should().BeNullOrEmpty(); }
public bool Update(T entity) { try { using (var db = new LiteRepository(conStr)) { // simple access to Insert/Update/Upsert/Delete bool result = db.Update(entity); return(result); } } catch { return(false); } }
private static void EnsurePdfFile(this LiteRepository repo, PdfFile value, bool updateLastSeen = true) { var pdf = repo.GetPdf(value.Md5); if (pdf == null) { value.Id = (Guid)repo.Insert <PdfFile>(value); } else { value.Id = pdf.Id; } if (updateLastSeen) { value.LastSeen = DateTime.Now; } repo.Update(value); }
private static async void NextQuestion(int currentSessionId, LiteRepository db, IHubCallerClients clients, ILogger log) { log.LogWarning("Showing Question"); var currentSession = db.SingleById <GameSession>(currentSessionId); var qi = currentSession.CurrentQuestionIndex; var question = currentSession.Questionnaire.Questions[qi]; var answer = db.Single <Answer>(ans => ans.Question.Id == question.Id); var endTime = DateTime.Now.Add(question.Time).ToUniversalTime(); await Task.WhenAll( clients.Group("Players" + currentSession.JoinCode).SendAsync("CurrentAnswer", answer, endTime), clients.Group("Server" + currentSession.JoinCode).SendAsync("CurrentQuestion", question, endTime), Task.Delay(question.Time)); currentSession.CurrentQuestionIndex++; db.Update(currentSession); LeaderBoards(currentSessionId, db, clients, log); }
public ActionResult Edit(Tag tag) { if (ModelState.IsValid) { var tagOld = db.SingleById <Tag>(tag.Id); var before = JsonConvert.SerializeObject(tagOld, Formatting.Indented); db.Update(tag); _audit.Add(new TagEditAudit() { Tag = tagOld.TagName, TagId = tag.Id.ToString(), Before = before, After = JsonConvert.SerializeObject(tag, Formatting.Indented), Type = "changed", User = _userManager.GetUserName(User), UserId = _userManager.GetUserId(User) }); return(RedirectToAction(nameof(Index))); } return(View(tag)); }