public IActionResult Create() { var model = new Resturent(); var viewModel = new ResturentViewModel { Cusines = _htmlHelper.GetEnumSelectList <CusineType>(), Resturent = model, }; return(View(viewModel)); }
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; } }
public IActionResult Create(Resturent resturent) { if (ModelState.IsValid) { _resturent.Create(resturent); _resturent.Commit(); return(RedirectToAction("Index")); } return(View(resturent)); }
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)); }
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"); } }
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")); }
public void Create(Resturent resturent) { resturents.Add(resturent); }
public void Create(Resturent resturent) { _context.Add(resturent); }