Exemple #1
0
        public ActionResult EditPost(BandModel m, IEnumerable <string> genres, Guid bandId)
        {
            var model = DataRepository.GetBand(bandId);

            if (ModelState.IsValid)
            {
                var oldUrl = model.UrlName;
                var newUrl = EntityNameHelper.CreateUrl(m.Name);

                m.UrlName = newUrl;
                m.BandId  = model.BandId;

                var selectedGenres = genres.Where(g => g != "false").Select(g => new Guid(g));

                DataRepository.UpdateBand(m);
                DataRepository.UpdateBandGenres(m.BandId, selectedGenres);
                DataRepository.AddFeedItem("{0} has updated their band profile.", 2, model.BandId);

                // notification
                Notifications.SendBandNotifications(NotificationType.NotifyBandProfileUpdate, model.BandId, new BandMessageData {
                    Band = model.Name, Link = model.UrlName
                });
            }

            return(JsonValidationResult(ModelState));
        }
        public ActionResult Edit(int id, BandModel band)
        {
            bands[id - 1] = band;

            Session["bands"] = bands;
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public ActionResult CreateBand(string bandName)
        {
            if (!String.IsNullOrWhiteSpace(bandName))
            {
                var band = DataRepository.GetBand(bandName, false);

                if (band == null)
                {
                    var bandUrl = EntityNameHelper.CreateUrl(bandName);

                    var       guid    = Guid.NewGuid();
                    BandModel newBand = new BandModel()
                    {
                        BandId = guid, UrlName = bandUrl, Name = bandName, Date = DateTime.Now
                    };

                    DataRepository.CreateBand(newBand, loggedUserGuid);

                    DataRepository.AddFeedItem("{0} has created their band profile!", 2, guid);

                    return(RedirectToRoute("MyBands", new { action = "edit", bandUrl = bandUrl }));
                }
                else
                {
                    ModelState.AddModelError("BandExists", "This band already exists.");
                    return(View("Join"));
                }
            }

            return(RedirectToRoute("join"));
        }
        public ActionResult Delete(int id)
        {
            GetBands();
            BandModel band = bands.FirstOrDefault(b => b.Id == id);

            return(View(band));
        }
Exemple #5
0
        private void buttonInsertBand_Click(object sender, EventArgs e)
        {
            if (textBoxBandName.Text == "" || textBoxDescription.Text == "")
            {
                MessageBox.Show("Wrong input!");
                return;
            }

            IBandsRepository bandsRep = new BandsRepository();

            BandModel toPost = new BandModel();

            toPost.BandName          = textBoxBandName.Text;
            toPost.DiscriptionOfType = textBoxDescription.Text;

            bool flag = bandsRep.AddBand(toPost);

            if (flag)
            {
                MessageBox.Show("Posted!");
            }
            else
            {
                MessageBox.Show("Error!");
            }

            textBoxBandName.Text    = "";
            textBoxDescription.Text = "";
        }
        public ActionResult Delete(int id, BandModel band)
        {
            GetBands();

            //Delete one by adding all the other ones to the bands.
            var newbands = bands.Where(b => b.Id != id);

            bands            = newbands.ToArray();
            Session["bands"] = bands;
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(BandModel band)
        {
            // add the new band here
            Array.Resize(ref bands, bands.Length + 1);

            band.Id = bands.Length;
            bands[bands.Length - 1] = band;

            Session["bands"] = bands;

            return(RedirectToAction("Index"));
        }
Exemple #8
0
        public static async Task <BandModel> LoadBandInformation()
        {
            string url = "http://localhost:11727/api/Bands/BandDetails/1";

            using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(url))
            {
                if (response.IsSuccessStatusCode)
                {
                    BandModel result = await response.Content.ReadAsAsync <BandModel>();

                    return(result);
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }
 public IActionResult AddBand([Bind("id,bandName,musicGenre")] BandModel newBand)
 {
     // if values passed in body of request meet validation annotations set in model
     if (ModelState.IsValid)
     {
         // add new band from body of request to data set
         _context.Add(newBand);
         // save changes to database (added record)
         _context.SaveChanges();
         // retrun confirmation message
         return(Content($"Addd Band {newBand.bandName}"));
     }
     else
     // if values passed in body of request DOES NOT meet validation annotations set in model
     {
         // return errors from method
         return(Content(DisplayString(ModelState)));
     }
 }
        public IActionResult AddAlbum([Bind("id,albumTitle,albumDesc,albumRating")] AlbumModel newAlbum, int bandID)
        {
            // find matching band based on bandID passed into body of request with access to the list of albums
            BandModel matchingBand = _context.bands.Include(band => band.albums).FirstOrDefault(band => band.id == bandID);

            // if values passed in body of request meet validation annotations set in model
            if (ModelState.IsValid)
            {
                // add new album from body of request to the data set
                _context.albums.Add(newAlbum);
                // add album to matching band in database
                matchingBand.albums.Add(newAlbum);
                // save changes to database (added record)
                _context.SaveChanges();
                // retrun confirmation message
                return(Content($"Add Album {newAlbum.albumTitle}"));
            }
            else
            // if values passed in body of request DOES NOT meet validation annotations set in model
            {
                // return errors from method
                return(Content(DisplayString(ModelState)));
            }
        }
Exemple #11
0
 public void Edit(BandModel model)
 {
     var record = _session.Single<Band>(x=>x.Id == model.Id);
     record.Update(model);
     _session.CommitChanges();
 }
Exemple #12
0
 public void Delete(BandModel model)
 {
     _session.Delete(model);
 }
Exemple #13
0
 public void Add(BandModel model)
 {
     _session.Add(model);
 }
        public ActionResult Create()
        {
            BandModel newband = new BandModel();

            return(View(newband));
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            Finish.IsEnabled         = true;
            WorkoutDetails.IsEnabled = true;

            var workoutId = WorkoutParams.workoutId;

            if (WorkoutParams.resetTimer == true)
            {
                App.workoutTimer          = new DispatcherTimer();
                App.workoutTimer.Interval = new TimeSpan(0, 0, 1);
                App.startTime             = DateTimeOffset.Now;
                App.workoutTimer.Start();
                CaloriesModel.startCalories = -1;
                CaloriesModel.calories      = 0;
                HeartRateModel.count        = 0;
                HeartRateModel.sum          = 0;
                HeartRateModel.peak         = 0;
                WorkoutParams.resetTimer    = false;
            }

            App.workoutTimer.Tick += dispatcherTimer_Tick;

            if (WorkoutParams.startNewWorkout || currentWorkout == null)
            {
                currentWorkout = await App.DefaultWorkoutsTable.LookupAsync(workoutId);

                m_nextExrciseIndex = 0;

                WorkoutParams.startNewWorkout = false;
            }
            if (WorkoutParams.isFinishedExercise)
            {
                m_nextExrciseIndex++;
                ExerciseParams.startNewExercise  = true;
                WorkoutParams.isFinishedExercise = false;
            }

            ExersiceIds = currentWorkout.ExercisesIds.Split(';').ToList();

            if (m_nextExrciseIndex >= ExersiceIds.Count())
            {
                StartExercise.IsEnabled  = false;
                StartExercise.Visibility = Visibility.Collapsed;
                NextEx.Text     = "Done";
                NextEx.FontSize = 30;
            }
            else
            {
                StartExercise.IsEnabled  = true;
                StartExercise.Visibility = Visibility.Visible;
                NextEx.FontSize          = 20;
                var fireAndForget = calculateNextExName(m_nextExrciseIndex);
            }

            // Calories
            await BandModel.InitAsync();

            _caloriesModel.Init();
            _caloriesModel.Changed += _caloriesModel_Changed;
            _caloriesModel.Start();
        }