public JsonResult RemoveFromFavouriteListJSON(int id) { var currentUser = idb.Users.Find(User.Identity.GetUserId()); Member _Member = repository.GetMemberByUserID(currentUser.Id); Group group = repository.GetGroupByID(id); CultureHelper _CultureHelper = new CultureHelper(repository); TimeZoneInfo TZone = _CultureHelper.GetTimeZoneInfo(currentUser.LocationID); repository.RemoveMember(currentUser.Id, group); repository.Save(); Task T = new Task(() => { Ride _Ride = repository.GetHomePageRideByUserID(currentUser.Id); if (_Ride.Group.id == id) { repository.DeleteHomePageRide(currentUser.Id); } }); T.Start(); Task E = new Task(() => { CloudStorageAccount storageAccount = CloudStorageAccount.Parse( ConfigurationManager.ConnectionStrings["AzureJobsData"].ConnectionString); // Create the queue client. CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); // Retrieve a reference to a queue. CloudQueue queue = queueClient.GetQueueReference("updatehomepage"); // Create the queue if it doesn't already exist. queue.CreateIfNotExists(); // Create a message and add it to the queue. CloudQueueMessage message = new CloudQueueMessage("Hello, World"); queue.AddMessage(message); }); E.Start(); return(Json(new { success = true, message = "Emails Sent", GroupId = 2 }, JsonRequestBehavior.AllowGet)); }
public ActionResult RemoveFromFavouriteList(int id) { var currentUser = idb.Users.Find(User.Identity.GetUserId()); Member _Member = repository.GetMemberByUserID(currentUser.Id); Group group = repository.GetGroupByID(id); CultureHelper _CultureHelper = new CultureHelper(repository); TimeZoneInfo TZone = _CultureHelper.GetTimeZoneInfo(currentUser.LocationID); repository.RemoveMember(currentUser.Id, group); repository.Save(); Task T = new Task(() => { Ride _Ride = repository.GetHomePageRideByUserID(currentUser.Id); if (_Ride != null) { if (_Ride.Group.id == id) { repository.DeleteHomePageRide(currentUser.Id); } } }); T.Start(); Task E = new Task(() => { CloudStorageAccount storageAccount = CloudStorageAccount.Parse( ConfigurationManager.ConnectionStrings["AzureJobsData"].ConnectionString); // Create the queue client. CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); // Retrieve a reference to a queue. CloudQueue queue = queueClient.GetQueueReference("updatehomepage"); // Create the queue if it doesn't already exist. queue.CreateIfNotExists(); // Create a message and add it to the queue. CloudQueueMessage message = new CloudQueueMessage("Hello, World"); queue.AddMessage(message); }); E.Start(); this.ShowMessage(MessageType.Success, "Removed from favourites", true, MessagePosition.TopCentre, false); return(RedirectToAction("Index", "Group")); }