コード例 #1
0
        // GET: BackOffice/Processes/Create
        public ActionResult Create()
        {
            var model = new ProcessTranslation
            {
                LanguageCode = LanguageDefinitions.DefaultLanguage
            };

            return View(model);
        }
コード例 #2
0
        public async Task<ActionResult> Create(ProcessTranslation pt)
        {
            if (DoesProcessExist(pt))
            {
                ModelState.AddModelError("Value", ProcessStrings.Validation_AlreadyExists);
            }

            if (ModelState.IsValid)
            {
                var process = new Process();
                process.Translations.Add(pt);

                db.Add(process);

                await db.SaveChangesAsync();

                return RedirectToAction("Index");
            }

            return View(pt);
        }
コード例 #3
0
        public async Task<ActionResult> AuxAdd(ProcessTranslation t)
        {
            var cl = db.Entities
                .FirstOrDefault(c => c.Translations.Any(ct =>
                    ct.LanguageCode == t.LanguageCode &&
                    ct.Value == t.Value &&
                    ct.ProcessId != t.ProcessId)
                );

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

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

            return Json((await db.Entities
                .OrderBy(ct => ct.Id)
                .ToListAsync())
                .Select(ct => new TranslatedViewModel<Process, ProcessTranslation>(ct))
                .Select(ct => new
                {
                    value = ct.Entity.Id.ToString(),
                    text = ct.Translation.Value,
                    selected = ct.Entity.Id == cl.Id
                })
                .ToList());
        }
コード例 #4
0
        public ActionResult AuxAdd()
        {
            var model = new ProcessTranslation { LanguageCode = LanguageDefinitions.DefaultLanguage };

            return PartialView("_ProcessFields", model);
        }
コード例 #5
0
 private bool DoesProcessExist(ProcessTranslation p)
 {
     return db.Set<ProcessTranslation>()
         .Any(t =>
             t.LanguageCode == p.LanguageCode &&
             t.Value == p.Value &&
             t.ProcessId != p.ProcessId);
 }
コード例 #6
0
        public async Task<ActionResult> AddTranslation(ProcessTranslation translation)
        {
            if (DoesProcessExist(translation))
            {
                ModelState.AddModelError("Value", ProcessStrings.Validation_AlreadyExists);
            }

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

                return RedirectToAction("Index");
            }
            return View(translation);
        }
コード例 #7
0
        public async Task<ActionResult> AddTranslation(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            var k = await db.GetByIdAsync(id);

            if (k == null)
            {
                return HttpNotFound();
            }

            ViewBag.Languages =
                LanguageDefinitions.GenerateAvailableLanguageDDL(k.Translations.Select(t => t.LanguageCode));

            var model = new ProcessTranslation
            {
                ProcessId = k.Id
            };

            return View(model);
        }