private void dependency_OnChange(object sender, SqlNotificationEventArgs e) { CustomerHub.Show(); //if(e.Type == SqlNotificationType.Change) //{ // CustomerHub.Show(); //} }
public ActionResult Insert(t_empresa model) { madrigaldev_testEntities context = new madrigaldev_testEntities(); var added = context.t_empresa.Add(model); context.SaveChanges(); CustomerHub.BroadcastData(); return(View("Insert")); }
public static string GetCustomerHub(RestCommand command, int customerHubID) { CustomerHub customerHub = CustomerHubs.GetCustomerHub(command.LoginUser, customerHubID); if (customerHub.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } return(customerHub.GetXml("CustomerHub", true)); }
public ActionResult Delete(Customer customer) { using (var context = new CustomerContext()) { var custRecord = context.Customers.Find(customer.CustomerID); context.Customers.Remove(custRecord); context.SaveChanges(); } //Once the record is inserted , then notify all the subscribers (Clients) CustomerHub.NotifyCurrentCustomerInformationToAllClients(); return(RedirectToAction("Index")); }
void sqlDep_OnChange(object sender, SqlNotificationEventArgs e) { //or you can also check => if (e.Info == SqlNotificationInfo.Insert) , if you want notification only for inserted record if (e.Type == SqlNotificationType.Change) { SqlDependency sqlDep = sender as SqlDependency; sqlDep.OnChange -= sqlDep_OnChange; //from here we will send notification message to client var notificationHub = GlobalHost.ConnectionManager.GetHubContext <CustomerHub>(); notificationHub.Clients.All.notify("added"); CustomerHub.BroadcastData(); //re-register notification RegisterNotification(DateTime.Now); } }
public ActionResult Delete(int id) { int result = 0; try { object[] parameters = { id }; result = objCust.Delete(parameters); if (result == 1) { //Notify to all CustomerHub.BroadcastData(); } } catch { } return(View("Index")); }
public ActionResult Update(Customer model) { int result = 0; try { object[] parameters = { model.Id, model.CustName, model.CustEmail }; result = objCust.Update(parameters); if (result == 1) { //Notify to all CustomerHub.BroadcastData(); } } catch { } return(View("Index")); }
public ActionResult Insert(CustomerDTO model) { //int result = 0; //try //{ // if (ModelState.IsValid) // { // object[] parameters = { model.CustName, model.CustEmail }; // result = objCust.Insert(parameters); // if (result == 1) // { // //Notify to all // CustomerHub.BroadcastData(); // } // } //} //catch { } //return View("Index"); using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:56775/api/customer"); var postTask = client.PostAsJsonAsync <CustomerDTO>("customer", model); postTask.Wait(); var postResult = postTask.Result; if (postResult.IsSuccessStatusCode) { CustomerHub.BroadcastData(); } } ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator."); Customer cus = new Customer() { Id = model.Id, CustName = model.CustName, CustEmail = model.CustEmail }; return(View(cus)); }
public ActionResult Update(Customer customer) { using (var context = new CustomerContext()) { var custRecord = context.Customers.Find(customer.CustomerID); custRecord.CustomerName = customer.CustomerName; custRecord.EmailAdress = customer.EmailAdress; custRecord.MobileNumber = customer.MobileNumber; context.Customers.Add(custRecord); context.Entry(custRecord).State = EntityState.Modified; context.SaveChanges(); } //Once the record is inserted , then notify all the subscribers (Clients) CustomerHub.NotifyCurrentCustomerInformationToAllClients(); return(RedirectToAction("Index")); }
public ActionResult Insert(Customer model) { int result = 0; try { if (ModelState.IsValid) { object[] parameters = { model.CustName, model.CustEmail }; result = objCust.Insert(parameters); if (result == 1) { //Notify to all CustomerHub.BroadcastData(); } } } catch { } return(View("Index")); }
public ActionResult Insert(Customer customer) { if (ModelState.IsValid) { //Insert into Customer table using (var context = new CustomerContext()) { try { context.Customers.Add(customer); context.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } //Once the record is inserted , then notify all the subscribers (Clients) CustomerHub.NotifyCurrentCustomerInformationToAllClients(); return(RedirectToAction("Index")); }