Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("id,Name,Diesel_Type,Power,Baseinfo,AllInfo,Imgsrc")] DieselLocomotiveInfo dieselLocomotiveInfo)
        {
            if (id != dieselLocomotiveInfo.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dieselLocomotiveInfo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DieselLocomotiveInfoExists(dieselLocomotiveInfo.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(View(dieselLocomotiveInfo));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("id,Name,Diesel_Type,Power,Baseinfo,AllInfo,Imgsrc")] DieselLocomotiveInfo dieselLocomotiveInfo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dieselLocomotiveInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dieselLocomotiveInfo));
        }
Beispiel #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));
        }