Пример #1
0
        public async Task <IActionResult> PromjenaNaslova([FromBody] PretragaModel model)
        {
            ApplicationUser user = await _userManager.GetUserAsync(HttpContext.User);

            Guid idRazg;
            var  flag = Guid.TryParse(model.Id, out idRazg);

            if (flag == false)
            {
                return(BadRequest());
            }
            Razgovor r = _ctx.Razgovor.Find(idRazg);

            if (r == null)
            {
                return(NotFound());
            }
            r.Naslov = model.Tekst;
            _ctx.SaveChanges();
            var m = new StringModel {
                Value = "Ok"
            };

            return(Ok(m));
        }
Пример #2
0
        public async Task <IActionResult> PromjenaNazivaZbor([FromBody] PretragaModel model)
        {
            ApplicationUser user = await _userManager.GetUserAsync(HttpContext.User);

            Guid idRep;
            var  flag = Guid.TryParse(model.Id, out idRep);

            if (flag == false)
            {
                return(BadRequest());
            }
            var d = _ctx.RepozitorijZbor.Find(idRep);

            if (d == null)
            {
                return(NotFound());
            }
            if (!IsAdmin(d.IdZbor, user.Id) && d.IdKorisnik != user.Id)
            {
                return(Forbid());
            }
            d.Naziv = model.Tekst.Trim() + "." + d.GetEkstenzija();
            _ctx.SaveChanges();
            var m = new StringModel {
                Value = "Ok"
            };

            return(Ok(m));
        }
Пример #3
0
        public async Task <IActionResult> Uredi([FromBody] PretragaModel model)
        {
            ApplicationUser user = await _userManager.GetUserAsync(HttpContext.User);

            Guid idZapis;
            var  flag = Guid.TryParse(model.Id, out idZapis);

            if (flag == false)
            {
                return(BadRequest());
            }
            var zapis = _ctx.Zapis.Find(idZapis);

            if (zapis == null)
            {
                return(NotFound());
            }
            if (!isMod(user.Id) && zapis.IdKorisnik != user.Id)
            {
                return(Forbid());
            }
            zapis.Tekst = model.Tekst;
            _ctx.SaveChanges();
            return(Ok());
        }
Пример #4
0
        public IActionResult Pretraga([FromBody] PretragaModel model)
        {
            var korisnici = _ctx.Korisnik.Where(k => (k.Ime.Trim().ToLower() + ' ' + k.Prezime.Trim().ToLower()).Contains(model.Tekst))
                            .Select(k => new { Id = k.Id, ImeIPrezime = k.Ime.Trim() + ' ' + k.Prezime.Trim() })
                            .ToList();

            return(Ok(korisnici));
        }
Пример #5
0
        public async Task <IActionResult> Uredi([FromBody] PretragaModel model)
        {
            ApplicationUser user = await _userManager.GetUserAsync(HttpContext.User);

            _ctx.Korisnik.Find(user.Id).Opis = model.Tekst;
            _ctx.SaveChanges();
            return(Ok());
        }