public IActionResult CreateCategory(CategoryContract category) { var client = GetCodeListClient(); var result = client.CreateCategory(category); return(Json(result)); }
public void Releases_ShouldBeEmpty_WhenCategories_AreEmpty() { var categories = new CategoryContract[0]; var releases = new Update.Releases.Releases(categories, new Version(), ""); releases.Should().HaveCount(0); }
public IEnumerable <PostContract> GetCategoryPosts(string Id) { if (Int32.TryParse(Id, out int categoryId)) { } else { categoryId = 1; } var posts = _postRepository.Get(p => p.CategoryId == categoryId); var dto = new List <PostContract>(); foreach (var post in posts) { var category = _repository.GetSingle(post.CategoryId); var categoryContract = new CategoryContract { Id = category.Id, Name = category.Name, Description = category.Description }; var p = new PostContract { Id = post.Id, SentBy = post.SentBy, SentAt = post.SentAt, Subject = post.Subject, Category = categoryContract, Body = post.Body }; dto.Add(p); } return(dto); }
public IActionResult RenameCategory(int categoryId, CategoryContract category) { var client = GetCodeListClient(); var result = client.UpdateCategory(categoryId, category); return(Json(result)); }
public void Releases_ShouldImplement_IEnumerable() { var categories = new CategoryContract[0]; var releases = new Update.Releases.Releases(categories, new Version(), ""); releases.Should().BeAssignableTo <IEnumerable <Release> >(); }
protected BooksAndCategoriesContract GetBooksAndCategories(bool fetchBooks = false) { var categoryClient = GetCodeListClient(); var categories = categoryClient.GetCategoryList(); // Modify data for DropDownSelect usage const int rootCategoryId = 0; var rootBookTypeCategory = new CategoryContract { Id = rootCategoryId, Description = BookTypeHelper.GetCategoryName(AreaBookType), ParentCategoryId = null, }; foreach (var category in categories) { if (category.ParentCategoryId == null) { category.ParentCategoryId = rootCategoryId; } } categories.Add(rootBookTypeCategory); var booksResult = new List <BookWithCategoryIdsContract>(); if (fetchBooks) { var bookClient = GetBookClient(); var books = bookClient.GetBooksByType(AreaBookType, 0, FetchBookCount); foreach (var book in books) { var categoryIds = book.CategoryIds; if (categoryIds.Count == 0) { categoryIds.Add(rootCategoryId); } booksResult.Add(new BookWithCategoryIdsContract { Id = book.Id, Title = book.Title, SubTitle = book.SubTitle, Guid = null, CategoryIds = categoryIds }); } } var result = new BooksAndCategoriesContract { BookType = AreaBookType, Categories = categories, Books = booksResult, }; return(result); }
public IEnumerable <PostContract> GetAll() { var categories = _repository.GetAll(); var dto = new List <PostContract>(); foreach (var post in categories) { var category = _categoryRepository.GetSingle(post.CategoryId); var categoryContract = new CategoryContract { Id = category.Id, Name = category.Name, Description = category.Description }; var p = new PostContract { Id = post.Id, SentBy = post.SentBy, SentAt = post.SentAt, Subject = post.Subject, Category = categoryContract, Body = post.Body, Comments = new Collection <CommentContract>() }; dto.Add(p); } return(dto); }
public UpdateSubForumWork(ForumRepository forumRepository, CategoryRepository categoryRepository, CategoryContract updatedCategory, CategoryContract oldCategory) : base(forumRepository) { m_forumRepository = forumRepository; m_categoryRepository = categoryRepository; m_updatedCategory = updatedCategory; m_oldCategory = oldCategory; }
/// <summary> /// Converts the given category contract to the category data model. /// </summary> /// <param name="categoryContract">The category data contract.</param> /// <returns>The category data model.</returns> public static Category ToDataModel(this CategoryContract categoryContract) { return(new Category { Id = categoryContract.Id, Name = categoryContract.Name }); }
public CreateSubForumWork(ForumRepository forumRepository, CategoryRepository categoryRepository, ForumAccessSubwork forumAccessSubwork, CategoryContract category) : base(forumRepository) { m_forumRepository = forumRepository; m_categoryRepository = categoryRepository; m_forumAccessSubwork = forumAccessSubwork; m_category = category; }
public IActionResult CreateCategory([FromBody] CategoryContract request) { using (var client = GetRestClient()) { var newId = client.CreateCategory(request); return(Json(newId)); } }
public CategoryContract GetDetailCategory(int idCategory) { var newCategory = new CategoryContract(); var result = new CategoryDao().GetDetailCategories(idCategory); newCategory.ID = result.idCate; newCategory.Name = result.nameCate; return(newCategory); }
public bool UpdateCate(CategoryContract cate) { Category c = new Category(); c.idCate = cate.idCate; c.nameCate = cate.nameCate; if (Repositories.UpdateCate(c) == true) { return(true); } return(false); }
public CategoryContract Update(CategoryContract category) { var entity = _repository.GetSingle(category.Id); entity.Name = category.Name; entity.Description = category.Description; _repository.Update(entity); _repository.SaveChanges(); return(category); }
public IActionResult UpdateCategory(int categoryId, [FromBody] CategoryContract category) { try { m_categoryManager.UpdateCategory(categoryId, category); return(Ok()); } catch (HttpErrorCodeException exception) { return(StatusCode((int)exception.StatusCode, exception.Message)); } }
public CategoryContract AddCategory(int merchId, CategoryContract categoryContract) { Category category = new Category(); category.Name = categoryContract.Name; category.Description = categoryContract.Description; category.MerchantId = merchId; context.Category.Add(category); context.SaveChanges(); categoryContract.CategoryId = category.CategoryId; categoryContract.MerchantId = merchId; return(categoryContract); }
public bool CreateCategory(CategoryContract newCate) { Category cate = new Category { nameCate = newCate.nameCate }; if (Repositories.CreateCate(cate) == true) { return(true); } return(false); }
public CategoryContract Create(CategoryContract category) { _repository.Insert(new Category { Name = category.Name, Description = category.Description }); _repository.SaveChanges(); var added = _repository.GetFirst(c => c.Name == category.Name); category.Id = added.Id; return(category); }
public bool EditCategory(CategoryContract category) { var data = db.Categories.Find(category.ID); data.nameCate = category.Name; if (db.SaveChanges() > 0) { return(true); } else { return(false); } }
public bool CreateCategory(CategoryContract category) { var data = new Category(); data.nameCate = category.Name; if (db.SaveChanges() > 0) { return(true); } else { return(false); } }
protected PhotoContract CreateTestPhoto(CategoryContract category, UserContract user, string description = "Test photo", int goldCount = 0) { return(new PhotoContract { CategoryId = category.Id, CategoryName = category.Name, User = user, Description = description, OSPlatform = "test", HighResolutionUrl = "http://bing.com", StandardUrl = "http://bing.com", ThumbnailUrl = "http://bing.com", NumberOfGoldVotes = goldCount }); }
public CategoryContract GetCategory(int merchId, int catId) { var cat = context.Category.FirstOrDefault(c => c.MerchantId == merchId && c.CategoryId == catId); if (cat != null) { CategoryContract categoryContract = new CategoryContract(); categoryContract.CategoryId = cat.CategoryId; categoryContract.Name = cat.Name; categoryContract.Description = cat.Description; categoryContract.MerchantId = cat.MerchantId; return(categoryContract); } return(null); }
public IEnumerable <CategoryContract> GetAll() { var categories = _repository.GetAll(); var dto = new List <CategoryContract>(); foreach (var category in categories) { var c = new CategoryContract { Id = category.Id, Name = category.Name, Description = category.Description, Posts = new Collection <PostContract>() }; dto.Add(c); } return(dto); }
public int CreateCategory(CategoryContract category) { try { var resultId = m_client.Post <int>("category", category); return(resultId); } catch (HttpRequestException e) { if (m_logger.IsErrorEnabled()) { m_logger.LogError("{0} failed with {1}", m_client.GetCurrentMethod(), e); } throw; } }
public object UpdateCategory(int categoryId, CategoryContract category) { try { var resultId = m_client.Put <object>($"category/{categoryId}", category); return(resultId); } catch (HttpRequestException e) { if (m_logger.IsErrorEnabled()) { m_logger.LogError("{0} failed with {1}", m_client.GetCurrentMethod(), e); } throw; } }
public PostContract Get(int Id) { var post = _repository.GetSingle(Id); var category = _categoryRepository.GetSingle(post.CategoryId); var categoryContract = new CategoryContract { Id = category.Id, Name = category.Name, Description = category.Description }; var p = new PostContract { Id = post.Id, SentBy = post.SentBy, SentAt = post.SentAt, Subject = post.Subject, Category = categoryContract, Body = post.Body }; return(p); }
public bool CreateNewCategory(CategoryContract category) { var data = new Category(); data.nameCate = category.Name; db.Categories.Add(data); try { if (db.SaveChanges() > 0) { return(true); } else { return(false); } } catch (Exception e) { Console.WriteLine(e); return(false); } }
public void UpdateSubForum(CategoryContract updatedCategory, CategoryContract oldCategory) { new UpdateSubForumWork(m_forumRepository, m_categoryRepository, updatedCategory, oldCategory).Execute(); }
public void CreateNewSubForum(CategoryContract category) { new CreateSubForumWork(m_forumRepository, m_categoryRepository, m_forumAccessSubwork, category).Execute(); }
public CreateCategoryWork(CategoryRepository categoryRepository, CategoryContract data) : base(categoryRepository.UnitOfWork) { m_categoryRepository = categoryRepository; m_data = data; }