Exemple #1
0
        public ActionResult DeleteOrg(int id)
        {
            var org     = _repOrg.Find(id);
            var orgUser = _repOrgUser.GetAll();
            var list    = orgUser.Where(c => c.OrgId == id).ToList();

            if (list.Count > 0)
            {
                foreach (var item in list)
                {
                    _repOrgUser.Delete(item);
                }
            }
            var OrgImage  = _repOrgImage.GetAll();
            var listImage = OrgImage.Where(c => c.OrgId == id).ToList();

            if (listImage.Count > 0)
            {
                foreach (var item in listImage)
                {
                    _repOrgImage.Delete(item);
                }
            }
            _repOrg.Delete(org);
            return(RedirectToAction("Index"));
        }
        public bool Delete(Organization organization)
        {
            int rowAffected = organizationRepository.Delete(organization);

            bool isSaved = rowAffected > 0;

            return(isSaved);
        }
        public bool Delete(int?id)
        {
            int rowAffected = _organizationRepository.Delete(id);

            bool isDeleted = rowAffected > 0;

            return(isDeleted);
        }
        //Get Delete
        public bool Delete(int Id)
        {
            var isDelete = false;

            isDelete = _organizationRepository.Delete(Id);
            if (isDelete)
            {
                return(true);
            }
            return(isDelete);
        }
Exemple #5
0
        /// <summary>
        /// 删除组织机构信息信息
        /// </summary>
        /// <param name="ids">要删除的组织机构信息编号</param>
        /// <returns>业务操作结果</returns>
        public OperationResult DeleteOrganizations(params int[] ids)
        {
            ids.CheckNotNull("ids");
            OperationResult result = OrganizationRepository.Delete(ids,
                                                                   entity =>
            {
                if (entity.Children.Any())
                {
                    throw new Exception("组织机构“{0}”的子级不为空,不能删除。".FormatWith(entity.Name));
                }
            });

            return(result);
        }
Exemple #6
0
        public IActionResult Delete(int Id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                return(Ok(_organizationRepository.Delete(Id)));
            }
            catch
            {
                return(BadRequest(ModelState)); //or you can throw new Exception
            }
        }
Exemple #7
0
 public HttpResponseMessage Delete(HttpRequestMessage request, int id)
 {
     try
     {
         using (OrganizationRepository rep = new OrganizationRepository())
         {
             Func <Organization, bool> delete = (o => o.ID == id);
             rep.Delete(delete);
             rep.SaveAll();
         }
         return(request.CreateResponse(HttpStatusCode.Accepted));
     }
     catch (Exception e)
     {
         return(request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message));
     }
 }
 public ActionResult OrganizationDelete(int id)
 {
     _orgRep.Delete(id);
     return(RedirectToAction("OrganizationList"));
 }
Exemple #9
0
 public bool Delete(int id)
 {
     return(_organizationRepository.Delete(id));
 }
        private void TryDeleteOrganization(Organization organization)
        {
            try {
                Log.Info().Message("Checking to see if organization '{0}' with Id: '{1}' can be deleted.", organization.Name, organization.Id).Write();

                ObjectId id;
                if (String.IsNullOrWhiteSpace(organization.Id) || !ObjectId.TryParse(organization.Id, out id))
                {
                    Log.Info().Message("Organization '{0}' with Id: '{1}' has an invalid id.", organization.Name, organization.Id).Write();
                    return;
                }

                if (id.CreationTime >= DateTime.Now.SubtractDays(90))
                {
                    Log.Info().Message("Organization '{0}' with Id: '{1}' has been created less than 90 days ago.", organization.Name, organization.Id).Write();
                    return;
                }

                if (organization.LastErrorDate >= DateTime.Now.SubtractDays(90))
                {
                    Log.Info().Message("Organization '{0}' with Id: '{1}' has had an exception newer than 90 days.", organization.Name, organization.Id).Write();
                    return;
                }

                if (!String.IsNullOrEmpty(organization.StripeCustomerId))
                {
                    Log.Info().Message("Organization '{0}' with Id: '{1}' has a stripe customer id and cannot be deleted.", organization.Name, organization.Id).Write();
                    return;
                }

                Log.Info().Message("Removing existing empty projects for the organization '{0}' with Id: '{1}'.", organization.Name, organization.Id).Write();
                List <Project> projects = _projectRepository.GetByOrganizationId(organization.Id).ToList();
                if (projects.Any(project => project.TotalErrorCount > 0))
                {
                    Log.Info().Message("Organization '{0}' with Id: '{1}' has a project with existing data. This organization will not be deleted.", organization.Name, organization.Id).Write();
                    return;
                }

                foreach (Project project in projects)
                {
                    Log.Info().Message("Resetting all project data for project '{0}' with Id: '{1}'.", project.Name, project.Id).Write();
                    _errorStackRepository.RemoveAllByProjectId(project.Id);
                    _errorRepository.RemoveAllByProjectId(project.Id);
                    _dayStackStats.RemoveAllByProjectId(project.Id);
                    _monthStackStats.RemoveAllByProjectId(project.Id);
                    _dayProjectStats.RemoveAllByProjectId(project.Id);
                    _monthProjectStats.RemoveAllByProjectId(project.Id);
                }

                Log.Info().Message("Deleting all projects for organization '{0}' with Id: '{1}'.", organization.Name, organization.Id).Write();
                _projectRepository.Delete(projects);

                Log.Info().Message("Removing users from organization '{0}' with Id: '{1}'.", organization.Name, organization.Id).Write();
                List <User> users = _userRepository.GetByOrganizationId(organization.Id).ToList();
                foreach (User user in users)
                {
                    if (user.OrganizationIds.All(oid => String.Equals(oid, organization.Id)))
                    {
                        Log.Info().Message("Removing user '{0}' as they do not belong to any other organizations.", user.Id, organization.Name, organization.Id).Write();
                        _userRepository.Delete(user.Id);
                    }
                    else
                    {
                        Log.Info().Message("Removing user '{0}' from organization '{1}' with Id: '{2}'", user.Id, organization.Name, organization.Id).Write();
                        user.OrganizationIds.Remove(organization.Id);
                        _userRepository.Update(user);
                    }
                }

                Log.Info().Message("Deleting organization '{0}' with Id: '{1}'.", organization.Name, organization.Id).Write();
                _organizationRepository.Delete(organization);

                // TODO: Send notifications that the organization and projects have been updated.
            } catch (Exception ex) {
                ex.ToExceptionless().MarkAsCritical().AddTags("Remove Stale Accounts").AddObject(organization).Submit();
            }
        }
 public ActionResult DeleteOrganization(int id)
 {
     _Orgrep.Delete(id);
     return(RedirectToAction("Organizasyonlar"));
 }
 // DELETE
 public bool DeleteOrg(Organization org)
 {
     return(_or.Delete(org));
 }
Exemple #13
0
 public async Task <bool> Delete(Guid organizationId)
 {
     return(await OrganizationRepository.Delete(organizationId));
 }