public async Task <IActionResult> PutTepih(int id, Tepih tepih) { if (id != tepih.Id) { return(BadRequest()); } _unitOfWork.Tepisi.Update(tepih); try { await _unitOfWork.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TepihsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void tepihAkcija(Tepih tepih) { var stariRacun = _context.Racuni.Where(x => x.Id == tepih.RacunId).FirstOrDefault(); //you will make this variable below optional double cijena = 1; stariRacun.BrojTepiha = _context.Tepisi.Count(x => x.RacunId == stariRacun.Id); stariRacun.Vrijednost = Math.Round((ukupnaKvadratura(stariRacun.Id) * cijena), 2); _context.Racuni.Update(stariRacun); _context.SaveChanges(); }
public async Task <IActionResult> PostTepih(Tepih tepih) { tepih.Duzina = Math.Round(tepih.Duzina, 2); tepih.Sirina = Math.Round(tepih.Sirina, 2); tepih.Kvadratura = Math.Round((tepih.Duzina * tepih.Sirina), 2); _unitOfWork.Tepisi.Add(tepih); await _unitOfWork.SaveChangesAsync(); _unitOfWork.Racuni.tepihAkcija(tepih); return(Ok(tepih)); }