// notification type 1 - "new inquiry about tender notice" public ActionResult CreateType1Notification(String tenderID) { NotificationModel noti = new NotificationModel(); noti.NoticeId = int.Parse(tenderID); noti.Organization = DBContext.GetInstance().getOrganizationOfNotice(tenderID); DBContext.GetInstance().createNotificationType1(noti); // create db entry return Json(null, JsonRequestBehavior.AllowGet); // enable ajax request. }
public ActionResult CreateType3Notification(String tenderID,String bidder) { // notification type 2 - "congratulations, your bid is selected as winning bid" NotificationModel noti = new NotificationModel(); noti.NoticeId = int.Parse(tenderID); noti.User = bidder; DBContext.GetInstance().createNotificationType3(noti); return Json(null, JsonRequestBehavior.AllowGet); // enable ajax }
public ActionResult CreateType2Notification(String tenderID,String user) { // notification type 2 - "your inquiry is now answered" NotificationModel noti = new NotificationModel(); noti.NoticeId = int.Parse(tenderID); noti.User = user; DBContext.GetInstance().createNotificationType2(noti); return Json(null, JsonRequestBehavior.AllowGet); // enable ajax }
public List<NotificationModel> findNotificationsOfUser(string UserName) { DbConnection.Open(); MySqlCommand command = DbConnection.CreateCommand(); command.CommandText = "select * from notification WHERE user =@value order by date asc"; command.Parameters.AddWithValue("@value", UserName); MySqlDataReader reader = command.ExecuteReader(); List<NotificationModel> NotificationList = new List<NotificationModel>(); while (reader.Read()) { if (reader.GetBoolean("caught") == true) continue; NotificationModel noti = new NotificationModel(); noti.NotificationId = reader.GetInt32("notificationId"); noti.NotificationText = reader.GetString("notificationText"); NotificationList.Add(noti); } DbConnection.Close(); return NotificationList; }
public void createNotificationType3(NotificationModel notifi) { DbConnection.Open(); MySqlCommand command = DbConnection.CreateCommand(); command.CommandText = "INSERT INTO notification (type,caught,notificationtext,noticeid,date,user) values(@type,@caught,@notificationtext,@noticeid,@date,@user)"; command.Parameters.AddWithValue("@type", 3); command.Parameters.AddWithValue("@caught", false); command.Parameters.AddWithValue("@notificationtext", "Congratulations your bid selected as the winning bid for Tender ID " + notifi.NoticeId); command.Parameters.AddWithValue("@noticeid", notifi.NoticeId); command.Parameters.AddWithValue("@user", notifi.User); command.Parameters.AddWithValue("@date", DateTime.Now); command.ExecuteNonQuery(); DbConnection.Close(); }
public void createNotificationType2(NotificationModel notifi) { DbConnection.Open(); MySqlCommand command = DbConnection.CreateCommand(); command.CommandText = "INSERT INTO notification (type,caught,notificationtext,noticeid,date,user) values(@type,@caught,@notificationtext,@noticeid,@date,@user)"; command.Parameters.AddWithValue("@type", 2); command.Parameters.AddWithValue("@caught", false); command.Parameters.AddWithValue("@notificationtext", "Your inquery about Tender ID " + notifi.NoticeId+" is now answered"); command.Parameters.AddWithValue("@noticeid", notifi.NoticeId); command.Parameters.AddWithValue("@user", notifi.User); command.Parameters.AddWithValue("@date", DateTime.Now); command.ExecuteNonQuery(); DbConnection.Close(); }
public void createNotificationType1(NotificationModel notifi) { DbConnection.Open(); MySqlCommand command = DbConnection.CreateCommand(); command.CommandText = "INSERT INTO notification (type,caught,notificationtext,noticeid,date,organization) values(@type,@caught,@notificationtext,@noticeid,@date,@organization)"; command.Parameters.AddWithValue("@type",1); command.Parameters.AddWithValue("@caught", false); command.Parameters.AddWithValue("@notificationtext","New inquiry about one of your tender : Tender ID "+notifi.NoticeId); command.Parameters.AddWithValue("@noticeid",notifi.NoticeId); command.Parameters.AddWithValue("@organization",notifi.Organization); command.Parameters.AddWithValue("@date", DateTime.Now); command.ExecuteNonQuery(); DbConnection.Close(); }