Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("id,Name,MaxSpeed,SectionCount,DiseslPower,Photo,Imgsrc")] DieselLocomoives dieselLocomoives)
        {
            if (id != dieselLocomoives.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dieselLocomoives);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DieselLocomoivesExists(dieselLocomoives.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dieselLocomoives));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("id,Name,MaxSpeed,SectionCount,DiseslPower,Photo,Imgsrc")] DieselLocomoives dieselLocomoives)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dieselLocomoives);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dieselLocomoives));
        }
Exemplo n.º 3
0
        // GET: DieselLocomotiveInfoes/Details/5
        public async Task <IActionResult> Details(int?idloc)
        {
            if (idloc == null)
            {
                return(NotFound());
            }
            DieselLocomoives dieselLocomoives = await _context.DieselLocomoives.Where(x => x.id == idloc).FirstOrDefaultAsync();

            var diesel_Lockomotive_Info = _context.DieselLocomotiveInfos.Where(m => m.Name == dieselLocomoives.Name).FirstOrDefault();

            if (diesel_Lockomotive_Info == null)
            {
                DieselLocomotiveInfo dieselLocomotiveInfo = new DieselLocomotiveInfo
                {
                    Name        = dieselLocomoives.Name,
                    Power       = dieselLocomoives.DiseslPower,
                    Diesel_Type = "",
                    Baseinfo    = "",
                    AllInfo     = "",
                    Imgsrc      = ""
                };
                _context.Add(dieselLocomotiveInfo);
                await _context.SaveChangesAsync();
            }
            DieselLocomotiveInfo diesel_Lockomotive_Info_result;

            try
            {
                diesel_Lockomotive_Info_result = await _context.DieselLocomotiveInfos
                                                 .FirstOrDefaultAsync(m => m.Name == diesel_Lockomotive_Info.Name);
            }catch (Exception exp)
            {
                return(NotFound());
            }
            return(View(diesel_Lockomotive_Info_result));
        }