/// <summary> /// Deletes the specified identifier. /// </summary> /// <typeparam name="TDocument">The type of the document.</typeparam> /// <param name="id">The identifier.</param> public void Delete <TDocument>(string id) where TDocument : IDocument { if (!string.IsNullOrWhiteSpace(id)) { _mongoRepository.Delete <TDocument>(id); } }
protected async void DownConnectBusinessMessage() { var businessLinkQr = (await _resourceRepository.GetAll(a => a.ResourceName == "BusinessLinkQr")).FirstOrDefault(); if (businessLinkQr == null) { return; } await _resourceRepository.Delete(businessLinkQr); var businessLinkEmail = (await _resourceRepository.GetAll(a => a.ResourceName == "BusinessLinkEmail")).FirstOrDefault(); if (businessLinkEmail == null) { return; } await _resourceRepository.Delete(businessLinkEmail); var businessJoinEmail = (await _resourceRepository.GetAll(a => a.ResourceName == "BusinessJoinEmail")).FirstOrDefault(); if (businessJoinEmail == null) { return; } await _resourceRepository.Delete(businessJoinEmail); }
public ActionResult DeleteAlertContacts(JArray selectedRows, FormCollection values) { var ids = selectedRows.Select(x => x.ToString()).ToList(); _alertContacts.Delete(t => ids.Contains(t._id)); RefreshAlertContactsList(values); return(UIHelper.Result()); }
public void BatchTest() { var artistList = new List <Artist>(new Artist[] { new Artist() { FirstName = "Artist1", MiddleName = "group1" }, new Artist() { FirstName = "Artist2", MiddleName = "group2" }, new Artist() { FirstName = "Artist3", MiddleName = "group1" }, new Artist() { FirstName = "Artist4", MiddleName = "group2" }, new Artist() { FirstName = "Artist5", MiddleName = "group1" }, }); //Insert Batch _artistRepo.Add(artistList); var count = _artistRepo.Count(); Assert.AreEqual(count, artistList.Count); foreach (Artist artist in artistList) { Assert.AreNotEqual(new string('0', 24), artist.Id); } //Update Batch foreach (var artist in artistList) { artist.LastName = artist.FirstName; } _artistRepo.Update(artistList); foreach (var artist in artistList) { Assert.AreEqual(artist.FirstName, artist.LastName); } //Delete by criteria _artistRepo.Delete(a => a.MiddleName.StartsWith("group1")); var countAfterDel = _artistRepo.Count(); Assert.AreEqual(countAfterDel, 2); }
public ActionResult Delete(JArray selectedRows, FormCollection values) { var ids = selectedRows.Select(Convert.ToInt32).ToList(); _rep.Delete(t => ids.Contains(t._id)); UpdateGrid(values); return(UIHelper.Result()); }
/// <summary> /// Deletes a setting /// </summary> /// <param name="setting">Setting</param> public virtual void DeleteSetting(Setting setting) { if (setting == null) { throw new ArgumentNullException(nameof(setting)); } _settingRepository.Delete(setting); //cache _cacheManager.RemoveByPrefix(setting.ApplicationName); }
public async Task <IActionResult> Delete(Guid id) { var existingItem = await _itemsRepository.Get(id); if (existingItem == null) { return(NotFound()); } await _itemsRepository.Delete(existingItem.Id); await _publishEndpoint.Publish(new CatalogItemDeleted(existingItem.Id)); return(NoContent()); }
public ActionResult DeleteFile(JArray selectedRows, FormCollection values) { var ids = selectedRows.Select(Convert.ToInt32).ToList(); var files = _file.Find(t => ids.Contains(t.Rid)).ToList(); _file.Delete(t => ids.Contains(t.Rid)); RefreshFileList(values); foreach (var file in files) { if (System.IO.File.Exists(file.Url)) { System.IO.File.Delete(file.Url); } } return(UIHelper.Result()); }
public async Task Delete(int id) { switch (_useDb) { case ConnectDb.MariaDb: await _userRepository.Delete(id); break; case ConnectDb.Mongo: await _mongoUserRepository.Delete(id); break; } if (_redisUserRepository != null) { await _redisUserRepository.Delete(id); } }
public void BatchTest() { var imageList = new List <Image>(new Image[] { new Image() { Name = "Image1", Link = "link1" }, new Image() { Name = "Image2", Link = "link2" }, new Image() { Name = "Image3", Link = "link1" }, new Image() { Name = "Image4", Link = "link2" }, new Image() { Name = "Image5", Link = "link1" }, }); //Insert Batch _imageRepo.Add(imageList); var count = _imageRepo.Count(); Assert.AreEqual(count, imageList.Count); foreach (Image image in imageList) { Assert.AreNotEqual(new string('0', 24), image.Id); } //Update Batch var counter = 1; foreach (var image in imageList) { image.Name = "Image1" + counter; counter++; } _imageRepo.Update(imageList); counter = 1; foreach (var image in imageList) { Assert.AreEqual(image.Name, "Image1" + counter); counter++; } //Delete by criteria _imageRepo.Delete(a => a.Link.StartsWith("link1")); var countAfterDel = _imageRepo.Count(); Assert.AreEqual(countAfterDel, 2); }
public async Task Delete(Collection collection) { await _repository.Delete(collection.ToDocument()); await _dispatcher.Dispatch(collection); }
public void BatchTest() { var socialList = new List <Social>(new Social[] { new Social() { Name = "FullName1", Alt = "text1" }, new Social() { Name = "FullName2", Alt = "text2" }, new Social() { Name = "FullName3", Alt = "text1" }, new Social() { Name = "FullName4", Alt = "text2" }, new Social() { Name = "FullName5", Alt = "text1" }, }); //Insert Batch _socialRepo.Add(socialList); var count = _socialRepo.Count(); Assert.AreEqual(count, socialList.Count); foreach (Social social in socialList) { Assert.AreNotEqual(new string('0', 24), social.Id); } //Update Batch var counter = 1; foreach (var social in socialList) { social.Name = "FullName1" + counter; counter++; } _socialRepo.Update(socialList); counter = 1; foreach (var message in socialList) { Assert.AreEqual(message.Name, "FullName1" + counter); counter++; } //Delete by criteria _socialRepo.Delete(a => a.Alt.StartsWith("text1")); var countAfterDel = _socialRepo.Count(); Assert.AreEqual(countAfterDel, 2); }
public void BatchTest() { var language = new Language() { Abbreviation = "language abbreviation", Name = "language name", EnName = "language en name", FlagImage = "flag image link", Locale = "en" }; _languageRepo.Add(language); var announcementList = new List <Announcement>(new Announcement[] { new Announcement() { Name = "Announcement1", Text = "group1", LanguageId = language.Id }, new Announcement() { Name = "Announcement2", Text = "group2", LanguageId = language.Id }, new Announcement() { Name = "Announcement3", Text = "group1", LanguageId = language.Id }, new Announcement() { Name = "Announcement4", Text = "group2", LanguageId = language.Id }, new Announcement() { Name = "Announcement5", Text = "group1", LanguageId = language.Id }, }); //Insert Batch _announcementRepo.Add(announcementList); var count = _announcementRepo.Count(); Assert.AreEqual(count, announcementList.Count); foreach (Announcement announcement in announcementList) { Assert.AreNotEqual(new string('0', 24), announcement.Id); } //Update Batch foreach (var announcement in announcementList) { announcement.IsActive = false; } _announcementRepo.Update(announcementList); foreach (var announcement in announcementList) { Assert.AreEqual(announcement.IsActive, false); } //Delete by criteria _announcementRepo.Delete(a => a.Text.StartsWith("group1")); var countAfterDel = _announcementRepo.Count(); Assert.AreEqual(countAfterDel, 2); }
public async Task Remove(ResourceLogHistory resourceLogHistory) => await _repository.Delete(resourceLogHistory.ToDocument());
public Task RemoveAllAsync(string subjectId, string clientId) { _dbRepository.Delete<PersistedGrant>(i => i.SubjectId == subjectId && i.ClientId == clientId); return Task.FromResult(0); }
public void Delete(string id) { _repository.Delete(id); //unitOfWork.Save(); }
public void Delete(Guid id) { _prods.Delete(id); }
public async Task Delete(Organization organization) { await _repository.Delete(organization.ToDocument()); await _dispatcher.Dispatch(organization); }
public void DeleteValue(string id) { _repository.Delete(id); }
public void HardDelete(string id) { _userRepository.Delete(id); }
public ActionResult btnSubmit_Click(JArray Grid1_fields, JArray Grid1_modifiedData, int Grid1_pageIndex, int Grid1_pageSize, string id, string isLog) { if (!Grid1_modifiedData.Any()) { ShowNotify("无修改数据!"); return(UIHelper.Result()); } //var detail = _repDetail.Get(t => t._id == int.Parse(id)); //var detailIds = new List<int>(); //if (detail.IsLog) //{ // detailIds.Add(detail._id); //} //else //{ // detailIds.AddRange( // _repDetail.Find(t => t.DeviceNum == detail.DeviceNum && !t.IsLog) // .ToList() // .Select(t => t._id) // .ToList()); //} foreach (var jToken in Grid1_modifiedData) { var modifiedRow = (JObject)jToken; string status = modifiedRow.Value <string>("status"); var rowId = modifiedRow.Value <string>("id"); var rowDic = modifiedRow.Value <JObject>("values").ToObject <Dictionary <string, object> >(); if (status == "newadded") { var model = new Accessory(); foreach (var p in rowDic) { typeof(Accessory).GetProperty(p.Key).SetValue(model, p.Value); } //model.RecDetailIds = detailIds.ToArray(); if (string.IsNullOrEmpty(isLog)) { model.RecId = int.Parse(id); } else { model.RecDetailId = int.Parse(id); } _rep.Add(model); } else if (status == "modified") { foreach (var p in rowDic) { var param = Expression.Parameter(typeof(Accessory), "x"); var body = Expression.Property(param, typeof(Accessory), p.Key); var lambda = Expression.Lambda <Func <Accessory, object> >(Expression.Convert(body, typeof(object)), param); _rep.Update(t => t._id == int.Parse(rowId), Builders <Accessory> .Update.Set(lambda, p.Value)); } } else if (status == "deleted") { _rep.Delete(t => t._id == int.Parse(rowId)); } } int count; var source = _rep.QueryByPage(Grid1_pageIndex, Grid1_pageSize, out count, string.IsNullOrEmpty(isLog) ? Builders <Accessory> .Filter.Eq(t => t.RecId, int.Parse(id)) : Builders <Accessory> .Filter.Eq(t => t.RecDetailId, int.Parse(id))); var grid1 = UIHelper.Grid("Grid1"); grid1.RecordCount(count); grid1.DataSource(source, Grid1_fields); ShowNotify("数据保存成功!"); return(UIHelper.Result()); }
public void BatchTest() { var messageList = new List <Message>(new Message[] { new Message() { FullName = "FullName1", Text = "text1" }, new Message() { FullName = "FullName2", Text = "text2" }, new Message() { FullName = "FullName3", Text = "text1" }, new Message() { FullName = "FullName4", Text = "text2" }, new Message() { FullName = "FullName5", Text = "text1" }, }); //Insert Batch _messageRepo.Add(messageList); var count = _messageRepo.Count(); Assert.AreEqual(count, messageList.Count); foreach (Message message in messageList) { Assert.AreNotEqual(new string('0', 24), message.Id); } //Update Batch var counter = 1; foreach (var message in messageList) { message.FullName = "FullName" + counter; counter++; } _messageRepo.Update(messageList); counter = 1; foreach (var message in messageList) { Assert.AreEqual(message.FullName, "FullName" + counter); counter++; } //Delete by criteria _messageRepo.Delete(a => a.Text.StartsWith("text1")); var countAfterDel = _messageRepo.Count(); Assert.AreEqual(countAfterDel, 2); }
public void BatchTest() { var sliderList = new List <Slider>(new Slider[] { new Slider() { ImageSrc = "ImageSrc1", IsActive = true }, new Slider() { ImageSrc = "ImageSrc2", IsActive = false }, new Slider() { ImageSrc = "ImageSrc3", IsActive = true }, new Slider() { ImageSrc = "ImageSrc4", IsActive = false }, new Slider() { ImageSrc = "ImageSrc5", IsActive = true }, }); //Insert Batch _sliderRepo.Add(sliderList); var count = _sliderRepo.Count(); Assert.AreEqual(count, sliderList.Count); foreach (Slider slider in sliderList) { Assert.AreNotEqual(new string('0', 24), slider.Id); } //Update Batch var counter = 1; foreach (var slider in sliderList) { slider.ImageSrc = "ImageSrc1" + counter; counter++; } _sliderRepo.Update(sliderList); counter = 1; foreach (var slider in sliderList) { Assert.AreEqual(slider.ImageSrc, "ImageSrc1" + counter); counter++; } //Delete by criteria _sliderRepo.Delete(a => a.IsActive.Equals(true)); var countAfterDel = _sliderRepo.Count(); Assert.AreEqual(countAfterDel, 2); }
public void BatchTest() { var settingList = new List <Setting>(new Setting[] { new Setting() { ImageLocation = "ImageLocation1", Type = 1 }, new Setting() { ImageLocation = "ImageLocation2", Type = 2 }, new Setting() { ImageLocation = "ImageLocation3", Type = 1 }, new Setting() { ImageLocation = "ImageLocation4", Type = 2 }, new Setting() { ImageLocation = "ImageLocation5", Type = 1 }, }); //Insert Batch _settingsRepo.Add(settingList); var count = _settingsRepo.Count(); Assert.AreEqual(count, settingList.Count); foreach (Setting setting in settingList) { Assert.AreNotEqual(new string('0', 24), setting.Id); } //Update Batch var counter = 1; foreach (var setting in settingList) { setting.ImageLocation = "ImageLocation1" + counter; counter++; } _settingsRepo.Update(settingList); counter = 1; foreach (var setting in settingList) { Assert.AreEqual(setting.ImageLocation, "ImageLocation1" + counter); counter++; } //Delete by criteria _settingsRepo.Delete(a => a.Type.Equals(1)); var countAfterDel = _settingsRepo.Count(); Assert.AreEqual(countAfterDel, 2); }
public void Delete(Guid id) { _repository.Delete(id); }
public ActionResult DeleteAll(FormCollection values) { _rep.Delete(t => true); UpdateGrid(values); return(UIHelper.Result()); }
public async Task <IActionResult> Delete(string id) { await _repository.Delete <Tip>(id); return(Ok()); }
public bool Delete(TKey key) { return(_repository.Delete(key).DeletedCount > 0); }
public async Task DeteleAuthor(string Id) { await _mongoRepository.Delete(Id); }
public void BatchTest() { var labelList = new List <Label>(new Label[] { new Label() { LabelName = "Label1", Text = "text1" }, new Label() { LabelName = "Label2", Text = "text2" }, new Label() { LabelName = "Label3", Text = "text1" }, new Label() { LabelName = "Label4", Text = "text2" }, new Label() { LabelName = "Label5", Text = "text1" }, }); //Insert Batch _labelRepo.Add(labelList); var count = _labelRepo.Count(); Assert.AreEqual(count, labelList.Count); foreach (Label label in labelList) { Assert.AreNotEqual(new string('0', 24), label.Id); } //Update Batch var counter = 1; foreach (var label in labelList) { label.LabelName = "Label1" + counter; counter++; } _labelRepo.Update(labelList); counter = 1; foreach (var label in labelList) { Assert.AreEqual(label.LabelName, "Label1" + counter); counter++; } //Delete by criteria _labelRepo.Delete(a => a.Text.StartsWith("text1")); var countAfterDel = _labelRepo.Count(); Assert.AreEqual(countAfterDel, 2); }