public void Test_RelationUpdate_01() { _logger.Trace(">>> Labelモデルの読み込みテストを開始"); using (InitializeFact()) { { var @dbc = (AppDbContext)container.GetInstance <IAppDbContext>(); var repo = new LabelRepository(dbc); var repoc = new ContentRepository(dbc); var entity = repo.Load(2L); var content = repoc.Load(2L); entity.Contents.Add(new Model.Label2Content { Content = (Content)content, Label = entity }); repo.Save(); } { var @dbc = (AppDbContext)container.GetInstance <IAppDbContext>(); var repo = new LabelRepository(dbc); var entity = repo.Load(2L); Assert.Equal(entity.Contents[1].Content.Id, 2L); } } }
public ActionResult DeleteConfirmed(int id) { Label label = LabelRepository.GetSingle(id); try { LabelRepository.Delete(label); LabelRepository.Save(); if (IsSuperAdmin) { return(RedirectToAction("Index", new { storeId = label.StoreId })); } else { return(RedirectToAction("Index")); } } catch (Exception ex) { Logger.Error(ex, "Unable to delete it:" + ex.StackTrace, label); ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(label)); }
public IEnumerable <Label> GetLabels(Topic topic, ImageLabel imageLabel) { #region validation if (topic == null) { throw new ArgumentNullException(nameof(topic)); } if (imageLabel == null) { throw new ArgumentNullException(nameof(imageLabel)); } #endregion IEnumerable <Label> labels = LabelRepository.GetLabels(topic, imageLabel).ToList(); if (labels.Any(o => string.IsNullOrEmpty(o.ObjectClassName))) { // load objectclasses only when labels includes where name of objectclass is not set List <ObjectClass> objectClasses = ObjectClassRepository.GetObjectClasses(topic).ToList(); foreach (Label label in labels) { label.ObjectClassName = objectClasses.GetObjectClass(label.ObjectClassId).Name; } } return(labels); }
public IEnumerable <Label> SaveLabels(Topic topic, ImageLabel image, IEnumerable <Label> labels) { #region validation if (topic == null) { throw new ArgumentNullException(nameof(topic)); } if (image == null) { throw new ArgumentNullException(nameof(image)); } #endregion List <Label> result = new List <Label>(); if (labels != null) { if (labels.Any()) { result = LabelRepository.AddOrUpdateOrDeleteLabels(topic, image, labels).ToList(); } else { LabelRepository.DeleteLabels(topic, image); } } return(result); }
/// <summary> /// obtains a list of tags /// </summary> /// <returns>returns the result to action</returns> public JsonResult GetTags() { LabelRepository objtag = new LabelRepository(SessionCustom); objtag.Entity.LanguageId = CurrentLanguage.LanguageId; return(this.Json(objtag.GetLabels(), JsonRequestBehavior.AllowGet)); }
public UnitOfWork(TodoContext context) { _context = context; TodoItems = new TodoItemRepository(_context); Labels = new LabelRepository(_context); TodoItemLabels = new TodoItemLabelRepository(_context); }
public async Task Unsubscribe_ValidParameters_SetsCorrectResourceAndMethod() { var sut = new LabelRepository(_requestFactory); await sut.Unsubscribe(0, "name"); _requestFactory.Received().Create("projects/{projectId}/labels/{labelId}/subscription", Method.Delete); }
private SVP.CIL.Domain.Label LabelRead(AppDbContext dbc, SVP.CIL.Domain.Label target) { var repo = new LabelRepository(dbc); var label = repo.Load(target.Id); var domainLabel = Mapper.Map <SVP.CIL.Domain.Label>(label); return(domainLabel); }
public async Task GetAll_ValidParameters_SetsCorrectResourceAndMethod() { var sut = new LabelRepository(_requestFactory); await sut.GetAll(0); _requestFactory.Received().Create("projects/{projectId}/labels", Method.Get); }
public void AddedLabel_not_adding_should_not_be_found() { LabelRepository repo = new LabelRepository(); bool found = repo.TryGetValue("Test", out var res); Assert.IsFalse(found); Assert.AreEqual(0, res); }
public void TestLabelRepository() { var log = new LabelRepository(new StoreContext(ConnectionString)); var mm = log.GetLabelsByItemTypeId(9, 225, "product"); Task.WaitAll(mm); var resultLabels = mm.Result; }
public async Task Create_ValidParameters_SetsCorrectResourceAndMethod() { var sut = new LabelRepository(_requestFactory); await sut.Create(0, "name", "color"); _requestFactory.Received().Create("projects/{projectId}/labels", Method.Post); }
public async Task Create_DescriptionIsSet_AddsDescriptionParameter() { const string expected = "description"; var sut = new LabelRepository(_requestFactory); await sut.Create(0, "name", "color", expected); _request.Received().AddParameterIfNotNull("description", expected); }
private bool LabelDelete(AppDbContext dbc, SVP.CIL.Domain.Label target) { var repo = new LabelRepository(dbc); var label = repo.Load(target.Id); repo.Delete(label); dbc.SaveChanges(); return(true); }
public void AddedLabel_not_setting_addr_and_getting_should_throw() { string key = "Test"; ushort addr = 0x9F; LabelRepository repo = new LabelRepository(); repo.CreateLabel(key); Assert.Throws <LabelAddressNotAssignedException>(() => repo.TryGetValue(key, out ushort res)); }
public async Task Create_ValidParameters_AddsNameParameter() { const string expected = "name"; var sut = new LabelRepository(_requestFactory); await sut.Create(0, expected, "color"); _request.Received().AddParameter("name", expected); }
public async Task DeleteTaskPrintItem([FromBody] TaskPrint input) { await CheckPermission(); var sqlR = new LabelRepository(); await sqlR.DeleteTaskPrintItem(input.Id); sqlR.Dispose(); }
public async Task GetAll_ValidParameters_AddsProjectIdUrlSegment() { const uint expected = 0; var sut = new LabelRepository(_requestFactory); await sut.GetAll(expected); _request.Received().AddUrlSegment("projectId", expected); }
public async Task Create_ValidParameters_AddsProjectIdUrlSegment() { const uint expected = 0; var sut = new LabelRepository(_requestFactory); await sut.Create(expected, "name", "color"); _request.Received().AddUrlSegment("projectId", expected); }
public async Task Update_ColorIsSet_AddsColorParameter() { const string expected = "color"; var sut = new LabelRepository(_requestFactory); await sut.Update(0, "name", color : expected); _request.Received().AddParameterIfNotNull("color", expected); }
public async Task Unsubscribe_ValidParameters_AddsLabelIdUrlSegment() { const string expected = "name"; var sut = new LabelRepository(_requestFactory); await sut.Unsubscribe(0, expected); _request.Received().AddUrlSegment("labelId", expected); }
public async Task UpdateTimePrinted([FromBody] LabelRepository.TaskPrintItemWithTimePrintedDateTime input) { await CheckPermission(); var sqlR = new LabelRepository(); await sqlR.UpdateTimePrinted(input); sqlR.Dispose(); }
public async Task Update_NewNameIsSet_AddsNewNameParameter() { const string expected = "newName"; var sut = new LabelRepository(_requestFactory); await sut.Update(0, "name", expected); _request.Received().AddParameterIfNotNull("new_name", expected); }
public async Task <JsonResult> GetSelectedLabelsByTaskPrintId([FromBody] TaskPrintSelectLabels req) { await CheckPermission(); var sqlR = new LabelRepository(); var result = await sqlR.GetTaskSelectedItemsByTaskPrintsIdUi(req.Id, req.IsSelectedAll, req.SelectedRows); sqlR.Dispose(); return(Json(result)); }
public async Task <JsonResult> GetAllLabelsByTaskPrintId(int taskPrintId, int skip, int limit) { await CheckPermission(); var sqlR = new LabelRepository(); var result = await sqlR.GetTaskPrintItemsByTaskPrintsIdUi(taskPrintId, skip, limit); sqlR.Dispose(); return(Json(result)); }
public async Task <JsonResult> GetTaskPrints(int skip, int limit, string filter) { await CheckPermission(); var sqlR = new LabelRepository(); var result = await sqlR.GetTaskPrints(skip, limit, filter); sqlR.Dispose(); return(Json(result)); }
public async Task <JsonResult> GetPrintTaskByIdGetPrintTaskById(int taskPrintId) { await CheckPermission(); var sqlR = new LabelRepository(); var result = await sqlR.GetPrintTaskById(taskPrintId); sqlR.Dispose(); return(Json(result)); }
public async Task <JsonResult> GetAllTemplateLabels() { await CheckPermission(); var sqlR = new LabelRepository(); var result = await sqlR.GetAllTemplateLabels(); sqlR.Dispose(); return(Json(result)); }
public async Task <JsonResult> AddLabelWithTaskPtintsItem([FromBody] LabelRepository.LabelWithTaskPrintId input) { var user = await CheckPermission(); var sqlR = new LabelRepository(); var id = await sqlR.AddLabelWithTaskPtintsItem(input, user); sqlR.Dispose(); return(Json(new { id = id })); }
public async Task <JsonResult> AddOrUpdateTaskPrints([FromBody] TaskPrint input) { var user = await CheckPermission(); input.User = user; var sqlr = new LabelRepository(); var id = await sqlr.AddOrUpdateTaskPrints(input); sqlr.Dispose(); return(Json(new { id = id })); }