public void CanMateAddCategoriesTest() { IMateDAO <Mate> MateDAO = new MateDAO(_connection); Mate testMate = new Mate(); testMate.FirstName = "Jessica"; testMate.LastName = "Coelho"; testMate.UserName = "******"; testMate.Password = "******"; testMate.Email = "*****@*****.**"; testMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testMate.Address = "Ordem"; testMate.Categories = new[] { Categories.FURNITURE_ASSEMBLE, Categories.TRANSPORTATION }; testMate.Rank = Ranks.MATE; testMate.Range = 20; Mate returned = MateDAO.Create(testMate); CategoryModel category = new CategoryModel(); category.categories = Categories.CLEANING; CategoryModel[] categories = { category }; MateDAO.AddCategory(returned.Id, categories); Assert.True(MateDAO.CategoriesList(returned.Id).ToList().Exists(a => a.categories == Categories.CLEANING)); _fixture.Dispose(); }
public ActionResult <Categories> AddCategory(CategoryModel[] category) { int?mateID = ClaimHelper.GetIdFromClaimIdentity((ClaimsIdentity)this.ControllerContext.HttpContext.User.Identity); if (mateID == null) { return(Unauthorized(new ErrorMessageModel("Utilizador não existe!"))); } MateDAO mateDAO = new MateDAO(_connection); mateDAO.AddCategory((int)mateID, category); return(Ok(category)); }