public async Task<ActionResult> Create(ClassificationTranslation classification)
        {
            if (DoesClassificationExist(classification))
            {
                ModelState.AddModelError("Value", ClassificationStrings.ValError_AlreadyExists);
            }


            if (ModelState.IsValid)
            {
                var c = new Classification();

                c.Translations.Add(classification);

                db.Add(c);
                await db.SaveChangesAsync();

                return RedirectToAction("Index");
            }

            return View(classification);
        }
        // GET: BackOffice/Classifications/Create
        public ActionResult Create()
        {
            var model = new ClassificationTranslation { LanguageCode = LanguageDefinitions.DefaultLanguage };

            return View(model);
        }
        public async Task<ActionResult> AuxAdd(ClassificationTranslation t)
        {
            var cl = db.Entities
                .FirstOrDefault(c => c.Translations.Any(ct =>
                    ct.LanguageCode == t.LanguageCode &&
                    ct.Value == t.Value &&
                    ct.ClassificationId != t.ClassificationId)
                );

            if (cl == null)
            {
                cl = new Classification();
                cl.Translations.Add(t);

                db.Add(cl);
                await db.SaveChangesAsync();
            }

            return Json((await db.Entities
                .OrderBy(ct => ct.Id)
                .ToListAsync())
                .Select(ct => new TranslatedViewModel<Classification, ClassificationTranslation>(ct))
                .Select(ct => new
                {
                    value = ct.Entity.Id.ToString(),
                    text = ct.Translation.Value,
                    selected = ct.Entity.Id == cl.Id
                })
                .ToList());
        }
        public ActionResult AuxAdd()
        {
            var model = new ClassificationTranslation { LanguageCode = LanguageDefinitions.DefaultLanguage };

            return PartialView("_ClassificationFields", model);
        }
 private bool DoesClassificationExist(ClassificationTranslation p)
 {
     return db.Set<ClassificationTranslation>()
         .Any(t =>
             t.LanguageCode == p.LanguageCode &&
             t.Value == p.Value &&
             t.ClassificationId != p.ClassificationId);
 }
        public async Task<ActionResult> AddTranslation(ClassificationTranslation translation)
        {
            if (DoesClassificationExist(translation))
            {
                ModelState.AddModelError("Value", ClassificationStrings.ValError_AlreadyExists);
            }

            if (ModelState.IsValid)
            {
                db.AddTranslation(translation);
                await db.SaveChangesAsync();

                return RedirectToAction("Index");
            }

            var c = await db.GetByIdAsync(translation.ClassificationId);

            if (c != null)
            {
                ViewBag.Languages = LanguageDefinitions
                    .GenerateAvailableLanguageDDL(c.Translations.Select(t => t.LanguageCode).ToList());
            }

            return View(translation);
        }