public async Task <bool> DoSaveProduct(ProductDto productDto, IFormFile file) { var product = _mapper.Map(productDto, new Product()); product.CreatedAt = DateTime.Now; product.Activated = true; product.CategoryProduct = await _categoryProductRepository.GetById(productDto.CategoryProductId); product.Producer = await _producerRepository.GetById(productDto.ProducerId); if (file != null) { var uploadFile = await FileManipulator.Uploadfile(file, Path.Combine(_env.WebRootPath, $"Content/Products"), new List <string> { "JPG", "PNG", "JPEG" }); if (uploadFile.uploaded) { product.Photo = uploadFile.fileName; } } _productRepository.Save(product); return(await _unitOfWork.CommitAsync()); }
public async Task <WasherDTO> ConvertToDTO(Washer model) { var dto = _mapper.Map <Washer, WasherDTO>(model); dto.Producer = _mapper.Map <Producer, ProducerDTO>(await _producerRepository.GetById(model.ProducerId)); dto.Room = _mapper.Map <Room, RoomDTO>(await _roomRepository.GetById(model.RoomId)); return(dto); }
public ActionResult DisplayProducer(int producerId) { var producer = _producerRepository.GetById(producerId); if (producer == null) { return(HttpNotFound()); } var viewModel = new ProducerViewModel() { Bio = producer.Bio, DateOfBirth = producer.DateOfBirth, Name = producer.Name, Sex = producer.Sex, RowId = producer.RowId }; return(View(viewModel)); }
public async Task <ActionResult <Producer> > GetById(long id) { var producer = await _producer.GetById(id); if (producer != null) { return(producer); } return(NotFound()); }
public Producer GetById(int id) { return(producerRepository.GetById(id)); }