public ActionResult Delete(ulong id)
        {
            DBQuery dbq = new DBQuery();

            VacationRequest vr = dbq.SelectVacationRequest(id);
            int netWorkingDays = vr.getNetVacationDays();
            int remainingVacationDays = dbq.SelectRemainingVacationDays(vr.getEmployeeID());
            Boolean update = dbq.UpdateRemainingVacationDays(vr.getEmployeeID(), netWorkingDays + remainingVacationDays);
            if (update)
            {
                Boolean result = dbq.DeleteVacationRequest(id);
                if (result)
                {
                    ErrorState.ErrorStateInstance.setError(ErrorState.DATABASE_ERROR);
                    TempData["success"] = "Der Urlaubsantrag wurde erfolgreich gelöscht";
                }
                else
                {
                    ErrorState.ErrorStateInstance.setError(ErrorState.DATABASE_ERROR);
                    //TempData["error"] = "Die Änderung konnte nicht in die Datenbank übernommen werden!";
                }
            }
            else
            {
                ErrorState.ErrorStateInstance.setError(ErrorState.DATABASE_ERROR);
                //TempData["error"] = "Die Änderung konnte nicht in die Datenbank übernommen werden!";
            }

            int lastError = ErrorState.ErrorStateInstance.getLastError();
            if (lastError != ErrorState.OK)
            {
                TempData["error"] = "Der Urlaubsantrag konnte nicht gelöscht werden. Grund: " + ErrorState.ErrorStateInstance.getErrorMessage(lastError);
            }

            return RedirectToAction("All");
        }
 private Boolean RestoreVacationDaysInEmployeeVacationEntitlement(VacationRequest vacationRequest)
 {
     Boolean result = false;
     DBQuery dbq = new DBQuery();
     int netWorkingDays = vacationRequest.getNetVacationDays();
     int remainingVacationDays = dbq.SelectRemainingVacationDays(vacationRequest.getEmployeeID());
     result = dbq.UpdateRemainingVacationDays(vacationRequest.getEmployeeID(), netWorkingDays + remainingVacationDays);
     return result;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 1. writes an information email
        /// 2. writes vacation request in the database
        /// </summary>
        /// <returns>Boolean status if the insert into database was successful</returns>
        private Boolean SendDataToDB()
        {
            Boolean result = false;
            DBQuery dbq = new DBQuery();
            result = dbq.InsertNewVacationRequest(this);

            if (result)
            {
                int remainingVacationDays = dbq.SelectRemainingVacationDays(_employeeID) - this._netVacationDays;
                result = dbq.UpdateRemainingVacationDays(_employeeID, remainingVacationDays);
            }
            if (!result)
            {
                ErrorState.ErrorStateInstance.setError(ErrorState.DATABASE_ERROR);
            }
            return result;
        }