public async Task <IActionResult> Edit(int id, [Bind("fighterId,figtherName,age,mma_record,category,created,modified,worth_salary")] mmaFighter m)
        {
            if (id != m.fighterId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    m.modified = DateTime.Now;
                    _context.mmaFighters.Update(m);
                    await _context.SaveChangesAsync();

                    ViewBag.Message = "Uspješno promijenjeno!";
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!mmaFighterExists(m.fighterId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(View("Index", new mmaFighter[] { m }));
            }
            return(View(m));
        }
        //Search
        public IActionResult Search(string name, mmaFighter mm, string mma_name, bool exist = true)
        {
            //Linq method syntax
            var        rez = _context.mmaFighters.Where(m => m.deleted == null && m.figtherName.StartsWith(name)).ToList();
            mmaFighter mma = _context.mmaFighters.Where(k => k.figtherName == mm.figtherName && k.fighterId == mm.fighterId).FirstOrDefault();

            if (ModelState.IsValid)
            {
                if (mma == null)
                {
                    ViewBag.fighterName = mma_name;
                }
                if (exist)
                {
                    ViewBag.Message = "Traženi borac je pronađen.";
                }
                if (!exist || rez.Count == 0)
                {
                    ViewBag.Message = "<b>Traženog borca nismo pronašli.</b>";
                }

                ViewBag.fighterName = name;
                return(View("Index", rez));
            }
            else
            {
                if (rez.Count == 0)
                {
                    ViewBag.Message = "<b>Traženog borca nismo pronašli.</b>";
                }
            }
            return(View("Index", rez));
        }
        public async Task <IActionResult> Create([Bind("figtherName,age,mma_record,category,created,worth_salary")] mmaFighter m)
        {
            if (ModelState.IsValid)
            {
                m.created = DateTime.Now;
                _context.Add(m);
                await _context.SaveChangesAsync();

                ViewBag.Message = "Borac je kreiran";
                return(View("Index", new mmaFighter[] { m }));
            }
            return(View(m));
        }
        public async Task <IActionResult> DeleteConfirmed(int?Id, mmaFighter mf)
        {
            //using (mmaDbContext d = new mmaDbContext())
            //{

            //}
            //var mma = await _context.mmaFighters.FirstOrDefaultAsync(m => m.fighterId == id);
            //var mma = await _context.mmaFighters.Remove(x => x.fighterId == s.fighterId) mmaFigther s
            //s.deleted = Datetime.Now;

            //briše iz baze
            var mmaf = await _context.mmaFighters.FindAsync(Id);

            mf.deleted = DateTime.Now;
            _context.mmaFighters.Remove(mmaf);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }