Example #1
0
        public async Task GetReturnsCategoryWithCorrectLinkCountWhenProfileIsHiddenAndThenRestoredTest(
            ProfileStatus status)
        {
            var account = Model.Create <Account>();
            var profile = await Model.UsingBuildStrategy <ProfileBuildStrategy>().Create <Profile>().Set(x => x.Status = status)
                          .Save(_logger, account).ConfigureAwait(false);

            var newCategory      = profile.Skills.First();
            var address          = ApiLocation.Category(newCategory);
            var categoryApproval = new NewCategory
            {
                Group = CategoryGroup.Skill,
                Name  = newCategory.Name
            };

            await categoryApproval.Save(_logger).ConfigureAwait(false);

            var firstActual = await Client.Get <PublicCategory>(address, _logger).ConfigureAwait(false);

            firstActual.LinkCount.Should().Be(1);

            await profile.Set(x => x.Status = ProfileStatus.Hidden).Save(_logger, account).ConfigureAwait(false);

            var secondActual = await Client.Get <PublicCategory>(address, _logger).ConfigureAwait(false);

            secondActual.LinkCount.Should().Be(0);

            await profile.Set(x => x.Status = status).Save(_logger, account).ConfigureAwait(false);

            var thirdActual = await Client.Get <PublicCategory>(address, _logger).ConfigureAwait(false);

            thirdActual.LinkCount.Should().Be(1);
        }
Example #2
0
        public async Task GetOnlyIncludesApprovedSkillTest(bool approved)
        {
            var categoryName = Guid.NewGuid().ToString();

            if (approved)
            {
                // Store the category as an administrator which will also make it approved by default
                var category = new NewCategory
                {
                    Group = CategoryGroup.Skill,
                    Name  = categoryName
                };

                await category.Save(_logger).ConfigureAwait(false);
            }

            var profile = await Model.UsingBuildStrategy <ProfileBuildStrategy>().Create <Profile>()
                          .Set(x => x.Skills.First().Name = categoryName)
                          .Save(_logger).ConfigureAwait(false);

            var address = ApiLocation.ProfileFor(profile.Id);

            var actual = await Client.Get <PublicProfile>(address, _logger).ConfigureAwait(false);

            if (approved)
            {
                actual.Skills.Should().Contain(x => x.Name == categoryName);
            }
            else
            {
                actual.Skills.Should().NotContain(x => x.Name == categoryName);
            }
        }
Example #3
0
 public override void Execute()
 {
     OldCategory.Remove(ProgramItem);
     ProgramItem.Category = NewCategory;
     NewCategory.Add(ProgramItem);
     newPaths = new List <string>(ProgramItem.Locations);
 }
Example #4
0
        public async Task GetReturnsProfileWithCaseInsensitiveFilterMatchTest(string filterName)
        {
            var category = new NewCategory
            {
                Group = CategoryGroup.Gender,
                Name  = "Female"
            };

            await category.Save(_logger).ConfigureAwait(false);

            var profile = await Model.UsingBuildStrategy <ProfileBuildStrategy>().Create <Profile>().Set(x => x.Gender = "Female")
                          .Save(_logger).ConfigureAwait(false);

            var filters = new List <ProfileFilter>
            {
                new ProfileFilter
                {
                    CategoryGroup = CategoryGroup.Gender,
                    CategoryName  = filterName
                }
            };
            var address = ApiLocation.ProfilesMatching(filters);

            var actual = await Client.Get <List <ProfileResult> >(address, _logger).ConfigureAwait(false);

            actual.Single(x => x.Id == profile.Id).Should().BeEquivalentTo(profile, opt => opt.ExcludingMissingMembers());
        }
Example #5
0
        public async Task GetReturnsCategoryWithCorrectLinkCountWhenProfileBannedTest()
        {
            var account = Model.Create <Account>();
            var profile = await Model.UsingBuildStrategy <ProfileBuildStrategy>().Create <Profile>().Save(_logger, account)
                          .ConfigureAwait(false);

            var newCategory      = profile.Skills.First();
            var address          = ApiLocation.Category(newCategory);
            var categoryApproval = new NewCategory
            {
                Group = CategoryGroup.Skill,
                Name  = newCategory.Name
            };

            await categoryApproval.Save(_logger).ConfigureAwait(false);

            var firstActual = await Client.Get <PublicCategory>(address, _logger).ConfigureAwait(false);

            firstActual.LinkCount.Should().Be(1);

            await profile.Set(x => x.BannedAt = DateTimeOffset.UtcNow).Save(_logger, account).ConfigureAwait(false);

            var secondActual = await Client.Get <PublicCategory>(address, _logger).ConfigureAwait(false);

            secondActual.LinkCount.Should().Be(0);
        }
Example #6
0
        public int AddCategory(string key, string username, string password, NewCategory category)
        {
            EnsureUser(username, password).Wait();

            // We don't store these, just query them from the list of stories so don't do anything
            return(1);
        }
        public ActionResult Create(NewCategory model)
        {
            var resultEntry = new JsonResultEntry()
            {
                Success = false
            };

            if (model != null)
            {
                var createBy = "";
                model.NewCateShortName = model.NewCateName.ToUrlSegment(250).ToLower();
                model.Language         = Culture;
                if (UserState != null && !CUtils.IsNullOrEmpty(UserState.UserName))
                {
                    createBy = CUtils.StrTrim(UserState.UserName);
                }
                model.CreateBy = createBy;
                NewCategoryManager.Add(model);
                resultEntry.Success = true;
                resultEntry.AddMessage("Tạo mới danh mục tin tức thành công!");
                resultEntry.RedirectUrl = Url.Action("Create", "NewsCategory", new { area = "Auth" });
            }
            else
            {
                resultEntry.Detail = "dư lieu null";
            }
            return(Json(resultEntry));
        }
Example #8
0
        private void tsiNewCategoria_Click(object sender, EventArgs e)
        {
            NewCategory n = new NewCategory();

            n.ShowDialog();
            c.DashBoardCreation(textBox1);
        }
        public async Task GetReturnsCategoryWithCorrectLinkCountWhenProfileIsRemovedFromExistingCategoryTest()
        {
            var account = Model.Create <Account>();
            var profile = await Model.UsingBuildStrategy <ProfileBuildStrategy>().Create <Profile>().Save(_logger, account)
                          .ConfigureAwait(false);

            var newCategory      = profile.Skills.First();
            var address          = ApiLocation.Categories;
            var categoryApproval = new NewCategory
            {
                Group = CategoryGroup.Skill,
                Name  = newCategory.Name
            };
            var administrator = ClaimsIdentityFactory.Build().AsAdministrator();

            await Client.Post(address, _logger, categoryApproval, administrator).ConfigureAwait(false);

            profile.Skills.Remove(profile.Skills.First());

            await profile.Save(_logger, account).ConfigureAwait(false);

            var actual = await Client.Get <List <PublicCategory> >(address, _logger).ConfigureAwait(false);

            var category = actual.Single(x => x.Group == CategoryGroup.Skill && x.Name == newCategory.Name);

            category.LinkCount.Should().Be(0);
        }
Example #10
0
 public IActionResult CreateCategory(NewCategory NewestCategory)
 {
     System.Console.WriteLine("**********Hitting the CreateCategory Route**********");
     if (_context.categories.Where(checkCategrory => checkCategrory.CategoryName == NewestCategory.CategoryName).FirstOrDefault() != null)
     {
         System.Console.WriteLine("**********CategoryName already exists**********");
         ModelState.AddModelError("CategoryName", "Category already exists");
     }
     System.Console.WriteLine("**********ProductName is Unique**********");
     if (ModelState.IsValid)
     {
         Category newCategory = new Category
         {
             CategoryName = NewestCategory.CategoryName,
             Created_At   = DateTime.Now,
             Updated_At   = DateTime.Now
         };
         _context.Add(newCategory);
         _context.SaveChanges();
         HttpContext.Session.SetInt32("cat_id", newCategory.Id);
         int?cat_id = newCategory.Id;
         System.Console.WriteLine("**********" + cat_id + "**********");
         return(Redirect($"Category/{cat_id}"));
     }
     ;
     System.Console.WriteLine("**********CreateCategory Failed**********");
     return(View("Index"));
 }
        public ActionResult POST(NewCategory category)
        {
            var service = new CategoryService();

            service.AddCategory(category);

            return(NoContent());
        }
Example #12
0
        public IActionResult Categories()
        {
            List <Category> AllCategories = dbContext.Categories.ToList();
            NewCategory     emptyForm     = new NewCategory();

            emptyForm.AllCategories = AllCategories;
            return(View("NewCategory", emptyForm));
        }
Example #13
0
        public async Task <IActionResult> CreateCategoriesAsync(
            [FromBody][Required] NewCategory category,
            CancellationToken cancellationToken = default)
        {
            var result = await categoriesProxyService.CreateCategoryAsync(category.CategoryName, cancellationToken);

            return(Ok(result));
        }
        public ActionResult Create()
        {
            NewCategory data       = new NewCategory();
            var         categories = NewCategoryManager.GetAllActive(Culture);

            ViewBag.Categories = categories;
            return(View("Create", data));
        }
Example #15
0
 public static Category toEntity(this NewCategory newCategory)
 {
     return(new Category()
     {
         Name = newCategory.Name,
         Description = newCategory.Description
     });
 }
        public async Task <ActionResult <Category> > PostAsync(NewCategory newCategory)
        {
            var webApi = webApiFactory.Create(User.FindFirstValue(ProxyClaimTypes.AuthenticationToken));

            // Since the Linnworks Web API doesn't have an endpoint to get a category by its ID,
            // and the create new category endpoint also doesn't return the Location HTTP response header,
            // the URL for this header cannot be created.
            return(StatusCode((int)HttpStatusCode.Created, await webApi.CreateNewCategoryAsync(newCategory.Name)));
        }
Example #17
0
        public static AbstractEntities.NewCategory ToAbstract(this NewCategory web)
        {
            if (web == null)
            {
                return(null);
            }

            return(new AbstractEntities.NewCategory(web.Name));
        }
Example #18
0
 public void AddCategory(NewCategory category)
 {
     DbContext.Categories.Add(new sample.DataAccess.Category
     {
         CategoryName = category.CategoryName,
         Description  = category.Description,
         Picture      = category.Picture
     });
     DbContext.SaveChanges();
 }
Example #19
0
        /// <summary>
        /// Category control
        /// </summary>
        public CategoryControl(ICategoryService category_service)
        {
            InitializeComponent();

            menu_category_control = new MenuCategory(this);
            list_category_control = new ListCategory(this);
            new_category_control  = new NewCategory(this);

            this.category_service = category_service;
        }// End of Constructor function
        public IActionResult NewCategory(NewCategory form)
        {
            Category newCategory = new Category()
            {
                Name = form.Name
            };

            dbContext.Categories.Add(newCategory);
            dbContext.SaveChanges();
            return(RedirectToAction("Categories"));
        }
        public async Task <GeneralCategory> Create(NewCategory newRegistry)
        {
            using (InventoryDB db = new InventoryDB())
            {
                Category newCategory = newRegistry.toEntity();
                db.Categories.Add(newCategory);
                await db.SaveChangesAsync();

                return(newCategory.toDTO());
            }
        }
Example #22
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     this.fs.FStatus       = FormStatusEnum.New;
     this.CurrentImptClass = new NewCategory
     {
         Category = 1
     };
     this.comboBox1.SelectedIndex = 0;
     this.imptClassBindingSource.Clear();
     this.imptClassBindingSource.Add(this.CurrentImptClass);
 }
        public async Task <IActionResult> Post([FromBody] NewCategory model, CancellationToken cancellationToken)
        {
            if (model == null)
            {
                return(new ErrorMessageResult(Resources.Controller_NoBodyDataProvided, HttpStatusCode.BadRequest));
            }

            await _command.CreateCategory(model, cancellationToken).ConfigureAwait(false);

            return(new StatusCodeResult((int)HttpStatusCode.Created));
        }
        public void Remove(NewCategory item)
        {
            var comm = this.GetCommand("sp_NewCategory_Delete");

            if (comm == null)
            {
                return;
            }
            comm.AddParameter <int>(this.Factory, "MewCategoryId", item.NewCategoryId);
            comm.SafeExecuteNonQuery();
            /*throw new NotImplementedException();*/
        }
Example #25
0
        public void CreateNewCategory()
        {
            var category = new NewCategory
            {
                Name      = "API Test " + Guid.NewGuid(),
                Color     = "FFA500",
                TextColor = "FFFFFF",
            };
            var response = _api.CreateCategory(category);

            Assert.IsNotNull(response);
        }
Example #26
0
        private Category CreateCategory(int?parentId, string name = "API Test Category")
        {
            var category = new NewCategory
            {
                Name             = name + Guid.NewGuid().ToString().Substring(0, 25),
                Color            = "FFA500",
                TextColor        = "FFFFFF",
                ParentCategoryID = parentId
            };

            return(_api.CreateCategory(category));
        }
Example #27
0
        private void btnNewCategory_Click(object sender, RoutedEventArgs e)
        {
            CloseableTab tab        = new CloseableTab();
            NewCategory  tabcontent = new NewCategory();

            tab.Header  = string.Format("{0}: New Category", MainTabWindow.Items.Count + 1);
            tab.Content = tabcontent;
            tab.HorizontalContentAlignment = HorizontalAlignment.Left;
            tab.VerticalContentAlignment   = VerticalAlignment.Top;
            tab.IsSelected = true;
            MainTabWindow.Items.Add(tab);
            StockSubMenu.IsOpen = false;
        }
Example #28
0
        public async Task CreateCategory(NewCategory newCategory, CancellationToken cancellationToken)
        {
            Ensure.Any.IsNotNull(newCategory, nameof(newCategory));

            var category = new Category
            {
                Group   = newCategory.Group,
                Name    = newCategory.Name,
                Visible = true
            };

            await StoreCategory(category, false, cancellationToken).ConfigureAwait(false);
        }
        public IActionResult PostCategory([FromBody] NewCategory category)
        {
            try
            {
                _adminRepository.PostCategory(category);
            }
            catch (Exception exception)
            {
                return(BadRequest(exception.Message));
            }

            return(Ok());
        }
Example #30
0
        public static async Task <NewCategory> Save(this NewCategory category, ILogger logger = null,
                                                    ClaimsIdentity administrator = null)
        {
            if (administrator == null)
            {
                administrator = ClaimsIdentityFactory.Build().AsAdministrator();
            }

            var address = ApiLocation.Categories;

            await Client.Post(address, logger, category, administrator).ConfigureAwait(false);

            return(category);
        }