Beispiel #1
0
        // transactional method
        public bool AcceptEmployee(int employeeId, int vacancyId, int responseId)
        {
            bool employeeDeactivated = false;
            bool vacancyDeactivated  = false;
            bool responseRemoved     = false;

            var employee = _employeeLogic.SelectById(employeeId);

            if (employee == null)
            {
                return(false);
            }

            var vacancy = _vacancyLogic.SelectById(vacancyId);

            if (vacancy == null)
            {
                return(false);
            }

            employeeDeactivated = _employeeLogic.Deactivate(employeeId);
            if (!employeeDeactivated)
            {
                return(false);
            }

            vacancyDeactivated = _vacancyLogic.Deactivate(vacancyId);
            if (!vacancyDeactivated)
            {
                _employeeLogic.Update(employee);
                return(false);
            }

            responseRemoved = _employeeLogic.DeleteVacancyResponse(responseId);

            if (!responseRemoved)
            {
                _employeeLogic.Update(employee);
                _vacancyLogic.Update(vacancy);
                return(false);
            }

            _employeeLogic.DeleteHiredVacancyResponses(employeeId, vacancyId);
            _vacancyLogic.DeleteHiredEmployeeResponses(employeeId, vacancyId);

            return(true);
        }
        public static void Deactivate(HttpRequestBase req, HttpResponseBase res)
        {
            var id     = int.Parse(req["id"]);
            var result = _vacancyLogic.Deactivate(id);

            if (result)
            {
                res.Write(JsonConvert.SerializeObject(new RequestResult("Success", "Vacancy has been deactivated.")));
            }
            else
            {
                res.Write(JsonConvert.SerializeObject(new RequestResult("Error", "Cannot deactivate vacancy.")));
            }
        }