Пример #1
0
        public async Task <IActionResult> Edit(Odam odam)
        {
            db.Odamon.Update(odam);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async Task <IActionResult> ConfirmDelete(int?Id)
        {
            if (Id != null)
            {
                Odam odam = await db.Odamon.FirstOrDefaultAsync(p => p.Id == Id);

                if (odam != null)
                {
                    return(View(odam));
                }
            }
            return(NotFound());
        }
Пример #3
0
        public async Task <IActionResult> Delete(int?Id)
        {
            if (Id != null)
            {
                Odam odam = new Odam {
                    Id = Id.Value
                };
                db.Entry(odam).State = EntityState.Deleted;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));

                #region
                //Odam odam = await db.Odamon.FirstOrDefaultAsync(p => p.Id == Id);
                //if (odam != null)
                //{
                //    db.Odamon.Remove(odam);
                //    await db.SaveChangesAsync();
                //    return RedirectToAction("Index");
                //}
                #endregion
            }
            return(NotFound());
        }