Exemplo n.º 1
0
        /// <summary>
        /// This method is used to delete the department
        /// </summary>
        /// <param name="id">Department Id</param>
        /// <returns>returns department details</returns>
        public async Task <Department> DeleteDepartmentAsync(int id)
        {
            var getDepartment = await _departmentRepository.GetDepartmentDetailsAsync(id);

            if (getDepartment == null)
            {
                return(null);
            }
            var getDesignationList = await _departmentDesignationRepository.GetDesignationList(id);

            if (getDesignationList != null)
            {
                foreach (var i in getDesignationList)
                {
                    await _designationService.DeleteDesignationAsync(i.DesignationId);
                }
            }
            using (var ts = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                getDepartment.IsDeleted = true;
                await _departmentRepository.SaveChangesAsync();

                await _departmentDesignationRepository.SaveChangesAsync();

                ts.Complete();
            }
            return(getDepartment);
        }
        public async Task <ActionResult <Designation> > DeleteDesignationAsync(int designationId)
        {
            var result = await _designationService.DeleteDesignationAsync(designationId);

            return(Ok(result));
        }