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); }
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); } if (employee.Id == -1) return this.Ok<int>(await Clear()); var result = await this.DeleteAsync(employee); return this.Ok<bool>(result); }
private async Task<bool> DeleteAsync(Employee employee) { var result = await this._context.Delete(employee); return result; }
//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; }