예제 #1
0
        public ActionResult Delete(int id)
        {
            if (userRepository.FindAll(user => user.AreaId == id, null).Any())
            {
                TempData[MESSAGE_KEY] = Resources.Resources.MsgCanNotDeleteAreaWithUser;
                return(RedirectToAction("Index"));
            }

            if (deviceRepository.FindAll(device => device.AreaId == id, null).Any())
            {
                TempData[MESSAGE_KEY] = Resources.Resources.MsgCanNotDeleteAreaWithDevice;
                return(RedirectToAction("Index"));
            }

            if (areaRepository.Count() == 1)
            {
                TempData[MESSAGE_KEY] = Resources.Resources.MsgAtLeastOneAreaInSystem;
                return(RedirectToAction("Index"));
            }

            Area existing = areaRepository.Get(id);

            areaRepository.Delete(existing);

            auditLogRepository.Add(
                AuditLogBuilder.Builder()
                .User(HttpContext.User.Identity.Name)
                .Deleted(typeof(Area), existing.Name)
                .With(new ChangeInfo().AddChange(() => existing.Name).ToJson())
                .Build());

            logger.Info("User '{0}' deleted area '{1}'.", Identity.Name, existing.Name);
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public async Task <IActionResult> DeleteArea([FromRoute] Guid id)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var areaData = await _areaRepo.GetArea(id);

                if (areaData == null)
                {
                    return(NotFound());
                }
                if (areaData.Protected == true)
                {
                    ModelState.AddModelError("Error", "This record is a protected record. It can not be deleted");
                    return(BadRequest(ModelState));
                }

                _areaRepo.Delete(areaData);
                await _unitOfWork.CompleteAsync();

                return(Ok(id));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", "An error occured while performing this operation. There might be some records depending on this record");
                return(BadRequest(ModelState));
            }
        }
예제 #3
0
        public ActionResult DeleteConfirmed(long id)
        {
            areaRepository.Delete(id);
            areaRepository.Save();

            return(RedirectToAction("Index"));
        }
예제 #4
0
        public async Task <bool> Handle(DeleteAreaCommand request, CancellationToken cancellationToken)
        {
            _writeRepository.Delete(request.AreaCod);

            //return await writeRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
            return(await _writeRepository.SaveAsync(cancellationToken));
        }
예제 #5
0
        /// <summary>
        /// 删除地区
        /// </summary>
        /// <param name="areaCode">地区编码</param>
        public void Delete(string areaCode)
        {
            Area area = Get(areaCode);

            EventBus <Area> .Instance().OnBefore(area, new CommonEventArgs(EventOperationType.Instance().Delete()));

            areaRepository.Delete(areaCode);
            EventBus <Area> .Instance().OnAfter(area, new CommonEventArgs(EventOperationType.Instance().Delete()));
        }
예제 #6
0
 public void DeleteForm(string keyValue)
 {
     if (service.Count(m => m.F_ParentId, m => m.F_ParentId == keyValue) > 0)
     {
         throw new Exception("删除失败!操作的对象包含了下级数据。");
     }
     else
     {
         service.Delete(m => m.F_Id == keyValue);
     }
 }
예제 #7
0
        // GET: AreaController/Delete/5
        public ActionResult Delete(int id)
        {
            var country   = _areaRepository.FindById(id);
            var isSuccess = _areaRepository.Delete(country);

            if (!isSuccess)
            {
                return(BadRequest());
            }
            return(RedirectToAction(nameof(Index)));
        }
예제 #8
0
 public void DeleteForm(string keyValue)
 {
     if (service.IQueryable().Count(t => t.F_ParentId.Equals(keyValue)) > 0)
     {
         throw new Exception("删除失败!操作的对象包含了下级数据。");
     }
     else
     {
         service.Delete(t => t.F_Id == keyValue);
     }
 }
예제 #9
0
        /// <summary>
        /// Delete Area by id
        /// </summary>
        public void DeleteArea(long areaId)
        {
            Area dbversion = areaRepository.Find((int)areaId);

            ValidateBeforeDeletion(areaId);
            if (dbversion == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
                                                                  "Area with Id {0} not found!", areaId));
            }
            areaRepository.Delete(dbversion);
            areaRepository.SaveChanges();
        }
예제 #10
0
        public bool DeleteArea(AreaDto request)
        {
            ValidateAreIdRequired(request);
            ValidationAreIdExist(request);
            var lialEmployedId = _repoEmployed
                                 .SearchMatching <EmployedEntity>(employed => employed.AreaId == request.AreaId)
                                 .Any();

            if (lialEmployedId)
            {
                throw new AreaIdIsAssociatedToEmployedException($"Este id: {request.AreaId} ya esta asociado con un empleado");
            }

            return(_repoArea.Delete(_mapper.Map <AreaEntity>(request)));
        }
예제 #11
0
        public void RemoveArea(int id)
        {
            var area = _areaRepository.Get(id);;

            if (area == null)
            {
                throw new NullReferenceException("Area does not exist!");
            }

            var activeBenefits = _benefitRepository.GetActive(area.Id).Count;

            if (activeBenefits != 0)
            {
                new Exception("Active programs present.");
            }
            _benefitRepository.DeleteAll(area.Id);
            _areaRepository.Delete(id, area);
        }
예제 #12
0
        /// <summary>
        /// 删除区域信息
        /// </summary>
        /// <param name="keyValue"></param>
        public void DeleteForm(string keyValue)
        {
            ResultClass <List <AreaEntity> > _ret = service.FindList(new AreaEntity()
            {
                F_ParentId = keyValue
            });

            if (!_ret.Result)
            {
                ResultClass <int> _rets = service.Delete(t => t.F_Id == keyValue);
                if (!_rets.Result)
                {
                    throw new Exception(_rets.ErrorMessage);
                }
            }
            else
            {
                throw new Exception("删除失败!操作的对象包含了下级数据。");
            }
        }
예제 #13
0
        public IActionResult Delete(int id)
        {
            Area _areaDb = _areaRepository.GetSingle(id);

            if (_areaDb == null)
            {
                return(new NotFoundResult());
            }

            IEnumerable <Suggestion> _suggestions = _suggestionRepository.FindBy(s => s.AreaId == id);

            foreach (var suggestion in _suggestions)
            {
                _suggestionRepository.Delete(suggestion);
            }

            _areaRepository.Delete(_areaDb);
            _areaRepository.Commit();

            return(new NoContentResult());
        }
예제 #14
0
 public void DeletePriorityEmployee(PriorityEmployee entity)
 {
     _areaRepository.Delete(entity);
 }
예제 #15
0
 public void Delete(int id)
 {
     repository.Delete(id);
 }
예제 #16
0
 public void DeleteArea(long id) => _areaRepository.Delete(_areaRepository.Get(id));
예제 #17
0
 public async Task <int> DeleteAreaAsync(Area Area)
 {
     return(await _areaRepo.Delete(Area));
 }
예제 #18
0
 public void Delete(AreaEntity entity)
 {
     service.Delete(entity);
 }
예제 #19
0
        public async Task <ActionResult> DeleteArea(int id)
        {
            await areaRepository.Delete(id);

            return(Redirect(Request.UrlReferrer.ToString()));
        }