/// <summary> /// Edits the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <param name="outlet">The outlet.</param> /// <returns>Task<Outlet>.</returns> public async Task<Outlet> Edit(int id, Outlet outlet) { using (ChePingContext db = new ChePingContext()) { await db.SaveOrUpdateAsync(outlet, o => o.Id == id); } return outlet; }
/// <summary> /// Edits the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <param name="user">The user.</param> /// <returns>Task<User>.</returns> public async Task<User> Edit(int id, User user) { using (ChePingContext db = new ChePingContext()) { await db.SaveOrUpdateAsync(user, t => t.Id == id); } return user; }
/// <summary> /// Edits the specified identifier. /// </summary> /// <param name="id">The identifier.</param> /// <param name="model">The model.</param> /// <returns>Task<Model>.</returns> /// <exception cref="System.ApplicationException">车型信息已经存在</exception> public async Task<Model> Edit(int id, Model model) { if (await this.Exist(model)) { throw new ApplicationException("车型信息已经存在"); } using (ChePingContext db = new ChePingContext()) { await db.SaveOrUpdateAsync(model, t => t.Id == id); } return model; }