Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        /// <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));
        }
Exemplo n.º 6
0
 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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        public void TestLabelRepository()
        {
            var log = new LabelRepository(new StoreContext(ConnectionString));
            var mm  = log.GetLabelsByItemTypeId(9, 225, "product");

            Task.WaitAll(mm);
            var resultLabels = mm.Result;
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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));
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        public async Task DeleteTaskPrintItem([FromBody] TaskPrint input)
        {
            await CheckPermission();

            var sqlR = new LabelRepository();
            await sqlR.DeleteTaskPrintItem(input.Id);

            sqlR.Dispose();
        }
Exemplo n.º 18
0
        public async Task GetAll_ValidParameters_AddsProjectIdUrlSegment()
        {
            const uint expected = 0;
            var        sut      = new LabelRepository(_requestFactory);

            await sut.GetAll(expected);

            _request.Received().AddUrlSegment("projectId", expected);
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
        public async Task UpdateTimePrinted([FromBody] LabelRepository.TaskPrintItemWithTimePrintedDateTime input)
        {
            await CheckPermission();

            var sqlR = new LabelRepository();
            await sqlR.UpdateTimePrinted(input);

            sqlR.Dispose();
        }
Exemplo n.º 23
0
        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);
        }
Exemplo n.º 24
0
        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));
        }
Exemplo n.º 25
0
        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));
        }
Exemplo n.º 26
0
        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));
        }
Exemplo n.º 27
0
        public async Task <JsonResult> GetPrintTaskByIdGetPrintTaskById(int taskPrintId)
        {
            await CheckPermission();

            var sqlR   = new LabelRepository();
            var result = await sqlR.GetPrintTaskById(taskPrintId);

            sqlR.Dispose();
            return(Json(result));
        }
Exemplo n.º 28
0
        public async Task <JsonResult> GetAllTemplateLabels()
        {
            await CheckPermission();

            var sqlR   = new LabelRepository();
            var result = await sqlR.GetAllTemplateLabels();

            sqlR.Dispose();
            return(Json(result));
        }
Exemplo n.º 29
0
        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 }));
        }
Exemplo n.º 30
0
        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 }));
        }