Example #1
0
        public bool Update(IGeekyObj geekyObject)
        {
            PracticeViewModel practice = (PracticeViewModel)geekyObject;

            if (practice == null)
            {
                throw new Exception("No practice found to update???");
            }

            var castedPractice = CastToDbModel(practice) as Practice;

            if (castedPractice == null)
            {
                return(false);
            }
            var dbPrac = _swimteamDb.Practices.FirstOrDefault(p => p.Id == practice.Id);

            if (dbPrac == null)
            {
                throw new Exception("No practice found to update???");
            }

            dbPrac.Begins          = castedPractice.Begins;
            dbPrac.Ends            = castedPractice.Ends;
            dbPrac.MaxParticipants = castedPractice.MaxParticipants;
            dbPrac.Description     = castedPractice.Description;

            _swimteamDb.Practices.Update(dbPrac);
            var recordCount = _swimteamDb.SaveChanges();

            return(recordCount > 0);
        }
Example #2
0
        public bool Delete(IGeekyObj geekyObjId)
        {
            var practice = _swimteamDb.Practices.Single(p => p.Id.Equals(geekyObjId.Id));

            if (practice == null)
            {
                throw new Exception("No practice found to delete???");
            }
            _swimteamDb.Practices.Remove(practice);
            var recordCount = _swimteamDb.SaveChanges();

            return(recordCount > 0);
        }
Example #3
0
        public bool Create(IGeekyObj geekyObject)
        {
            PracticeViewModel practiceVm = geekyObject as PracticeViewModel;

            if (practiceVm == null)
            {
                return(false);
            }

            var practiceDb = CastToDbModel(practiceVm) as Practice;

            _swimteamDb.Practices.Add(practiceDb);
            var recordCount = _swimteamDb.SaveChanges();

            return(recordCount > 0);
        }