Example #1
0
        public async Task AddLabel()
        {
            LabelDto addedLabel = await _labelRepository.Add(new CreateLabelDto { Description = "buy phone", CreatedBy = 1 });

            Assert.IsNotNull(addedLabel);
            Assert.AreEqual("buy phone", addedLabel.Description);
        }
Example #2
0
        public IActionResult Edit(long id, [Bind("Name,Id")] LabelDto label)
        {
            if (id != label.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _appService.Update(label);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LabelExists(label.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(label));
        }
Example #3
0
        public LabelDto AddLabelByPublisherId(int publisherId, LabelDto label)
        {
            var organizationLabel = new organization_labels
            {
                countrycode         = 354,
                organizationid      = publisherId,
                labelname           = label.LabelName,
                dateissued          = DateTime.Now,
                rights_world        = true,
                rights_europe       = true,
                rights_ownterritory = true,
                updatedby           = "User",
                updatedon           = DateTime.Now,
                createdby           = "User",
                createdon           = DateTime.Now
            };

            _organizationLabelRepository.Add(organizationLabel);
            _unitOfWork.Commit();

            return(new LabelDto
            {
                LabelId = organizationLabel.id,
                LabelName = organizationLabel.labelname,
                OrganizationId = organizationLabel.organizationid
            });
        }
        public async Task GetByIdTest()
        {
            LabelDto result = await _labelService.GetById(1, 1);

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.LabelId);
        }
        public IActionResult Create(LabelDto labelDto)
        {
            var label = Mapper.Map <Label>(labelDto);

            _labelRepository.Add(label);

            return(Ok(Mapper.Map <LabelDto>(label)));
        }
Example #6
0
 public IActionResult Create([Bind("Name,Id")] LabelDto label)
 {
     if (ModelState.IsValid)
     {
         _appService.Add(label);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(label));
 }
Example #7
0
        public async Task AddLabelTest()
        {
            LabelDto result = await _labelContract.AddLabel(new CreateLabelDto()
            {
                Description = "test", CreatedBy = 1
            });

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.LabelId);
        }
Example #8
0
        /// <summary>
        /// Adds Label record
        /// </summary>
        /// <param name="createLabelDto"></param>
        /// <returns> added ToDoList record. </returns>
        public async Task <LabelDto> AddLabel(CreateLabelDto createLabelDto)
        {
            if (createLabelDto != null)
            {
                createLabelDto.CreatedBy = _userId;
            }
            LabelDto addedItem = await _labelDbOps.AddLabel(createLabelDto);

            return(addedItem);
        }
Example #9
0
 private void initGridView()
 {
     try
     {
         LabelDto labelDto = eventService.Find(labelId);
         commentsList.DataSource = labelDto.comments;
         commentsList.DataBind();
     }
     catch { }
 }
Example #10
0
        public static LabelCloneModel MapLabelCloneModel(LabelDto dto)
        {
            var model = new LabelCloneModel();

            model.OrganizationUid              = dto.OrganizationUid;
            model.CloningLabelUid              = dto.Uid;
            model.CloningLabelKey              = dto.Key;
            model.CloningLabelDescription      = dto.Description;
            model.CloningLabelTranslationCount = dto.LabelTranslationCount;

            model.SetInputModelValues();
            return(model);
        }
Example #11
0
        public static LabelEditModel MapLabelEditModel(LabelDto dto)
        {
            var model = new LabelEditModel();

            model.OrganizationUid = dto.OrganizationUid;

            model.LabelUid    = dto.Uid;
            model.Key         = dto.Key;
            model.Description = dto.Description;

            model.SetInputModelValues();
            return(model);
        }
        public void CreateLabel_ShouldReturnCreatedLabel()
        {
            // Arrange
            var input = new CreateLabelDto();
            var model = new LabelDto();

            todoItemLogic.Setup(u => u.CreateLabel(1, It.Is <CreateLabelDto>(c => c == input))).Returns(model);

            // Act
            var result = controller.AssignLabel(input);

            // Assert
            Assert.IsType <CreatedAtActionResult>(result);
        }
Example #13
0
        public static LabelTranslationCreateModel MapLabelTranslationCreateModel(LabelDto label)
        {
            var model = new LabelTranslationCreateModel();

            model.OrganizationUid = label.OrganizationUid;

            model.ProjectUid  = label.ProjectUid;
            model.ProjectName = label.ProjectName;

            model.LabelUid = label.Uid;
            model.LabelKey = label.Key;

            model.SetInputModelValues();
            return(model);
        }
        public void UpdateLabel_ShouldReturnUpdatedLabel()
        {
            // Arrange
            var input = new UpdateLabelDto();
            var model = new LabelDto();

            todoItemLogic.Setup(u => u.UpdateLabel(1, It.Is <UpdateLabelDto>(c => c == input))).Returns(model);

            // Act
            var result = controller.UpdateLabel(input);

            // Assert
            Assert.IsType <OkObjectResult>(result);
            var response = (result as OkObjectResult).Value as Response <LabelDto>;

            Assert.Equal(model, response.Model);
        }
        public async Task <IActionResult> CreateLabel(CreateLabelModel createLabelModel, ApiVersion version)
        {
            long userId = long.Parse(HttpContext.Items["UserId"].ToString());

            if (createLabelModel == null || string.IsNullOrWhiteSpace(createLabelModel.Description))
            {
                return(BadRequest(new ApiResponse <string>
                {
                    IsSuccess = false,
                    Result = "Not Updated.",
                    Message = "Please enter correct values. Description should not be empty."
                }));
            }
            createLabelModel.CreatedBy = userId;
            CreateLabelDto createLabelDto = _mapper.Map <CreateLabelDto>(createLabelModel);
            LabelDto       createdLabel   = await _labelContract.AddLabel(createLabelDto);

            return(CreatedAtAction(nameof(GetLabelById), new { createdLabel.LabelId, version = $"{version}" }, createdLabel));
        }
        public async Task <IActionResult> Add(CreateLabelDto labelDto, ApiVersion version)
        {
            int userId = int.Parse(HttpContext.Items["UserId"].ToString());

            if (labelDto == null || string.IsNullOrWhiteSpace(labelDto.Description))
            {
                return(BadRequest(new ResponseModel <string>
                {
                    IsSuccess = false,
                    Result = "Not Updated.",
                    Message = "Invalid request, Mandatory fields not provided in request."
                }));
            }
            labelDto.CreatedBy = userId;
            labelDto.UserId    = userId;
            LabelDto createdLabel = await _labelService.Add(labelDto);

            return(CreatedAtAction(nameof(GetById), new { id = createdLabel.LabelId, version = $"{version}" }, createdLabel));
        }
Example #17
0
        public LabelDto CreateDtoFromEntity(Label entity)
        {
            var dto = new LabelDto();

            dto.Uid                   = entity.Uid;
            dto.CreatedAt             = entity.CreatedAt;
            dto.UpdatedAt             = entity.UpdatedAt;
            dto.Key                   = entity.Key;
            dto.Name                  = entity.Name;
            dto.Description           = entity.Description;
            dto.LabelTranslationCount = entity.LabelTranslationCount;

            dto.OrganizationUid  = entity.OrganizationUid;
            dto.OrganizationName = entity.OrganizationName;
            dto.ProjectUid       = entity.ProjectUid;
            dto.ProjectName      = entity.ProjectName;
            dto.IsActive         = entity.IsActive;

            return(dto);
        }
Example #18
0
        public static LabelDetailModel MapLabelDetailModel(LabelDto dto)
        {
            var model = new LabelDetailModel();

            model.OrganizationUid  = dto.OrganizationUid;
            model.OrganizationName = dto.OrganizationName;

            model.ProjectUid  = dto.ProjectUid;
            model.ProjectName = dto.ProjectName;

            model.LabelUid            = dto.Uid;
            model.Key                 = dto.Key;
            model.Description         = dto.Description;
            model.IsActive            = dto.IsActive;
            model.IsActiveInput.Value = dto.IsActive;

            model.LabelTranslationCount = dto.LabelTranslationCount;

            model.SetInputModelValues();
            return(model);
        }
        public async Task <IActionResult> GetById([Required] int id)
        {
            int      userId     = int.Parse(HttpContext.Items["UserId"].ToString());
            LabelDto labelModel = await _labelService.GetById(id, userId);

            if (labelModel != null)
            {
                return(Ok(
                           new ResponseModel <LabelDto>
                {
                    IsSuccess = true,
                    Result = labelModel,
                    Message = "Data retrieved successfully."
                }));
            }
            return(NotFound(
                       new ResponseModel <string>
            {
                IsSuccess = false,
                Result = "Not found.",
                Message = "No data exist for Id = " + id + "."
            }));
        }
        public async Task <IActionResult> GetLabelById([Required] long labelId)
        {
            long     userId     = long.Parse(HttpContext.Items["UserId"].ToString());
            LabelDto LabelModel = await _labelContract.GetLabelById(labelId, userId);

            if (LabelModel != null)
            {
                return(Ok(
                           new ApiResponse <LabelDto>
                {
                    IsSuccess = true,
                    Result = LabelModel,
                    Message = "Label records retrieved successfully."
                }));
            }
            return(NotFound(
                       new ApiResponse <string>
            {
                IsSuccess = false,
                Result = "Not found.",
                Message = "No data exist for Id = " + labelId + "."
            }));
        }
Example #21
0
        public void Service_FindTest()
        {
            try
            {
                long userId =
                    userService.RegisterUser(userLoginName2, clearPassword,
                                             new UserProfileDetails(firstName, lastName, email, language, country));
                Comment comment = eventService.AddComment(content2, myEvent.eventId, userId);
                ICollection <Comment> labelComments = myEvent.Comments;
                String label1 = "label1";
                Label  label  = new Label();
                label.name = label1;
                eventService.Create(label);
                ICollection <CommentDto> labelCommentsDto = new List <CommentDto>();

                LabelDto labelFound = eventService.Find(label.labelId);

                Assert.AreEqual(label1, labelFound.name, "Label doesn't work properly.");
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
Example #22
0
 public static void SetLabel(this IMemoryCache cache, LabelDto label)
 => cache.Set($"label-{label.Id}", label, TimeSpan.FromSeconds(5));
 public void UpdateLabel(LabelDto dto)
 {
     throw new NotImplementedException();
 }
 public LabelDto AddLabel(LabelDto dto)
 {
     throw new NotImplementedException();
 }
 public IHttpActionResult AddLabelsByPublisherId(int publisherId, [FromBody] LabelDto label)
 {
     return(Ok(_organizationService.AddLabelByPublisherId(publisherId, label)));
 }
Example #26
0
 public Label DtoToModel(LabelDto dto) => Mapper.Map <Label>(dto);
Example #27
0
        public static UploadLabelTranslationFromCSVFileModel MapUploadLabelTranslationFromCSVFileModel(LabelDto label)
        {
            var model = new UploadLabelTranslationFromCSVFileModel();

            model.OrganizationUid = label.OrganizationUid;
            model.LabelUid        = label.Uid;
            model.LabelKey        = label.Key;

            model.SetInputModelValues();
            return(model);
        }