public async Task <ActionResult <float> > AddOcena(string naziv, short val) { OcenaRente ocena = new OcenaRente(); ocena.kompanija = naziv; ocena.Value = val; _context.OceneRente.Add(ocena); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (GetOcenaKola(naziv) == null) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <bool> > OceniRentu() { var request = HttpContext.Request.Form.Keys.ToList <string>(); string naziv = request[0]; int ocena = int.Parse(request[1]); string user = request[2]; List <OcenaRente> ocene = await _context.OceneRente.ToListAsync(); foreach (OcenaRente oc in ocene) { // renta vec ocenjena if (oc.Username == user && oc.kompanija == naziv) { return(false); } } OcenaRente o = new OcenaRente(); o.kompanija = naziv; o.Username = user; o.Value = ocena; _context.OceneRente.Add(o); await _context.SaveChangesAsync(); return(true); }