public IActionResult Delete(EmployeeDeleteModel employee)
        {
            EmployeeBusiness employeeBusiness = new EmployeeBusiness();
            var result = employeeBusiness.Delete(employee);

            return(Ok(result));
        }
Exemplo n.º 2
0
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                TempData["Msg"]   = "Please select an employee before selecting delete.";
                TempData["Show"]  = true;
                TempData["color"] = "alert-warning";
                return(RedirectToAction("Index"));
            }

            var viewModel = new EmployeeDeleteModel();

            viewModel.registered_person = db.Registered_Person.Find(id);
            viewModel.person_role       = db.Person_Role.Where(x => x.Person_ID == id);
            viewModel.trainer_topic     = db.Trainer_Topic
                                          .Where(x => x.Person_ID == id)
                                          .Include(pr => pr.Topic).ToList();

            TempData["Check"] = false;
            if (viewModel.trainer_topic.Any())
            {
                TempData["Check"] = true;
            }

            viewModel.trainer_topic = db.Trainer_Topic
                                      .Where(x => x.Person_ID == id)
                                      .Include(pr => pr.Topic).ToList();

            if (db.Person_Role.Where(x => x.Person_ID == id).Where(x => x.Role_ID == 5).Any())
            {
                ViewBag.ErrorMsg     = "Administrators cannot be deleted.";
                TempData["Disabled"] = "Disabled";
                return(View(viewModel));
            }
            if (db.Person_Questionnaire.Any(x => x.Person_ID == id))
            {
                ViewBag.ErrorMsg     = "Employee cannot be deleted because they have been active on the system (relating to questionnaires).";
                TempData["Disabled"] = "Disabled";
                return(View(viewModel));
            }
            if (db.Person_Questionnaire_Result.Any(x => x.Person_ID == id))
            {
                ViewBag.ErrorMsg     = "Employee cannot be deleted because they have been active on the system (relating to questionnaire results).";
                TempData["Disabled"] = "Disabled";
                return(View(viewModel));
            }
            if (db.Person_Session_Log.Any(x => x.Person_ID == id))
            {
                ViewBag.ErrorMsg     = "Employee cannot be deleted because they have been active on the system (relating to session log).";
                TempData["Disabled"] = "Disabled";
                return(View(viewModel));
            }

            ViewBag.ErrorMsg     = "Are you sure you want to delete?";
            TempData["Show"]     = false;
            TempData["Disabled"] = "";

            return(View(viewModel));
        }
        public async Task <ActionResult> Delete(EmployeeDeleteModel Employee)
        {
            Employee.DeletedBy = _userSessionHelper.GetUserSession().UserName;
            string apiUrl = _appUrlHelper.GetApiUrl(ApiUrlPath.EMPLOYEE_DELETE);
            var    result = await HttpUtilities.PostAsyncApi <ReturnResult <Employee> >(apiUrl, JsonConvert.SerializeObject(Employee));

            return(Json(result));
        }
Exemplo n.º 4
0
        public ReturnResult <Employee> Delete(EmployeeDeleteModel employee)
        {
            DbProvider dbProvider = new DbProvider();
            string     outCode    = String.Empty;
            string     outMessage = String.Empty;
            StoredProcedureConfigs <Employee> storedProcedureConfigs = new StoredProcedureConfigs <Employee>();

            dbProvider.SetQuery(storedProcedureConfigs._DELETE_SINGLE_STORED_PROCEDURE, CommandType.StoredProcedure)
            .SetParameter("Id", SqlDbType.Int, employee.Id, ParameterDirection.Input)
            .SetParameter("UserName", SqlDbType.NVarChar, employee.DeletedBy, ParameterDirection.Input)
            .SetParameter("ERROR_CODE", SqlDbType.NVarChar, DBNull.Value, 100, ParameterDirection.Output)
            .SetParameter("ERROR_MESSAGE", SqlDbType.NVarChar, DBNull.Value, 400, ParameterDirection.Output)
            .ExcuteNonQuery()
            .Complete();
            dbProvider.GetOutValue("ERROR_CODE", out outCode)
            .GetOutValue("ERROR_MESSAGE", out outMessage);
            return(new ReturnResult <Employee>()
            {
                ErrorCode = outCode,
                ErrorMessage = outMessage,
            });
        }
Exemplo n.º 5
0
 public ReturnResult <Employee> Delete(EmployeeDeleteModel employee)
 {
     return(EmployeeDAL.Delete(employee));
 }