public async Task <object> AddAttendance(Guid businessID, [FromBody] AttendanceModel attendanceModel)
        {
            var checkBusinessId = await commonLogic.CheckBusinessID(businessID);

            if (checkBusinessId)
            {
                var checkEmployeeId = await commonLogic.CheckEmployeeID(businessID, attendanceModel.EmployeeID);

                if (checkEmployeeId)
                {
                    var result = await attendanceLogic.AddAttendance(businessID, attendanceModel);

                    if (result)
                    {
                        return(attendanceValidation.AttendanceAddedSuccess());
                    }

                    return(attendanceValidation.AttendanceAdditionFailed());
                }

                return(commonValidation.EmployeeIdNotExists(attendanceModel.EmployeeID));
            }
            return(commonValidation.BusinessIdNotExists(businessID));
        }
Пример #2
0
        public async Task <Object> AddEmployeeSalary(Guid businessID, [FromBody] SalaryModel salaryModel)
        {
            var checkBusinessID = await _commonlogic.CheckBusinessID(businessID);  //check that this business is available

            if (checkBusinessID)
            {
                var checkEmployeeID = await _commonlogic.CheckEmployeeID(businessID, salaryModel.EmployeeID); //check that this employee id is available in above business

                if (checkEmployeeID)
                {
                    var checkIfSalaryIsAlreadyAssigned = await _salaryLogic.CheckIfEmployeeHasAlreaySaleryAssigned(businessID, salaryModel.EmployeeID); //checking if salery is already assigned to this employee

                    if (checkIfSalaryIsAlreadyAssigned)
                    {
                        return(_salaryValidation.SalaryAlreadyAssigned(salaryModel.EmployeeID));
                    }

                    //insertion starts here
                    var errors = _salaryValidation.ValidateSalaryData(salaryModel);
                    if (errors != null)
                    {
                        return(errors);
                    }
                    bool response = await _salaryLogic.AddEmployeeSalary(businessID, salaryModel);

                    if (response)
                    {
                        return(_salaryValidation.SalaryAddedSuccess());
                    }

                    return(_salaryValidation.SalaryAddedFailed());
                }
                return(_commonValidation.EmployeeIdNotExists(salaryModel.EmployeeID));
            }

            return(_commonValidation.BusinessIdNotExists(businessID));
        }