Exemple #1
0
        public async Task <IActionResult> DeleteConfirmed(long id)
        {
            //var employeeInfo = await _context.EmployeeInfos.FindAsync(id);
            //_context.EmployeeInfos.Remove(employeeInfo);
            //await _context.SaveChangesAsync();
            var employeeInfo = employeeInfoRepository.GetDeleteList(id);
            await employeeInfoRepository.Delete(employeeInfo);

            return(RedirectToAction(nameof(Index)));
        }
Exemple #2
0
        //public async Task<EmployeeInfo> UpdateEmployeeBasicProfile(string email, EmployeeUpdateRequest request)
        //{
        //    var aEmpInfo = await employeeInfoRepository.GetAEmployeeAsync(email);

        //    aEmpInfo.FirstName = request.FirstName;
        //    aEmpInfo.LastName = request.LastName;
        //    aEmpInfo.NationalID = request.NationalID;
        //    aEmpInfo.DateOfBirth = request.DateOfBirth;
        //    aEmpInfo.Gender = request.Gender;
        //    aEmpInfo.Email = request.Email;

        //    if (!string.IsNullOrWhiteSpace(request.Email))
        //    {
        //        var isEmailExistInOtherEmpInfo = await employeeInfoRepository.GetAAsync(
        //                                            emp => emp.Email == request.Email
        //                                            && emp.EmployeeID != aEmpInfo.EmployeeID);
        //        if (isEmailExistInOtherEmpInfo == null)
        //        {
        //            aEmpInfo.Email = request.Email;
        //        }
        //        else
        //        {
        //            throw new RapsAppException("Email already exist in another employees info.");
        //        }
        //    }

        //    if (!string.IsNullOrWhiteSpace(request.MobileNumber))
        //    {
        //        var isMobileNumberExistInOtherEmpInfo = await _empBasicInfoRepository.GetAAsync(
        //                                            emp => emp.MobileNumber == request.MobileNumber
        //                                            && emp.EmployeeID != aEmpInfo.EmployeeID);
        //        if (isMobileNumberExistInOtherEmpInfo == null)
        //        {
        //            aEmpInfo.MobileNumber = request.MobileNumber;
        //        }
        //        else
        //        {
        //            throw new RapsAppException("Mobile number already exist in another employees info.");
        //        }
        //    }

        //    if (!string.IsNullOrWhiteSpace(request.NID))
        //    {
        //        var isNIDExistInOtherEmpInfo = await _empBasicInfoRepository.GetAAsync(
        //                                            emp => emp.NID == request.NID
        //                                            && emp.EmployeeID != aEmpInfo.EmployeeID);
        //        if (isNIDExistInOtherEmpInfo == null)
        //        {
        //            aEmpInfo.NID = request.NID;
        //        }
        //        else
        //        {
        //            throw new RapsAppException("National ID already exist in another employees info.");
        //        }
        //    }

        //    _empBasicInfoRepository.UpdateAsync(aEmpInfo);
        //    // var a = await _empBasicInfoRepository.testUpdate(aEmpInfo);

        //    if (await _empBasicInfoRepository.ApplySaveChangesAsync())
        //    {
        //        return aEmpInfo;
        //    }
        //    throw new RapsAppException("somthing went worng");
        //}

        public async Task <EmployeeInfo> DeleteEmployee(string email)
        {
            var empInfo = await employeeInfoRepository.GetAAsync(e => e.Email == email);

            if (empInfo == null)
            {
                throw new ApiExceptions("Employee not found");
            }

            employeeInfoRepository.Delete(empInfo);

            if (await employeeInfoRepository.EntitySaveChangeAsync())
            {
                return(empInfo);
            }
            throw new ApiExceptions("somthing went worng");
        }
 public static void Delete(employee_info obj)
 {
     repository.Delete(obj);
 }