public ActionResult RemovePayment(int tourDateId) { TourDate tourDate = db.TourDates.Find(tourDateId); tourDate.FeeCollectedOn = null; db.SaveChanges(); TempData["infoMessage"] = String.Format("Payment removed from tour date on {0:MM/dd/yy}.", tourDate.EventDate); return(RedirectToAction("Details", "Tour", new { tourId = tourDate.ParentId })); }
public ActionResult Delete(int tourDateId) { TourDate tourDate = db.TourDates.Find(tourDateId); db.TourDates.Remove(tourDate); db.SaveChanges(); TempData["infoMessage"] = "Tour date deleted!"; return(RedirectToAction("Details", "Tour", new { tourId = tourDate.ParentId })); }
public ActionResult MarkAsPaid(int tourDateId, DateTime datePaid) { TourDate tourDate = db.TourDates.Find(tourDateId); tourDate.FeeCollectedOn = datePaid; db.SaveChanges(); TempData["infoMessage"] = String.Format("Tour date on {0:MM/dd/yy} has been marked as paid", tourDate.EventDate); return(RedirectToAction("Details", "Tour", new { tourId = tourDate.ParentId })); }
public ActionResult MarkAsPaid(int tourDateId) { TourDate tourDate = db.TourDates .Include(t => t.Venue) .Where(t => t.TourDateId == tourDateId) .FirstOrDefault(); return(View(tourDate)); }
public bool IsReminderDateValid() { if (ReminderDate != null && ReminderDate.Value != null) { bool result = (ReminderDate == DateTime.MinValue || ReminderDate > TourDate.AddMinutes(5) || ReminderDate < DateTime.Now.ToUniversalTime().AddMinutes(-5) || ReminderDate == null) ? false : true; return(result); } else { return(false); } }
public ActionResult Edit(int tourDateId, DateTime eventDate, double appearanceFee, int SetListId, int VenueId) { TourDate tourDate = db.TourDates.Find(tourDateId); tourDate.AppearanceFee = Convert.ToDouble(appearanceFee); tourDate.EventDate = eventDate; tourDate.SetListId = SetListId; tourDate.VenueId = VenueId; db.SaveChanges(); TempData["infoMessage"] = "Tour date modified!"; return(RedirectToAction("Details", "Tour", new { tourId = tourDate.ParentId })); }
public ActionResult Create(int tourId, int bandId, DateTime eventDate, double appearanceFee, int SetListId, int VenueId) { TourDate tourDate = new TourDate(); tourDate.AppearanceFee = Convert.ToDouble(appearanceFee); tourDate.BandId = bandId; tourDate.ParentId = tourId; tourDate.EventDate = eventDate; tourDate.SetListId = SetListId; tourDate.VenueId = VenueId; Tour tour = db.Tours .Include(t => t.TourDates) .Where(t => t.TourId == tourId) .FirstOrDefault(); tour.TourDates.Add(tourDate); db.TourDates.Add(tourDate); db.SaveChanges(); TempData["infoMessage"] = "Tour date created!"; return(RedirectToAction("Tours", "Band", new { bandId = bandId })); }
public void SendNotification() { MusikaEntities db = new MusikaEntities(); List <Users> lstUsers = new List <Users>(); string type = string.Empty; string message = string.Empty; GenericRepository <Users> _UsersRepo = new GenericRepository <Users>(_unitOfWork); GenericRepository <Artists> _ArtistRepo = new GenericRepository <Artists>(_unitOfWork); GenericRepository <UserSettings> _UserSettingsRepo = new GenericRepository <UserSettings>(_unitOfWork); GenericRepository <UserDevices> _UserDevicesRepo = new GenericRepository <UserDevices>(_unitOfWork); GenericRepository <TourDate> _TourDateRepo = new GenericRepository <TourDate>(_unitOfWork); List <Artists> lstArtists = new List <Artists>(); DateTime dt = GetMonday(DateTime.Now); lstArtists = _ArtistRepo.Repository.GetAll(u => u.RecordStatus == "Active").Where(t => t.CreatedDate >= dt).ToList(); string artists = string.Empty; artists += "Newly Added Artists : "; foreach (Artists str in lstArtists) { artists += str.ArtistName + ","; } string events = string.Empty; List <TourDate> lstEvents = new List <TourDate>(); lstEvents = _TourDateRepo.Repository.GetAll(u => u.RecordStatus == "Active").Where(t => t.CreatedDate >= dt).ToList(); events += "Newly Added Events : "; foreach (TourDate str in lstEvents) { events += str.EventName + ","; } string finalMessage = string.Empty; finalMessage += artists + "\n" + events; //Users entity; lstUsers = _UsersRepo.Repository.GetAll(u => u.RecordStatus == "Active"); if (lstUsers.Count > 0) { try { Users _UsersTo = null; UserSettings _UserSettings = null; TourDate _TourEntity = null; for (int i = 0; i < lstUsers.Count; i++) { _UsersTo = _UsersRepo.Repository.Get(p => p.UserID == lstUsers[i].UserID); //_UsersTo.UserLanguage _UserSettings = _UserSettingsRepo.Repository.Get(p => p.UserID == _UsersTo.UserID && p.SettingKey == EUserSettings.Musika.ToString()); type = lstUsers[i].DeviceType; PushNotifications pNoty = new PushNotifications(); var deviceList = _UserDevicesRepo.Repository.GetAll(x => x.UserId == lstUsers[i].UserID); //for multiple devices if (deviceList != null && deviceList.Count > 0 && _UserSettings.SettingValue == true && _UsersTo.RecordStatus == RecordStatus.Active.ToString() && _TourEntity != null) { bool updateCount = false; message = SetMessageLang(_UsersTo.UserLanguage, _TourEntity.Tour_Utcdate); foreach (var d in deviceList) { if (string.IsNullOrEmpty(d.DeviceToken)) { LogHelper.CreateLog2(message + " - Device Token Not found - ToUserID : " + lstUsers[i].UserID.ToString(), Musika.Library.Utilities.LogHelper.ErrorType.Notification); } if (d.DeviceType == "IOS" && !string.IsNullOrEmpty(d.DeviceToken)) { LogHelper.CreateLog2(message + " - IOS - ToUserID : " + lstUsers[i].UserID.ToString(), Musika.Library.Utilities.LogHelper.ErrorType.Notification); pNoty.SendNotification_IOS(d.DeviceToken, finalMessage, type); updateCount = true; } else if (d.DeviceType == "Android" && !string.IsNullOrEmpty(d.DeviceToken)) { LogHelper.CreateLog2(message + " - ANDROID - ToUserID : " + lstUsers[i].UserID.ToString(), Musika.Library.Utilities.LogHelper.ErrorType.Notification); pNoty.SendNotification_Android(d.DeviceToken, finalMessage, type); updateCount = true; } } if (updateCount) { _UserSettings.NotificationCount += 1; _UserSettingsRepo.Repository.Update(_UserSettings); } } // for single device if (deviceList.Count == 0 && _UserSettings.SettingValue == true && _UsersTo.RecordStatus == RecordStatus.Active.ToString() && _TourEntity != null) { message = SetMessageLang(_UsersTo.UserLanguage, _TourEntity.Tour_Utcdate); if (string.IsNullOrEmpty(_UsersTo.DeviceToken)) { LogHelper.CreateLog2(message + " - Device Token Not found - ToUserID : " + lstUsers[i].UserID.ToString(), Musika.Library.Utilities.LogHelper.ErrorType.Notification); } if (_UsersTo.DeviceType == "IOS" && !string.IsNullOrEmpty(_UsersTo.DeviceToken)) { LogHelper.CreateLog2(message + " - IOS - ToUserID : " + lstUsers[i].UserID.ToString() + " devicetoken= " + _UsersTo.DeviceToken, Musika.Library.Utilities.LogHelper.ErrorType.Notification); pNoty.SendNotification_IOS(_UsersTo.DeviceToken, message, type); _UserSettings.NotificationCount += 1; _UserSettingsRepo.Repository.Update(_UserSettings); } else if (_UsersTo.DeviceType == "Android" && !string.IsNullOrEmpty(_UsersTo.DeviceToken)) { LogHelper.CreateLog2(message + " - ANDROID - ToUserID : " + lstUsers[i].UserID.ToString(), Musika.Library.Utilities.LogHelper.ErrorType.Notification); pNoty.SendNotification_Android(_UsersTo.DeviceToken, message, type); _UserSettings.NotificationCount += 1; _UserSettingsRepo.Repository.Update(_UserSettings); } } } } catch (Exception ex) { } } }