Example #1
0
        public async Task <IActionResult> Edit(int id, AssociationTranslation associationTranslation)
        {
            if (id != associationTranslation.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(associationTranslation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AssociationTranslationExists(associationTranslation.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), "Associations"));
            }
            ViewData["AssociationId"]       = new SelectList(_context.Association, "Id", "Name", associationTranslation.AssociationId);
            ViewData["CultureId"]           = new SelectList(_context.Culture, "Id", "Name", associationTranslation.CultureId);
            ViewData["AssociationIdSingle"] = id;
            return(View(associationTranslation));
        }
Example #2
0
        public async Task <IActionResult> GetAssByIdCulture([FromRoute] int id, [FromRoute] string culture)
        {
            var         cultureId = _context.Culture.Where(x => x.Name == culture).Select(x => x.Id).SingleOrDefault();
            Association res       = await _context.Association.Where(x => x.Id == id).Include(z => z.AssociationTranslation).FirstOrDefaultAsync();

            AssociationTranslation res1 = res.AssociationTranslation.Where(x => x.CultureId == cultureId).FirstOrDefault();

            return(Ok(res1));
        }
Example #3
0
        public async Task <IActionResult> Create(AssociationTranslation associationTranslation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(associationTranslation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), "Associations"));
            }
            ViewData["AssociationId"]       = new SelectList(_context.Association, "Id", "Name", associationTranslation.AssociationId);
            ViewData["CultureId"]           = new SelectList(_context.Culture, "Id", "Name", associationTranslation.CultureId);
            ViewData["AssociationIdSingle"] = associationTranslation.AssociationId;
            return(View(associationTranslation));
        }
Example #4
0
        public IActionResult Index()
        {
            var count = 1;
            List <Association> hcp = _context.Association.ToList();

            foreach (var a in hcp)
            {
                if (count != 0)
                {
                    var translation = new AssociationTranslation();
                    translation.Name          = a.Name;
                    translation.CultureId     = 2;
                    translation.AssociationId = a.Id;
                    _context.AssociationTranslation.Add(translation);
                    _context.SaveChanges();
                }
                count++;
            }

            return(View());
        }