public void Should_Delete_Status() { var fakeContext = new FakeContext("DeleteStatus"); fakeContext.FillWith <Status>(); using (var context = new MainContext(fakeContext.FakeOptions)) { var repository = new StatusRepository(context); var validator = new StatusValidator(); var service = new StatusService(repository, validator); var currentCount = context.Status.Count(); var newStatus = new Status(); newStatus.Name = "Testing"; service.Create(newStatus); var createdStatus = (from u in service.GetAll() where u.Id != 0 select u).FirstOrDefault(); Assert.NotEqual(0, currentCount); service.Delete(createdStatus.Id); Assert.Equal(currentCount, context.Status.Count()); repository.Dispose(); } }
public bool ExcluirStatus(Status status) { bool ret = true; if (status == null) { return(false); } if (status.StatusId == Guid.Empty) { return(false); } try { using (IDataContextAsync context = new PCFTIDataContext()) using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context)) { IRepositoryAsync <Status> StatusRepository = new Repository <Status>(context, unitOfWork); IStatusService StatusService = new StatusService(StatusRepository); status.ObjectState = INFRAESTRUTURA.TRANSVERSAL.Core.States.ObjectState.Deleted; StatusService.Delete(status.StatusId); unitOfWork.SaveChanges(); (new Execute()).Sistema.Versao.NovaVersaoParaExclusao(status); } } catch { ret = false; } return(ret); }
public void DeleteStatus(int id) { using (ServiceDB serviceDB = new ServiceDB()) { IUnitOfWork uow = new UnitOfWork(serviceDB); IStatusService service = new StatusService(uow); service.Delete(id); } }
public async Task <ActionResult <object> > Delete([FromQuery] string code) { try { return(await _statusService.Delete(code)); } catch (Exception ex) { return(new ApiResponse(ex.Message)); } }
public HttpResponseMessage Delete(int id) { try { StatusService svc = new StatusService(); svc.Delete(id); SuccessResponse resp = new SuccessResponse(); return(Request.CreateResponse(HttpStatusCode.OK, resp)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
/// <summary> /// ɾ³ýÎÒµÄÉÁ´æ /// </summary> /// <param name="model"></param> private void Delete(StatusModel model) { ProgressDialog progressDialog = new ProgressDialog(Activity); progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner); progressDialog.SetMessage("ɾ³ýÖÐ...."); progressDialog.Show(); StatusService.Delete(UserTokenUtil.GetToken(Activity), model.Id, (success) => { Activity.RunOnUiThread(() => { progressDialog.Hide(); statusList.Remove(model); adapter.SetNewData(statusList); }); }, (error) => { Activity.RunOnUiThread(() => { progressDialog.Hide(); AlertUtil.ToastShort(Activity, error); }); }); }
// DELETE api/<controller>/5 public IHttpActionResult Delete(int id) { return(Utils.Response(Service.Delete(id), HttpStatusCode.NotFound, string.Format("Could not delete status with id {0}.", id), Request.RequestUri.AbsoluteUri)); }