public async Task <ApiResultLite> CreateAsync(KindOfSeatCreateRequest request) { KindOfSeat kindOfSeat = new KindOfSeat() { Name = request.Name, Surcharge = request.SurCharge }; _context.KindOfSeats.Add(kindOfSeat); int result = await _context.SaveChangesAsync(); if (result == 0) { return(new ApiErrorResultLite("Tạo mới thất bại")); } return(new ApiSuccessResultLite()); }
public async Task <ApiResultLite> DeleteAsync(int id) { KindOfSeat seat = await _context.KindOfSeats.FindAsync(id); if (seat == null) { return(new ApiErrorResultLite("Không tìm thấy")); } else { _context.KindOfSeats.Remove(seat); if (await _context.SaveChangesAsync() != 0) { return(new ApiSuccessResultLite("Xóa thành công")); } else { return(new ApiErrorResultLite("Xóa thất bại")); } } }
public async Task <ApiResultLite> UpdateAsync(KindOfSeatUpdateRequest request) { KindOfSeat seat = await _context.KindOfSeats.FindAsync(request.Id); if (seat == null) { return(new ApiErrorResultLite("Không tìm thấy")); } else { seat.Name = request.Name; seat.Surcharge = request.Surcharge; _context.Update(seat); if (await _context.SaveChangesAsync() != 0) { return(new ApiSuccessResultLite("Cập nhật thành công")); } else { return(new ApiErrorResultLite("Cập nhật thất bại mới thất bại")); } } }