Exemplo n.º 1
0
        /// <summary>
        ///     Edits the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="outlet">The outlet.</param>
        /// <returns>Task&lt;Outlet&gt;.</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;
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Edits the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="user">The user.</param>
        /// <returns>Task&lt;User&gt;.</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;
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Edits the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="model">The model.</param>
        /// <returns>Task&lt;Model&gt;.</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;
        }