public async Task <ActionResult <Pozoriste> > DeletePozoriste(int id)
        {
            Pozoriste pozoriste = await _context.Pozorista
                                  .Include(x => x.sale)
                                  .FirstOrDefaultAsync(i => i.id == id);

            if (pozoriste == null)
            {
                return(NotFound());
            }
            foreach (var sala in pozoriste.sale)
            {
                sala.zauzeta = false;
                _context.Entry(sala).State = EntityState.Modified;
            }

            var festival = await _context.Festivali.FirstOrDefaultAsync(x => x.pozoriste.id == pozoriste.id);

            if (festival != null)
            {
                return(BadRequest());
            }
            //_context.Entry(festival).State = EntityState.Modified;

            //_context.Entry(pozoriste.orgOdb).State = EntityState.Modified;

            _context.Entry(pozoriste).State = EntityState.Deleted;
            await _context.SaveChangesAsync();

            return(Ok());
        }
コード例 #2
0
        public IHttpActionResult Post(Pozoriste pozoriste)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _repository.Add(pozoriste);

            return(CreatedAtRoute("DefaultApi", new { id = pozoriste.Id }, pozoriste));
        }
コード例 #3
0
 public void Update(Pozoriste pozoriste)
 {
     db.Entry(pozoriste).State = EntityState.Modified;
     try
     {
         db.SaveChanges();
     }
     catch (DbUpdateConcurrencyException)
     {
         throw;
     }
 }
        public async Task <ActionResult <Pozoriste> > GetPozoriste(int id)
        {
            Pozoriste pozoriste = await _context.Pozorista
                                  .Include(x => x.sale)
                                  //.Include(x => x.izabrani)
                                  .FirstOrDefaultAsync(i => i.id == id);

            if (pozoriste == null)
            {
                return(NotFound());
            }

            return(pozoriste);
        }
        public async Task <IActionResult> UpdatePozoriste(Pozoriste pozoriste)
        {
            foreach (var sala in pozoriste.sale)
            {
                _context.Entry(sala).State = EntityState.Unchanged;
            }

            //foreach (var izabran in pozoriste.izabrani)
            //{
            //    _context.Entry(izabran).State = EntityState.Unchanged;
            //}

            var festival = await _context.Festivali.FirstOrDefaultAsync(x => x.pozoriste.id == pozoriste.id);

            _context.Entry(festival).State = EntityState.Unchanged;

            //_context.Entry(pozoriste.orgOdb).State = EntityState.Unchanged;

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

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

            return(Ok());
        }
        public async Task <ActionResult <Pozoriste> > AddPozoriste(Pozoriste pozoriste)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (ValidateModel(pozoriste, true))
            {
                foreach (var sala in pozoriste.sale)
                {
                    _context.Entry(sala).State = EntityState.Unchanged;
                }
                _context.Pozorista.Add(pozoriste);
                await _context.SaveChangesAsync();

                return(CreatedAtAction("GetPozoriste", new { id = pozoriste.id }, pozoriste));
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #7
0
        public IHttpActionResult Put(int id, Pozoriste pozoriste)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            try
            {
                _repository.Update(pozoriste);
            }
            catch
            {
                return(BadRequest());
            }

            return(Ok(pozoriste));
        }
        public async Task <IActionResult> Check(IdChecker idChecker)
        {
            if (idChecker.type == 1)
            {
                ClanOrgOdb model = await _context.ClanOrgOdbora
                                   .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 2)
            {
                Festival model = await _context.Festivali
                                 .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 3)
            {
                Forma model = await _context.Forme
                              .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 4)
            {
                Glumac model = await _context.Glumci
                               .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 5)
            {
                Nagrada model = await _context.Nagrade
                                .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 6)
            {
                OrgOdb model = await _context.OrgOdbori
                               .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 7)
            {
                Pozoriste model = await _context.Pozorista
                                  .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 8)
            {
                Predstava model = await _context.Predstave
                                  .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 9)
            {
                PropDeoFest model = await _context.PropDeoFesta
                                    .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 10)
            {
                Radnik model = await _context.Radnici
                               .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 11)
            {
                Reditelj model = await _context.Reditelji
                                 .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 12)
            {
                Sala model = await _context.Sale
                             .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 13)
            {
                Selektor model = await _context.Selektori
                                 .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            if (idChecker.type == 14)
            {
                Ugovor model = await _context.Ugovori
                               .FirstOrDefaultAsync(i => i.id == idChecker.idChecker);

                if (model == null)
                {
                    return(Ok());
                }
            }

            return(BadRequest());
        }
コード例 #9
0
 public async Task IzmeniPozorista([FromBody] Pozoriste p)
 {
     Context.Update <Pozoriste>(p);
     await Context.SaveChangesAsync();
 }
コード例 #10
0
 public async Task UpisiPozorista([FromBody] Pozoriste p)
 {
     Context.Pozorista.Add(p);
     await Context.SaveChangesAsync();
 }
 private bool ValidateModel(Pozoriste pozoriste, bool isPost)
 {
     return(true);
 }
コード例 #12
0
 public void Delete(Pozoriste pozoriste)
 {
     db.Pozorista.Remove(pozoriste);
     db.SaveChanges();
 }
コード例 #13
0
 public void Add(Pozoriste pozoriste)
 {
     db.Pozorista.Add(pozoriste);
     db.SaveChanges();
 }