예제 #1
0
        /// <summary>
        /// Delete catalog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Delete(object sender, DirectEventArgs e)
        {
            try
            {
                // init id
                var param = e.ExtraParams["Id"];

                // parse id
                if (!int.TryParse(param, out var id) || id <= 0)
                {
                    // parse error, show error
                    Dialog.ShowError("Có lỗi xảy ra trong quá trình xử lý");
                    return;
                }

                // delete
                CatalogController.Delete(hdfObjName.Text, id);

                // log action
                SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục {0}".FormatWith(hdfObjName.Text), SystemAction.Delete,
                                                              "Xóa danh mục {0}".FormatWith(id)));

                // reload data
                gpCatalog.Reload();
            }
            catch (Exception ex)
            {
                // show dilog
                Dialog.ShowError(ex);

                // log exception
                SystemLogController.Create(new SystemLogModel(CurrentUser.User.UserName, "Danh mục {0} - Delete".FormatWith(hdfObjName.Text), ex));
            }
        }
예제 #2
0
        public void DeleteCatalogItemTest()
        {
            var id   = new Guid("ce2dbb82-6689-487b-9691-0a05ebabce4a");
            var item = _items.FirstOrDefault(i => i.Id == id);

            Assert.NotNull(item);
            var okObjectResult = _controller.Delete(id);

            Assert.IsType <OkResult>(okObjectResult);
            item = _items.FirstOrDefault(i => i.Id == id);
            Assert.Null(item);
        }
예제 #3
0
 public void Should_Delete_Present_Book()
 {
     controller.Delete(2);
     mock.Verify(m => m.DeleteBook(2));
 }