Beispiel #1
0
        public async Task <IActionResult> Put(ProductRepairDto productRepair)
        {
            var _productRepair = await _productRepairRepository.GetById(productRepair.Id);

            if (_productRepair != null)
            {
                await _productRepairRepository.Update(productRepair);

                return(Ok(productRepair));
            }
            else
            {
                return(Ok("El Producto para Reparación no existe"));
            }
        }
Beispiel #2
0
        public async Task Create(ProductRepairDto dto)
        {
            var _brand = await _brandRepository.GetById(dto.BrandId);

            if (_brand == null)
            {
                throw new Exception("Por favor cargue alguna Marca antes de cargar un producto");
            }

            var _category = await _categoryRepository.GetById(dto.CategoryId);

            if (_category == null)
            {
                throw new Exception("Por favor cargue alguna Rubro antes de cargar un producto");
            }

            var newProductRepair = new ProductRepair()
            {
                Description = dto.Description,
                BrandId     = _brand.Id,
                CategoryId  = _category.Id,
                Code        = dto.Code,
                CostPrice   = dto.CostPrice.HasValue?dto.CostPrice.Value:default,
Beispiel #3
0
        public async Task <IActionResult> Create(ProductRepairDto productRepair)
        {
            if (productRepair == null)
            {
                return(BadRequest());
            }

            var _productRepair = _productRepairRepository.GetAll().Result.
                                 FirstOrDefault(x => x.Code == productRepair.Code &&
                                                x.Description == productRepair.Description &&
                                                x.BrandId == productRepair.BrandId &&
                                                x.CategoryId == productRepair.CategoryId);

            if (_productRepair != null)
            {
                ModelState.AddModelError("description", "La Producto Reparado ya existe");
                return(BadRequest(ModelState));
            }

            await _productRepairRepository.Create(productRepair);

            return(Ok(productRepair));
        }