コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public void DeleteStatus(int id)
 {
     using (ServiceDB serviceDB = new ServiceDB())
     {
         IUnitOfWork    uow     = new UnitOfWork(serviceDB);
         IStatusService service = new StatusService(uow);
         service.Delete(id);
     }
 }
コード例 #4
0
 public async Task <ActionResult <object> > Delete([FromQuery] string code)
 {
     try
     {
         return(await _statusService.Delete(code));
     }
     catch (Exception ex)
     {
         return(new ApiResponse(ex.Message));
     }
 }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        /// <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);
                });
            });
        }
コード例 #7
0
 // 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));
 }