Beispiel #1
0
        //public IActionResult Put([FromRoute] int id, [FromBody] VrstaVrednostiTree vrstaVrednostiEdit)
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] VrstaVrednosti vrstaVrednostiEdit)
        {
            if (!ModelState.IsValid)
            {
                return(Fail(ModelState));
            }

            var vrstaVrednosti = await _unitOfWork.VrsteVrednosti.Get(id);

            if (vrstaVrednosti == null)
            {
                return(Fail("Not Found"));
            }

            vrstaVrednosti.Naziv = vrstaVrednostiEdit.Naziv;
            vrstaVrednosti.Opis  = vrstaVrednostiEdit.Opis;
            vrstaVrednosti.OrganizacionaCelinaId = vrstaVrednostiEdit.OrganizacionaCelinaId;
            vrstaVrednosti.PoslovnaVrednostId    = vrstaVrednostiEdit.PoslovnaVrednostId;
            vrstaVrednosti.NadredjenaKategorija  = vrstaVrednostiEdit.NadredjenaKategorija;

            await _unitOfWork.Complete();

            //return Success(await _unitOfWork.VrsteVrednosti.Get(id));
            return(Success(await _unitOfWork.VrsteVrednosti.VrstaVrednostiPosleAzuriranja(id)));

            //var vrstaVrednostiTree = _mapper.Map<VrstaVrednostiTree>(_unitOfWork.VrsteVrednosti.Get(id));
            //vrstaVrednostiTree.Nivo = _unitOfWork.VrsteVrednosti.Nivo(vrstaVrednostiTree.Id);
            //vrstaVrednostiTree.Expanded = vrstaVrednostiEdit.Expanded;
            //return Success(vrstaVrednostiTree);
        }
Beispiel #2
0
        public async Task <IActionResult> Post([FromBody] VrstaVrednosti vrstaVrednosti)
        {
            if (!ModelState.IsValid)
            {
                return(Fail(ModelState));
            }

            _unitOfWork.VrsteVrednosti.Add(vrstaVrednosti);
            await _unitOfWork.Complete();

            //return Success(await _unitOfWork.VrsteVrednosti.Get(vrstaVrednosti.Id));
            return(Success(await _unitOfWork.VrsteVrednosti.VrstaVrednostiPosleAzuriranja(vrstaVrednosti.Id)));
        }