Ejemplo n.º 1
0
        public IActionResult Create()
        {
            var model     = new Resturent();
            var viewModel = new ResturentViewModel
            {
                Cusines   = _htmlHelper.GetEnumSelectList <CusineType>(),
                Resturent = model,
            };

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public void Update(Resturent resturent)
        {
            var resutentToUpdate = resturents.FirstOrDefault(c => c.Id == resturent.Id);

            if (resutentToUpdate != null)
            {
                resutentToUpdate.Name     = resturent.Name;
                resutentToUpdate.Location = resturent.Location;
                resutentToUpdate.Cusine   = resturent.Cusine;
            }
        }
Ejemplo n.º 3
0
        public IActionResult Create(Resturent resturent)
        {
            if (ModelState.IsValid)
            {
                _resturent.Create(resturent);
                _resturent.Commit();

                return(RedirectToAction("Index"));
            }

            return(View(resturent));
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            // Test Of Bacon class
            //BaconDecorator baconDecorator = new BaconDecorator();

            //Test of PizzaFactory


            Resturent resturent = new Resturent();

            resturent.ResturentRun();
        }
        public async Task <IActionResult> CreateResturent([Bind("ResturentId,Type,Name,Address")] Resturent resturent)
        {
            if (ModelState.IsValid)
            {
                // _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Resturent ON"); skulle fikse så man kan create med resturentID men constraints er f****d. ;(
                _context.Add(resturent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(resturent));
        }
Ejemplo n.º 6
0
        public void Update(Resturent resturent)
        {
            var updateToResturent = _context.Resturents.FirstOrDefault(c => c.Id == resturent.Id);

            if (updateToResturent != null)
            {
                updateToResturent = resturent;
            }

            else
            {
                throw new Exception("Not found");
            }
        }
Ejemplo n.º 7
0
        public IActionResult Edit(Resturent resturent, int id)
        {
            var updateToResturent = _resturent.GetById(id);

            //if (updateToResturent == null) {


            //    return NotFound();

            //}


            updateToResturent.Name     = resturent.Name;
            updateToResturent.Cusine   = resturent.Cusine;
            updateToResturent.Location = resturent.Location;

            _resturent.Commit();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
 public void Create(Resturent resturent)
 {
     resturents.Add(resturent);
 }
Ejemplo n.º 9
0
 public void Create(Resturent resturent)
 {
     _context.Add(resturent);
 }