public JsonResult reqId(string username) { // if (Session["IdEmployee"] == null) // return RedirectToAction("Login", "Home"); int idEmployee = (int)Session["IdEmployee"]; Requisition req = _requisitionDAO.CreateRequisition(idEmployee); //@Shutong: send notification here int IdHead = _employeeDAO.FindHeadIdByIdEmployee(idEmployee); int IdActingHead = _employeeDAO.FindActingHeadIdByIdEmployee(idEmployee); var hub = GlobalHost.ConnectionManager.GetHubContext <ChatHub>(); hub.Clients.All.receiveNotification(IdHead); EmailClass emailClass = new EmailClass(); string message = "Hi Department Head," + _employeeDAO.FindEmployeeById(idEmployee).Name + "has raised a stationery requisition: " + req.IdRequisition + " on " + req.RaiseDate + ". Please kindly approve or reject it."; _notificationChannelDAO.CreateNotificationsToIndividual(IdHead, (int)Session["IdEmployee"], message); emailClass.SendTo(_employeeDAO.FindEmployeeById(IdHead).Email, "SSIS System Email", message); if (IdActingHead != 0) { message = "Hi Department Acting Head," + _employeeDAO.FindEmployeeById(idEmployee).Name + "has raised a stationery requisition: " + req.IdRequisition + " on " + req.RaiseDate + ". Please kindly approve or reject it."; hub.Clients.All.receiveNotification(IdActingHead); _notificationChannelDAO.CreateNotificationsToIndividual(IdActingHead, (int)Session["IdEmployee"], message); emailClass.SendTo(_employeeDAO.FindEmployeeById(IdActingHead).Email, "SSIS System Email", message); } message = "Hi " + _employeeDAO.FindEmployeeById(idEmployee).Name + "you has raised a stationery requisition: " + req.IdRequisition + " on " + req.RaiseDate + ". Your Head/Acting Head will handle it in 5 working days."; hub.Clients.All.receiveNotification(idEmployee); _notificationChannelDAO.CreateNotificationsToIndividual(idEmployee, idEmployee, message); emailClass.SendTo(_employeeDAO.FindEmployeeById(idEmployee).Email, "SSIS System Email", message); //end of notification sending //replace with below /* using (SqlConnection conn = new SqlConnection(connectionString)) * { * conn.Open(); * * Random rand = new Random(); * int orderNum = rand.Next(10000000, 100000000); * * string sql = @"INSERT INTO Requisitions(IdStatusCurrent,RaiseDate,HeadRemark,ApprovedDate,WithdrawlDate,IdEmployee) * VALUES(1,GETDATE(),null,GETDATE(),GETDATE()," + idEmployee + ")"; * * SqlCommand cmdd = new SqlCommand(sql, conn); * * cmdd.ExecuteNonQuery(); * }*/ return(Json(new { result = "OK" })); }