Esempio n. 1
0
        public async Task <IActionResult> EditLocomotive(int id, [Bind("id,Name,Number,Depot,Country,City,Status,Photo")] ListRollingStone listRollingStone)
        {
            if (id != listRollingStone.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Trace.WriteLine("POST " + this + listRollingStone);
                    Electic_locomotive electic_Locomotive = _context.Electic_Locomotives.Where(x => x.Seria + " - " + x.Number == listRollingStone.Name).FirstOrDefault();
                    _context.Update(listRollingStone);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ListRollingStoneExists(listRollingStone.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            Trace.WriteLine("RESPONSE " + this + listRollingStone);
            return(View("IndexAll", await _context.ListRollingStones.ToListAsync()));
        }
Esempio n. 2
0
        // GET: ListRollingStones/Edit/5
        public async Task <IActionResult> EditLocomotive(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ListRollingStone listRollingStone = await _context.ListRollingStones.FindAsync(id);

            if (listRollingStone == null)
            {
                return(NotFound());
            }

            SelectList depots = new SelectList(_context.Depots.Select(x => x.Name).ToList());

            ViewBag.depots = depots;
            SelectList citys = new SelectList(_context.Cities.Select(x => x.Name).ToList());

            ViewBag.citys = citys;
            SelectList status = new SelectList(_context.Statuses.Select(x => x.Status_namr).ToList());

            ViewBag.status = status;
            return(View(listRollingStone));
        }
Esempio n. 3
0
        // GET: ListRollingStones/Edit/5
        public async Task <IActionResult> Edit(string?idlocname)
        {
            if (idlocname == null)
            {
                return(NotFound());
            }

            ListRollingStone listRollingStone = await _context.ListRollingStones.Where(x => x.Name == idlocname).FirstOrDefaultAsync();

            if (listRollingStone == null)
            {
                var electrick_Lockomotive = await _context.Electrick_Lockomotive_Infos.Where(x => x.Name == idlocname).FirstOrDefaultAsync();

                ListRollingStone listRollingStoneObj = new ListRollingStone
                {
                    Name    = electrick_Lockomotive.Name,
                    City    = "",
                    Country = "",
                    Depot   = ""
                };
                Trace.WriteLine("POST " + this + listRollingStoneObj);
                _context.ListRollingStones.Add(listRollingStoneObj);
                _context.SaveChanges();
                ListRollingStone listRollingStoneNew = await _context.ListRollingStones.Where(x => x.Name == electrick_Lockomotive.Name).FirstOrDefaultAsync();

                Trace.WriteLine("RESPONSE" + this + listRollingStoneNew);
                return(View(listRollingStoneNew));
            }
            Trace.WriteLine("RESPONSE" + this + listRollingStone);
            return(View(listRollingStone));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("id,Name,Number,Depot,Country,City,Status,Photo")] ListRollingStone listRollingStone)
        {
            if (id != listRollingStone.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try {
                    listRollingStone.id = 0;
                    _context.ListRollingStones.Add(listRollingStone);
                    await _context.SaveChangesAsync();

                    List <ListRollingStone> listRollingStoneRequest = await _context.ListRollingStones.Where(x => x.Name == listRollingStone.Name).ToListAsync();

                    return(View("Index", listRollingStoneRequest));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ListRollingStoneExists(listRollingStone.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(View(listRollingStone));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create([Bind("id,Name,Number,Depot,Country,City,Status,Photo")] ListRollingStone listRollingStone)
        {
            listRollingStone.Country = "Украина";
            Electic_locomotive electic_Locomotive = _context.Electic_Locomotives.Where(x => x.Seria + " - " + x.Number == listRollingStone.Name).FirstOrDefault();

            if (listRollingStone.Image == null)
            {
                listRollingStone.Image = electic_Locomotive.Image;
                listRollingStone.ImageMimeTypeOfData = electic_Locomotive.ImageMimeTypeOfData;
            }
            _context.Add(listRollingStone);
            await _context.SaveChangesAsync();

            return(View("IndexAll", await _context.ListRollingStones.ToListAsync()));
        }