コード例 #1
0
        public ActionResult Create([Bind(Include = "activityrecordid,activityrecorddate,activityrecordrating")] ActivityRecords activityRecords)
        {
            //******TODO: DON"T ADD IF A RECORD AT THAT DATE ALREADY EXISTS
            if (ModelState.IsValid)
            {
                //checking to see if a record already exists with this date
                ActivityRecords existingRecord = db.ActivityRecords.Where(record => record.activityrecorddate == activityRecords.activityrecorddate).FirstOrDefault();

                //if a record with that date already exists
                if (existingRecord != null)
                {
                    Debug.WriteLine("An activity record with the date you are trying to add already exists: " + existingRecord.ToString());
                    ViewBag.existingDate = existingRecord.activityrecorddate.ToLongDateString();
                    ViewBag.existingId   = existingRecord.activityrecordid;
                    //return to the view and indicate a record with that date already exists, and prompt if the user wants to update that existing record instead
                    return(View());
                }

                //else, a record with that date
                Debug.WriteLine("A record with the date you are trying to add does not yet exist. Adding it to the database...");
                db.ActivityRecords.Add(activityRecords);
                db.SaveChanges();
                return(RedirectToAction("Index", new { add = true }));
            }


            return(View(activityRecords));
        }
コード例 #2
0
        // GET: ActivityRecords/Delete/5
        public ActionResult Delete(int?id)
        {
            //check if the user is logged in (true if logged in)
            bool isLoggedIn = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
            //is admin is false by default
            bool isAdmin = false;

            //if the user is logged in, isAdmin = whether or not the user is an admin
            if (isLoggedIn)
            {
                //below custom column check from https://stackoverflow.com/questions/31864400/how-get-custom-field-in-aspnetusers-table
                isAdmin = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(User.Identity.GetUserId()).is_admin;
            }
            if (!isAdmin)
            {
                //redirect to login page if not a logged in admin
                //return RedirectToAction("Login", "AccountController");
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ActivityRecords activityRecords = db.ActivityRecords.Find(id);

            if (activityRecords == null)
            {
                return(HttpNotFound());
            }
            db.ActivityRecords.Remove(activityRecords);
            db.SaveChanges();
            return(RedirectToAction("Index", new { delete = true }));
        }
コード例 #3
0
        private async Task OnActivityRecordDeletedAsync(ActivityRecordDeletedEventArgs args)
        {
            var activityRecordItem = ActivityRecords.FirstOrDefault(activityRecordItem => activityRecordItem.ActivityRecord.Id == args.ActivityRecordId);

            ActivityRecords.Remove(activityRecordItem);
            await OnActivityRecordItemOrderChangedAsync();
        }
コード例 #4
0
        public ActionResult showDeleteInfo(int activityrecordsid)
        {
            Debug.WriteLine("Receiving activityrecordsid in the ajax call as " + activityrecordsid);
            //grabbing the activity records object
            ActivityRecords activityRecords = db.ActivityRecords.Find(activityrecordsid);

            //returns a partial view with the given galleryImage and prints it back to whichever div the jquery call indicated in the view
            //(in this case, it will be inside a modal window)
            return(PartialView("_ShowDeleteInfo", activityRecords));
        }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "activityrecordid,activityrecorddate,activityrecordrating")] ActivityRecords activityRecords)
 {
     if (ModelState.IsValid)
     {
         db.Entry(activityRecords).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", new { update = true }));
     }
     return(View(activityRecords));
 }
コード例 #6
0
        private async Task AddActivityRecordItemAsync(ActivityRecordForDayRecordPanel activityRecord)
        {
            var activityRecordItem = _dayRecordPanelActivityRecordItemGetter.GetFromActivityType(activityRecord.Activity.Type);

            activityRecordItem.OrderChanged += OnActivityRecordItemOrderChangedAsync;
            activityRecordItem.Deleted      += OnActivityRecordDeletedAsync;
            await activityRecordItem.InitializeAsync(activityRecord);

            ActivityRecords.Add(activityRecordItem);
        }
コード例 #7
0
 private async Task OnActivityRecordItemOrderChangedAsync()
 {
     ActivityRecords.Clear();
     await LoadActivityRecords(); // TODO to change
 }
コード例 #8
0
 private void GetNextRecord()
 {
     CurrentActivityRecord = ActivityRecords.OrderBy(r => r.StartTime).First();
 }