public async Task <IActionResult> PutKompaniskaSmetka([FromRoute] int id, [FromBody] KompaniskaSmetka kompaniskaSmetka)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != kompaniskaSmetka.Id)
            {
                return(BadRequest());
            }

            _context.Entry(kompaniskaSmetka).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!KompaniskaSmetkaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutFirmiSopstvenici([FromRoute] int id, [FromBody] FirmiSopstvenici firmiSopstvenici)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != firmiSopstvenici.Id)
            {
                return(BadRequest());
            }

            _context.Entry(firmiSopstvenici).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FirmiSopstveniciExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #3
0
        public async Task <IActionResult> PutEmployeeFirms([FromRoute] int id, [FromBody] EmployeeFirms employeeFirms)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employeeFirms.Id)
            {
                return(BadRequest());
            }

            _context.Entry(employeeFirms).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeFirmsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "ID,ime,prezime,jmbg,adresa,brTelefona,mail,password,racunId")] Korisnik korisnik)
 {
     if (ModelState.IsValid)
     {
         db.Entry(korisnik).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(korisnik));
 }
Exemple #5
0
 public ActionResult Edit([Bind(Include = "ID,ukupnoUzeto,ukupnoZaVratiti,kamata,racunId")] Kredit kredit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kredit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kredit));
 }
Exemple #6
0
 public ActionResult Edit([Bind(Include = "ID,posiljalacId,primalacId,vrijeme,iznos")] Transakcija transakcija)
 {
     if (ModelState.IsValid)
     {
         db.Entry(transakcija).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(transakcija));
 }
 public ActionResult Edit([Bind(Include = "ID,stanje,blokiran")] Racun racun)
 {
     if (ModelState.IsValid)
     {
         db.Entry(racun).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(racun));
 }
Exemple #8
0
        public async Task <IActionResult> PutEmployee([FromRoute] int id, [FromBody] VraboteniSmetkiEdit viewmodel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != viewmodel.Vraboten.Id)
            {
                return(BadRequest());
            }

            _context.Entry(viewmodel.Vraboten).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                IEnumerable <int>          listSmetki  = viewmodel.SelectedKompaniskiSmetki;
                IQueryable <EmployeeFirms> toBeRemoved = _context.EmployeeFirms.Where(e => !listSmetki.Contains(e.kompaniskaSmetkaId) &&
                                                                                      e.employeeId == id);
                _context.EmployeeFirms.RemoveRange(toBeRemoved);

                IEnumerable <int> existSmetki = _context.EmployeeFirms.Where(e => listSmetki.Contains(e.kompaniskaSmetkaId) &&
                                                                             e.employeeId == id).Select(e => e.kompaniskaSmetkaId);
                IEnumerable <int> newSmetki = listSmetki.Where(s => !existSmetki.Contains(s));

                foreach (int smetkaId in newSmetki)
                {
                    _context.EmployeeFirms.Add(new EmployeeFirms
                    {
                        employeeId         = id,
                        kompaniskaSmetkaId = smetkaId
                    });
                }

                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #9
0
        public async Task <IActionResult> PutKorisnik([FromRoute] int id, [FromBody] KorisniciFirmiEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != model.Sopstvenik.Id)
            {
                return(BadRequest());
            }

            _context.Entry(model.Sopstvenik).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                IEnumerable <int>             listFirmi   = model.SelectedFirmi;
                IQueryable <FirmiSopstvenici> toBeRemoved = _context.FirmiSopstvenici.Where(s => !listFirmi.Contains(s.firmaId) &&
                                                                                            s.sopstvenikId == id);
                _context.FirmiSopstvenici.RemoveRange(toBeRemoved);

                IEnumerable <int> existFirmi = _context.FirmiSopstvenici.Where(s => listFirmi.Contains(s.firmaId) &&
                                                                               s.sopstvenikId == id).Select(s => s.firmaId);

                IEnumerable <int> newFirmi = listFirmi.Where(e => !existFirmi.Contains(e));

                foreach (int firmId in newFirmi)
                {
                    _context.FirmiSopstvenici.Add(new FirmiSopstvenici {
                        firmaId = firmId, sopstvenikId = id
                    });
                }
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!KorisnikExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }