public async Task <ActionResult <Resturaunts> > PostResturaunts(Resturaunts resturaunts)
        {
            _context.Resturaunt.Add(resturaunts);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetResturaunts", new { id = resturaunts.ID }, resturaunts));
        }
        public async Task <IActionResult> PutResturaunts(int id, Resturaunts resturaunts)
        {
            if (id != resturaunts.ID)
            {
                return(BadRequest());
            }

            _context.Entry(resturaunts).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ResturauntsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 3
0
        public Resturaunts Edit(Resturaunts resdata)
        {
            //Attach Method means that object which come is already in DB
            var entity = db.Resturaunt.Attach(resdata);

            entity.State = EntityState.Modified;
            return(resdata);
        }
 public IActionResult OnGet(int id)
 {
     Resturaunt = RestaurantData.GetDatabyID(id);
     if (Resturaunt == null)
     {
         return(RedirectToPage("./NotFound"));
     }
     else
     {
         return(Page());
     }
 }
Ejemplo n.º 5
0
        public Resturaunts Edit(Resturaunts resdata)
        {
            var data = resturaunts.SingleOrDefault(r => resdata.ID == r.ID);

            if (data != null)
            {
                data.Name     = resdata.Name;
                data.location = resdata.location;
                data.Type     = resdata.Type;
            }
            return(data);
        }
 public IActionResult OnPost(int id)
 {
     Resturaunt = RestaurantData.delete(id);
     RestaurantData.commit();
     if (Resturaunt == null)
     {
         return(RedirectToPage("./NotFound "));
     }
     else
     {
         TempData["Message"] = $"{Resturaunt.Name} Deleted";
         return(RedirectToPage("./List"));
     }
 }
Ejemplo n.º 7
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Resturaunts = await _context.Resturaunt.FirstOrDefaultAsync(m => m.ID == id);

            if (Resturaunts == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Resturaunts = await _context.Resturaunt.FindAsync(id);

            if (Resturaunts != null)
            {
                _context.Resturaunt.Remove(Resturaunts);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 9
0
        public IActionResult OnGet(int?id)
        {
            if (id.HasValue)
            {
                Restraunt = RestaurantData.GetDatabyID(id.Value);
            }
            else
            {
                Restraunt = new Resturaunts();
            }

            types = HtmlHelper.GetEnumSelectList <CuisineType>();
            if (Restraunt == null)
            {
                return(RedirectToPage("./NotFound"));
            }
            return(Page());
        }
Ejemplo n.º 10
0
 public Resturaunts Add(Resturaunts Data)
 {
     db.Add(Data);
     return(Data);
 }
Ejemplo n.º 11
0
 public Resturaunts Add(Resturaunts Data)
 {
     resturaunts.Add(Data);
     Data.ID = resturaunts.Max(i => i.ID) + 1;
     return(Data);
 }