Exemplo n.º 1
0
 public IActionResult EditRestaurent(string id, Restaurent res)
 {
     if (id != null)
     {
         res.Name        = "updateRes";
         res.Discription = "updateTest";
     }
     return(this.Ok(res));
 }
Exemplo n.º 2
0
 public IActionResult OnGet(int id)
 {
     Restaurent = _restaurentData.Get(id);
     if (Restaurent == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(Page());
 }
Exemplo n.º 3
0
 public IActionResult Create(Restaurent restaurent)
 {
     if (ModelState.IsValid)
     {
         restaurent = _restaurent.Add(restaurent);
         return(RedirectToAction(nameof(Details), new { id = restaurent.Id }));
     }
     else
     {
         return(View());
     }
 }
        public IActionResult Create(EditRestaurentViewModel restaurent)
        {
            if (ModelState.IsValid)
            {
                Restaurent aRestaurent = new Restaurent();
                aRestaurent.Name = restaurent.Name;
                aRestaurent.Type = restaurent.Type;

                _restaurentData.Add(aRestaurent);
                return(RedirectToAction("Details", new { id = aRestaurent.Id }));
            }
            return(View());
        }
Exemplo n.º 5
0
        public Restaurent Add(Restaurent restaurent)
        {
            //_restaurant.Restaurents.Add(restaurent);
            //_restaurant.SaveChanges();
            //return restaurent;
            //var result = _restaurant.Database.ExecuteSqlCommand("spInsertion @Name, @City, @ContactNumber", parameters: new[] {
            //    restaurent.Name,
            //    restaurent.City,
            //    restaurent.ContactNumber.ToString()
            //});
            Restaurent result = _restaurant.Set <Restaurent>().FromSql("spInsertion @Name={0} ,@City ={1}, @ContactNumber={2}", restaurent.Name, restaurent.City, restaurent.ContactNumber).Single();

            return(result);
        }
Exemplo n.º 6
0
 public Restaurent Edit(Restaurent restaurent)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
 public Restaurent Add(Restaurent restaurent)
 {
     restaurent.Id = _restaurents.Max(a => a.Id) + 1;
     _restaurents.Add(restaurent);
     return(restaurent);
 }
Exemplo n.º 8
0
 public IActionResult SaveRestaurent([FromBody] Restaurent res)
 {
     res.Id = Guid.NewGuid().ToString();
     return(this.Ok(res));
 }
 public void Add(Restaurent aRestaurent)
 {
     context.Restaurents.Add(aRestaurent);
     context.SaveChanges();
 }
Exemplo n.º 10
0
 public Restaurent Edit(Restaurent restaurent)
 {
     _restaurant.Attach(restaurent).State = EntityState.Modified;
     _restaurant.SaveChanges();
     return(restaurent);
 }