private void DoLinkActions(string action) { LinkService ls = LinkService.GetInstance(); if (action.Equals("LinkOrder")) { string id = Request["Id"]; string order = Request["Order"]; int r = ls.ChangeOrder(id, int.Parse(order)); if (r > 0) { json = "{\"result\":1}"; } else { json = "{\"result\":0, \"msg\":\"服务器发生错误,排序失败!\"}"; } } else if (action.Equals("LinkDelete")) { string id = Request["Id"]; int r = ls.Delete(id); if (r > 0) { json = "{\"result\":1}"; } else { json = "{\"result\":0, \"msg\":\"服务器发生错误,删除失败!\"}"; } } }
public ActionResult DeleteLinks([FromQuery] int id) { if (id == 0) { return(BadRequest("Link id should be specified")); } _linkService.Delete(id); return(Ok()); }
public HttpResponseMessage Delete(int id) { try { linkService.Delete(id); SuccessResponse resp = new SuccessResponse(); return(Request.CreateResponse(HttpStatusCode.OK, resp)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public async void Delete() { var mock = new ServiceMockFacade <ILinkRepository>(); var model = new ApiLinkRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new LinkService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.LinkModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLLinkMapperMock, mock.DALMapperMockFactory.DALLinkMapperMock, mock.BOLMapperMockFactory.BOLLinkLogMapperMock, mock.DALMapperMockFactory.DALLinkLogMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.LinkModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); }
public async void Delete_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <ILinkService, ILinkRepository>(); var model = new ApiLinkServerRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new LinkService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.LinkModelValidatorMock.Object, mock.DALMapperMockFactory.DALLinkMapperMock, mock.DALMapperMockFactory.DALLinkLogMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.LinkModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <LinkDeletedNotification>(), It.IsAny <CancellationToken>())); }
public async void DeleteLink(Link objectToDelete) { var dialog = new MessageDialog("Czy jesteś pewien usunięcia grupy '" + objectToDelete.Description + "' ?"); dialog.Title = "Naprawdę?"; dialog.Commands.Add(new UICommand { Label = "Tak", Id = 0 }); dialog.Commands.Add(new UICommand { Label = "Nie", Id = 1 }); var res = await dialog.ShowAsync(); if ((int)res.Id == 0) { using (var logic = new LinkService()) { logic.Delete(objectToDelete); } Links.Remove(objectToDelete); } }
public async void Delete_ErrorsOccurred_ShouldReturnErrorResponse() { var mock = new ServiceMockFacade <ILinkService, ILinkRepository>(); var model = new ApiLinkServerRequestModel(); var validatorMock = new Mock <IApiLinkServerRequestModelValidator>(); validatorMock.Setup(x => x.ValidateDeleteAsync(It.IsAny <int>())).Returns(Task.FromResult(new FluentValidation.Results.ValidationResult(new List <ValidationFailure>() { new ValidationFailure("text", "test") }))); var service = new LinkService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, validatorMock.Object, mock.DALMapperMockFactory.DALLinkMapperMock, mock.DALMapperMockFactory.DALLinkLogMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeFalse(); validatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <LinkDeletedNotification>(), It.IsAny <CancellationToken>()), Times.Never()); }
public async Task <IActionResult> Delete(string id) { await _linkService.Delete(id); return(Ok()); }