public IActionResult Put(int id, [FromBody] CreateCategoryDto category) { category.CategoryId = id; try { _editCategoryCommand.Execute(category); return(NoContent()); } catch (EntityNotFoundException e) { if (e.Message == "Category doesn't exist.") { return(NotFound(e.Message)); } return(UnprocessableEntity(e.Message)); } catch (Exception e) { return(StatusCode(500)); } }
public HttpStatusCode CreateCategory(CreateCategoryDto createCategoryDto) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; if (string.IsNullOrEmpty(userId)) { return(HttpStatusCode.Unauthorized); } var response = _categoryRepository.CreateCategory(createCategoryDto, userId); switch (response) { case HttpStatusCode.OK: return(HttpStatusCode.OK); case HttpStatusCode.InternalServerError: return(HttpStatusCode.InternalServerError); default: return(HttpStatusCode.NotFound); } }
public FindCategoryDto Post([FromBody] CreateCategoryDto cat) { return(categoriesServices.PostCategory(cat)); }
public ActionResult Create([FromRoute] string name, [FromBody] CreateCategoryDto dto) { var id = _categoryService.Create(name, dto); return(Created($"/api/Game/Category/{id}", null)); }
public async Task <IActionResult> AddCategory(CreateCategoryDto categoryDto) { var response = await _categoryService.Add(categoryDto); return(GetInstanceActionResult(response)); }
public async Task <IActionResult> Post([FromBody] CreateCategoryDto dto) { return(Ok(await Mediator.Send(dto))); }
/// <summary> /// Transforme un createdCategorie DTO en model /// </summary> /// <param name="cat">le createCategoryDto</param> /// <returns>Categorie</returns> private Category TransformDtoToModel(CreateCategoryDto cat) { return(new Category(null, cat.NameCategory)); }
public async Task CreateAsync(CreateCategoryDto input) { var category = ObjectMapper.Map <Category>(input); await _categoryManager.CreateAsync(category); }
public static CreateCategoryViewModel GetCreateCategoryViewModel(CreateCategoryDto createCategoryDto) { return(new CreateCategoryViewModel(createCategoryDto.Title)); }
public Task <OperationResult <int> > CreateCategory(CreateCategoryDto createCategoryDto) { return(categoryService.CreateCategory(createCategoryDto.Name)); }
public async Task <IActionResult> Create([FromBody] CreateCategoryDto input) { await _categoryService.CreateCategories(input); return(Ok()); }
public async Task <IActionResult> Create([FromBody] CreateCategoryDto dto) => await GetResponse(async() => new ApiResponseViewModel(true, "Category Created Successfully", await _categoryService.Create(dto, UserId)));
public async Task CreateCategories(CreateCategoryDto input) { //Admin: Yeni Kategori Oluşturma var category = _mapper.Map <Category>(input); await _repository.InsertAsync(category); }
public ActionResult CreateCategory([FromBody] CreateCategoryDto newCategoryDto) { var id = _categoryService.CreateCategory(newCategoryDto); return(Created($"/category/{id}", null)); }
public FindCategoryDto Put(int id, [FromBody] CreateCategoryDto cat) { return(categoriesServices.PutCategory(id, cat)); }
public ActionResult <CategoryDto> CreateCategory(Guid personId, Guid projectId, [FromBody] CreateCategoryDto dto) { try { if (!ModelState.IsValid) { return(BadRequest()); } if (!_db.Person.BelongsToUser(personId, HttpContext)) { return(Forbid()); } if (_db.Participation.GetRole(personId, projectId)?.CalendarWrite != true) { return(Forbid()); } var category = _mapper.Map <Category>(dto); category.ProjectId = projectId; foreach (var eligibility in category.Eligibilities) { var role = _db.Role .FindByCondition(x => x.Id == eligibility.RoleId && x.ProjectId == projectId) .SingleOrDefault(); if (role == null) { return(BadRequest()); } eligibility.ShiftsWrite = eligibility.ShiftsWrite && eligibility.ShiftsRead; eligibility.IsTeamCaptain = eligibility.IsTeamCaptain && eligibility.ShiftsRead; eligibility.IsSubstituteCaptain = eligibility.IsSubstituteCaptain && eligibility.ShiftsRead && !eligibility.IsTeamCaptain; } _db.Category.Create(category); _db.Save(); var createdCategory = _db.Category .FindByCondition(x => x.Id == category.Id && x.ProjectId == projectId) .Include(x => x.Eligibilities).ThenInclude(x => x.Role) .SingleOrDefault(); return(Ok(_mapper.Map <CategoryDto>(createdCategory))); } catch (Exception e) { _logger.LogError($"ERROR in CreateCategory: {e.Message}"); return(StatusCode(500, "Internal server error")); } }
public CreateCategoryCommand(CreateCategoryDto createCategoryDto) { CreateCategoryDto = createCategoryDto; }
public async Task <Response> Add(CreateCategoryDto categoryDto) { var AddCategoryCommand = ObjectMapper.Mapper.Map <DDDNLayer.Application.Commands.AddCategoryCommand>(categoryDto); return(await _mediatorHandler.SendCommand(AddCategoryCommand)); }
public async Task <IActionResult> CreateCategory(CreateCategoryDto createCategoryDto) { var result = await categoryOrchestrator.CreateCategory(createCategoryDto); return(ActionResult(result)); }
public async Task <IActionResult> CreateCategory(CreateCategoryDto createCategoryDTO) { var categoryDto = await categoryService.CreateCategoryAsync(createCategoryDTO); return(CreatedAtAction(nameof(CreateCategory), categoryDto)); }
public void DeleteCategoryTest() { CreateCategoryDto myDeleteExceptionCategory = new CreateCategoryDto(); Task.WaitAll(Assert.ThrowsExceptionAsync <ArgumentOutOfRangeException>(() => _CategoriesService.Delete(-1), "Id cannot be lower than 1.")); }