Ejemplo n.º 1
0
        public async Task <IActionResult> AzurirajAuto([FromBody] AutomobilViewModel automobil)
        {
            try
            {
                if (automobil == null)
                {
                    throw new Exception("Greska prilikom azuriranja auta!");
                }

                var auto = automobil.ToModel();

                var updatedAuto = await _autoService.AzurirajAutomobil(auto);

                return(Ok(updatedAuto.ToViewModel()));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> SnimiAutomobil([FromBody] AutomobilViewModel automobil)
        {
            try
            {
                if (automobil == null)
                {
                    throw new Exception("Greska auto ne moze biti null!");
                }

                var auto = automobil.ToModel();

                var createdAuto = await _autoService.SnimiAutomobil(auto);

                return(Ok(createdAuto.ToViewModel()));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }