public JsonResult Create(GrupeViewModel viewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." }));
                }

                using (var context = new LMContext())
                {
                    Grupe model = new Grupe
                    {
                        Naziv = viewModel.Naziv,
                    };
                    context.Grupes.Add(model);
                    context.SaveChanges();

                    return(Json(new { Result = "OK", Record = model }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
        public JsonResult Delete(int GrupaID)
        {
            try
            {
                using (var context = new LMContext())
                {
                    Grupe model = context.Grupes.Find(GrupaID);
                    context.Grupes.Remove(model);
                    context.SaveChanges();
                }

                return(Json(new { Result = "OK" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
        public JsonResult Update(GrupeViewModel viewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." }));
                }
                using (var context = new LMContext())
                {
                    Grupe model = context.Grupes.Find(viewModel.GrupaID);
                    model.Naziv = viewModel.Naziv;
                    context.SaveChanges();
                }

                return(Json(new { Result = "OK" }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }