Esempio n. 1
0
        public ActionResult Create(ProductVM productVM, IFormFile FilePicture)
        {
            try
            {
                PictureVM imageEntity = GeneratePicture.CreatePicture(FilePicture, $"{productVM.Name} - {productVM.Description}");
                productVM.Picture = imageEntity;

                if (string.IsNullOrEmpty(productVM.DT_RowId))
                {
                    _productAppService.Add(productVM);
                }
                else
                {
                    _productAppService.Update(productVM);
                }

                if (_notificationContext.HasNotifications)
                {
                    ViewData["Notifications"] = _notificationContext.Notifications.ToList();
                    return(View());
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public ActionResult Post([FromBody] ProductDTO productDTO)
        {
            try
            {
                if (productDTO == null)
                {
                    return(NotFound());
                }

                _applicationService.Add(productDTO);

                return(Ok("Produto Cadastrado com sucesso!"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 3
0
        public IActionResult Post(ProductVM productVM)
        {
            //if (ModelState.IsValid)
            if (true)
            {
                try
                {
                    var prod = _productApplicationService.Add(productVM);

                    if (string.IsNullOrEmpty(prod.DT_RowId))
                    {
                        return(Ok(prod));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.Message));
                }
            }
        }