Example #1
0
 public async Task <IActionResult> AddOrEdit(int id, [Bind("Id,Codice,Descrizione,Note")] Componente componente)
 {
     if (ModelState.IsValid)
     {
         if (id == 0)
         {
             _context.Add(componente);
             await _context.SaveChangesAsync();
         }
         else
         {
             try
             {
                 _context.Update(componente);
                 await _context.SaveChangesAsync();
             }
             catch (DbUpdateConcurrencyException)
             {
                 if (!ComponenteExists(componente.Id))
                 {
                     return(NotFound());
                 }
                 else
                 {
                     throw;
                 }
             }
         }
         return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", _context.Componente.ToList()) }));
     }
     return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "AddOrEdit", componente) }));
 }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Codice,AreaId")] Locazione locazione)
        {
            if (id != locazione.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(locazione);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocazioneExists(locazione.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AreaId"] = new SelectList(_context.Aree, "Id", "Codice", locazione.AreaId);
            return(View(locazione));
        }
Example #3
0
        public async Task<IActionResult> Edit(int id, [Bind("Qty,CarelloId,ComponenteId")] ComponenteDelCarello componenteDelCarello)
        {
            if (id != componenteDelCarello.CarelloId)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(componenteDelCarello);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ComponenteDelCarelloExists(componenteDelCarello.CarelloId))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction(nameof(Index));
            }
            ViewData["CarelloId"] = new SelectList(_context.Carelli, "Id", "Matricola", componenteDelCarello.CarelloId);
            ViewData["ComponenteId"] = new SelectList(_context.Componente, "Id", "Codice", componenteDelCarello.ComponenteId);
            return View(componenteDelCarello);
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Codice")] Area area)
        {
            if (id != area.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(area);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AreaExists(area.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(area));
        }
Example #5
0
        public async Task <IActionResult> Edit(int?CarelloId, int?LocazioneId, [Bind("Identificativo,Descrizione,Date,CarelloId,LocazioneId")] Arrivi arrivi)
        {
            if (CarelloId != arrivi.CarelloId || LocazioneId != arrivi.LocazioneId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(arrivi);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ArriviExists(arrivi.CarelloId, arrivi.LocazioneId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarelloId"]   = new SelectList(_context.Carelli, "Id", "Matricola", arrivi.CarelloId);
            ViewData["LocazioneId"] = new SelectList(_context.Locazioni, "Id", "Codice", arrivi.LocazioneId);
            return(View(arrivi));
        }
Example #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Matricola")] Carello carello)
        {
            if (id != carello.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(carello);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarelloExists(carello.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(carello));
        }