public ResultOperation Update(sysBpmsDepartment Department, sysBpmsEmailAccount emailAccount)
        {
            ResultOperation resultOperation = new ResultOperation();

            try
            {
                this.BeginTransaction();
                if (resultOperation.IsSuccess)
                {
                    this.UnitOfWork.Repository <IDepartmentRepository>().Update(Department);
                    this.UnitOfWork.Save();

                    if (emailAccount != null)
                    {
                        emailAccount.ObjectID = Department.ID;
                        resultOperation       = new EmailAccountService(base.UnitOfWork).AddOverwrite(emailAccount);
                    }
                }
            }
            catch (Exception ex)
            {
                return(base.ExceptionHandler(ex));
            }
            base.FinalizeService(resultOperation);
            return(resultOperation);
        }
        public object PostAddEdit(DepartmentDTO departmentDTO)
        {
            using (DepartmentService departmentService = new DepartmentService())
            {
                sysBpmsDepartment department = departmentDTO.ID != Guid.Empty ? departmentService.GetInfo(departmentDTO.ID) : new sysBpmsDepartment();
                department.Update(departmentDTO.DepartmentID, departmentDTO.Name);

                sysBpmsEmailAccount emailAccount = new sysBpmsEmailAccount();

                ResultOperation resultOperation = emailAccount.Update((int)sysBpmsEmailAccount.e_ObjectTypeLU.Department, department.ID, departmentDTO.SMTP, departmentDTO.Port, departmentDTO.MailPassword, departmentDTO.WorkEmail);
                if (!resultOperation.IsSuccess)
                {
                    return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                }
                if (departmentDTO.ID != Guid.Empty)
                {
                    resultOperation = departmentService.Update(department, emailAccount);
                }
                else
                {
                    resultOperation = departmentService.Add(department, emailAccount);
                }

                if (resultOperation.IsSuccess)
                {
                    return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success));
                }
                else
                {
                    return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                }
            }
        }
 private void GetListHierarchy(sysBpmsDepartment childDepartment, List <Guid> Hierarchy)
 {
     Hierarchy.Add(childDepartment.ID);
     foreach (var item in this.Context.sysBpmsDepartments.Where(c => c.ID == childDepartment.DepartmentID))
     {
         this.GetListHierarchy(item, Hierarchy);
     }
 }
        public void Delete(Guid DepartmentId)
        {
            sysBpmsDepartment Department = this.Context.sysBpmsDepartments.FirstOrDefault(d => d.ID == DepartmentId);

            if (Department != null)
            {
                this.Context.sysBpmsDepartments.Remove(Department);
            }
        }
Beispiel #5
0
 public DepartmentDTO(sysBpmsDepartment department, sysBpmsEmailAccount emailAccount = null)
 {
     if (department != null)
     {
         this.ID           = department.ID;
         this.DepartmentID = department.DepartmentID;
         this.Name         = department.Name;
         this.IsActive     = department.IsActive;
         this.SMTP         = emailAccount?.SMTP;
         this.Port         = emailAccount?.Port;
         this.MailPassword = emailAccount?.MailPassword;
         this.WorkEmail    = emailAccount?.Email;
     }
 }
 private void FillTree(sysBpmsDepartment department, List <TreeViewModel> Items, List <sysBpmsDepartment> departments, Guid?SelectedID)
 {
     Items.Add(new TreeViewModel()
     {
         id    = department.ID.ToString(),
         text  = department.Name,
         icon  = departments.Any(d => d.DepartmentID == department.ID) ? "fa fa-folder text-primary" : "fa fa-file  text-primary",
         state = SelectedID.HasValue && department.ID == SelectedID ? new TreeNodeStateModel()
         {
             selected = true
         } : null
     });
     foreach (sysBpmsDepartment item in departments.Where(d => d.DepartmentID == department.ID))
     {
         this.FillTree(item, Items.LastOrDefault().children, departments, SelectedID);
     }
 }
        public object Delete(Guid ID)
        {
            using (DepartmentService departmentService = new DepartmentService())
            {
                sysBpmsDepartment department = departmentService.GetInfo(ID);
                department.IsActive = false;
                ResultOperation resultOperation = departmentService.Update(department, null);

                if (resultOperation.IsSuccess)
                {
                    return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success));
                }
                else
                {
                    return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                }
            }
        }
        public ResultOperation Delete(Guid departmentId)
        {
            ResultOperation resultOperation = new ResultOperation();

            try
            {
                sysBpmsDepartment department = this.GetInfo(departmentId);
                if (department.DepartmentID.HasValue)
                {
                    resultOperation.AddError("This Organization has children, so delete the children first.");
                }
                if (resultOperation.IsSuccess)
                {
                    DepartmentMemberService      departmentMemberService      = new DepartmentMemberService(base.UnitOfWork);
                    ApplicationPageAccessService applicationPageAccessService = new ApplicationPageAccessService(base.UnitOfWork);
                    var members  = departmentMemberService.GetList(departmentId, null, null);
                    var accesses = applicationPageAccessService.GetList(departmentId);
                    this.BeginTransaction();

                    foreach (var item in members)
                    {
                        departmentMemberService.Delete(item.ID);
                    }
                    foreach (var item in accesses)
                    {
                        applicationPageAccessService.Delete(item.ID);
                    }
                    this.UnitOfWork.Repository <IDepartmentRepository>().Delete(departmentId);
                    this.UnitOfWork.Save();
                }
            }
            catch (Exception ex)
            {
                return(base.ExceptionHandler(ex));
            }
            base.FinalizeService(resultOperation);

            return(resultOperation);
        }
 public void Update(sysBpmsDepartment department)
 {
     this.Context.Entry(department).State = EntityState.Modified;
 }
 public void Add(sysBpmsDepartment Department)
 {
     Department.ID = Guid.NewGuid();
     this.Context.sysBpmsDepartments.Add(Department);
 }