コード例 #1
0
        public IActionResult AddWayToAvto(int id)
        {
            AddWayViewModel addWayViewModel = new AddWayViewModel()
            {
                Avto_Key   = id,
                ways       = _context.ways,
                work_Datas = _context.work_data.Include(e => e.worker).Where(e => e.profession.Profession_Key == 1).Where(e => e.Department_Key == _context.avtoes.Where(r => r.Avto_Key == id).FirstOrDefault().Department_Key)
            };

            return(View(addWayViewModel));
        }
コード例 #2
0
        public IActionResult AddWayToAvto(AddWayViewModel model, int ways, string worker)
        {
            division division = new division()
            {
                date_end    = model.date_end,
                date_start  = model.date_start,
                way         = _context.ways.Where(e => e.Ways_Key == ways).FirstOrDefault(),
                avto_worker = _context.avto_worker.Where(e => e.work_data.worker.fullname == worker).FirstOrDefault()
            };

            division.Avto_Worker_Key = division.avto_worker.Avto_Worker_Key;
            division.Ways_Key        = division.way.Ways_Key;
            _context.divisions.Add(division);
            _context.SaveChanges();
            return(RedirectToAction("ShowAvto", "Shows", new { id = model.Avto_Key }));
        }