Ejemplo n.º 1
0
        public async Task ComUmaDiferenca()
        {
            var first = regionRepository.Get(1);

            regionRepository.Delete(first);
            regionRepository.Create(new Region(1, "V", "Vorte"));
            var result = await regionDiffServices.Get();

            Assert.NotEmpty(result.Diffs);
        }
Ejemplo n.º 2
0
 public override async Task <int> HandleCommand(DeleteCommand request, CancellationToken cancellationToken)
 {
     return(await regionRepository.Delete(DeleteBuild(new Region()
     {
         Id = request.RegionId
     }, request.LoginSession)));
 }
Ejemplo n.º 3
0
        public async Task <bool> Handle(RemoveRegionCommand request, CancellationToken cancellationToken)
        {
            Domain.AggregatesModel.RegionAggregate.Region region = await _regionRepository.GetAsync(request.Id);

            _regionRepository.Delete(region);
            var result = await _regionRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);

            return(result);
        }
Ejemplo n.º 4
0
        public async Task Delete(int id)
        {
            var repoResult = await _repository.Find(p => p.Id == id);

            var u = repoResult.SingleOrDefault();

            if (u != null)
            {
                await _repository.Delete(u);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Delete Region by id
        /// </summary>
        public void DeleteRegion(long regionId)
        {
            Region dbversion = regionRepository.Find((int)regionId);

            ValidateBeforeDeletion(regionId);
            if (dbversion == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
                                                                  "Region with Id {0} not found!", regionId));
            }
            regionRepository.Delete(dbversion);
            regionRepository.SaveChanges();
        }
Ejemplo n.º 6
0
 // GET: Municipio/Delete/5
 public ActionResult Delete(int id)
 {
     try
     {
         repository.Delete(id);
         return(RedirectToAction("List"));
     }
     catch (Exception ex)
     {
         TempData["message"] = $"Error: {ex.Message}";
         return(View());
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// The Delete
 /// </summary>
 /// <param name="entity">The entity<see cref="Region"/></param>
 /// <returns>The <see cref="ServiceResult"/></returns>
 public ServiceResult Delete(Region entity)
 {
     try
     {
         _repository.Delete(entity);
         return(new ServiceResult(true));
     }
     catch (Exception ex)
     {
         return(new ServiceResult(false)
         {
             Error = ex.ToString()
         });
     }
 }
        public bool DeleteOneRegion()
        {
            if (InputIsEmpty)
            {
                return(false);
            }

            OptimizeRegion region = _service.Query();

            if (region == null)
            {
                return(false);
            }
            _repository.Delete(region);
            return(true);
        }
        public IActionResult Delete(int Id)
        {
            CommonResponse <int> response = new CommonResponse <int>();
            var result = _regionRepository.Delete(Id, this.loginUserId);

            if (result == 0)
            {
                response.status  = Helper.failure_code;
                response.message = Message.regionDeletedError;
            }
            else
            {
                response.status  = Helper.success_code;
                response.message = Message.regionDeleted;
            }
            return(Ok(response));
        }
Ejemplo n.º 10
0
        ///<Summary>
        ///Delete
        ///This method deletes one Region record from the store
        ///</Summary>
        ///<returns>
        ///void
        ///</returns>
        ///<parameters>
        ///
        ///</parameters>
        public virtual void Delete()
        {
            Doing(this);
            IDAORegion daoRegion = _iRegionRepository.New();

            RegisterDataObject(_iRegionRepository, _iRegionRepository.BaseData(daoRegion));
            BeginTransaction(_iRegionRepository, "deleteBORegion");
            try
            {
                daoRegion.RegionID = _regionID;
                _iRegionRepository.Delete(daoRegion);
                CommitTransaction(_iRegionRepository);
                Done(this);
            }
            catch (Exception ex)
            {
                Failed(this, ex);
                RollbackTransaction(_iRegionRepository, "deleteBORegion");
                Handle(this, ex);
            }
        }
Ejemplo n.º 11
0
 public ActionResult Delete(Region region)
 {
     _regionRepository.Delete(region.Id);
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Used to delete Region
 /// </summary>
 /// <param name="region">holds the region data</param>
 public async Task Delete(Region region)
 {
     await _regionRepository.Delete(region);
 }
Ejemplo n.º 13
0
 public int Delete(Guid[] ids)
 {
     return(_regionRepository.Delete(ids));
 }
Ejemplo n.º 14
0
 public RegionModel Delete(int id)
 {
     return(_repository.Delete(id));
 }
Ejemplo n.º 15
0
        public void DeleteRegion(int id)
        {
            var regionEF = regionRepository.GetBy(id);

            regionRepository.Delete(regionEF);
        }
Ejemplo n.º 16
0
 public void Delete(int IdRegion)
 {
     _repository.Delete(IdRegion);
 }
        public async Task <IActionResult> RegionUpdate([FromBody] CmsPostWebHookApiModel model)
        {
            if (model == null)
            {
                return(BadRequest("delete model empty or null."));
            }

            var postId = model.post_id;

            if (postId <= 0)
            {
                return(BadRequest($"post id null. model.post_id: {postId}"));
            }

            if (model.post.post_status == "trash")
            {
                var removeSuccessful = await _regionRepository.Delete(postId);

                if (!removeSuccessful)
                {
                    _logger.LogError("Failed to delete region with id: {PostId} in elasticsearch.", postId);
                    return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to delete region."));
                }
                return(NoContent());
            }

            var cmsRegion = await _cmsApiProxy.GetRegion(postId);

            var elasticRegion = await MapToElasticModel(cmsRegion);

            bool successful;
            var  region = await _regionRepository.Get(postId);

            if (region == null)
            {
                successful = await _regionRepository.Insert(new List <RegionElasticModel> {
                    elasticRegion
                });

                if (!successful)
                {
                    _logger.LogError("Failed to insert region with id:{PostId} in elasticsearch.", postId);
                    return(BadRequest("Failed to insert region."));
                }

                _logger.LogInformation("Inserted region with id {PostId} to elasticsearch successfully.", postId);

                return(Created(elasticRegion.Id.ToString(), elasticRegion));
            }

            successful = await _regionRepository.Update(elasticRegion);

            if (!successful)
            {
                _logger.LogError("Failed to update region with id:{PostId} in elasticsearch.", postId);
                return(BadRequest("Failed to update region."));
            }

            _logger.LogInformation("Updated region with id {PostId} to elasticsearch successfully.", postId);

            // TODO: FIX THIS!!!!!!
            // Update business cache!
            await SyncBusiness();

            // Update pages cache!
            var apiPath = model.post.post_type;

            _cmsApiProxy.RemovePagesCache(apiPath);
            await _cmsApiProxy.GetPages(regionPageApiPath : apiPath);

            return(Ok());
        }