Exemplo n.º 1
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="t"></param>
 /// <param name="saved"></param>
 /// <returns></returns>
 public async Task EditAsync(T t, bool saved = true)
 {
     _db.Entry(t).State = System.Data.Entity.EntityState.Modified;
     if (saved)
     {
         await SaveAsync();
     }
 }
Exemplo n.º 2
0
        public string Edit(Student Model)
        {
            Models.StudentContext db = new Models.StudentContext();
            string msg;

            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(Model).State = EntityState.Modified;
                    db.SaveChanges();
                    msg = "Saved Successfully";
                }
                else
                {
                    msg = "Validation data not successfully";
                }
            }
            catch (Exception ex)
            {
                msg = "Error occured:" + ex.Message;
            }
            return(msg);
        }