예제 #1
0
 private void barButtonDelete_ItemClick(object sender, ItemClickEventArgs e)
 {
     _nhanVienRepository.Delete(NhanVienIdRowSelected);
     gridView1.DeleteRow(numrow);
     XtraMessageBox.Show("Xoá nhân viên thành công");
     barButtonLoad_ItemClick(sender, e);
 }
예제 #2
0
        public async Task <ActionResultDto> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                var count = 0;

                var repo = new NhanVienRepository(context);

                for (int i = 0; i < _listId.Count; i++)
                {
                    if (_listId[i] > 0 && await repo.Delete(_listId[i]))
                    {
                        count++;
                    }
                }
                return(ActionHelper.returnActionResult(HttpStatusCode.OK, count, null));
            }
            catch (FormatException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
        }
예제 #3
0
        public HttpResponseMessage DeleteNhanVien(int id)
        {
            var nhanVien = _repository.Get(id);

            try
            {
                if (nhanVien != null)
                {
                    _repository.Delete(id);
                    return(Request.CreateResponse(HttpStatusCode.OK, nhanVien));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound, "NhanVien Not Found"));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Lỗi không xác định", ex));
            }
        }