示例#1
0
        public async Task<IHttpActionResult> Patch(Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            var result = await this._context.Update(employee);
            return this.Ok<Employee>(result);
        }
示例#2
0
        public async Task<IHttpActionResult> Post(Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }


            var result = await this.StoreAsync(employee);
            return this.Ok<Employee>(result);
        }
示例#3
0
        public async Task<IHttpActionResult> Delete(Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return this.BadRequest(this.ModelState);
            }

            if (employee.Id == -1)
                return this.Ok<int>(await Clear());

            var result = await this.DeleteAsync(employee);
            return this.Ok<bool>(result);
        }
示例#4
0
       private async Task<bool> DeleteAsync(Employee employee)
       {
           var result = await this._context.Delete(employee);

           return result;
       }
示例#5
0
        //public async Task<IHttpActionResult> Post(Employee employee)
        //{
        //    if (!ModelState.IsValid)
        //    {
        //        return this.BadRequest(this.ModelState);
        //    }


        //    var result = await this.StoreAsync(employee);
        //    return this.Ok<Employee>(result);
        //}

        //public async Task<IHttpActionResult> Delete(Employee employee)
        //{
        //    if (!ModelState.IsValid)
        //    {
        //        return this.BadRequest(this.ModelState);
        //    }


        //    var result = await this.DeleteAsync(employee);
        //    return this.Ok<bool>(result);
        //}

        //public async Task<IHttpActionResult> Patch(Employee employee)
        //{
        //    if (!ModelState.IsValid)
        //    {
        //        return this.BadRequest(this.ModelState);
        //    }


        //    var result = await this._context.Update(employee);
        //    return this.Ok<Employee>(result);
        //}

        private async Task<Employee> StoreAsync(Employee employee)
       {
           var result = await this._context.Add(employee);

           return result;
       }