Пример #1
0
        //public bool EnterFishOld(string username, Models.FishModels.Fish fish)
        //{
        //    try
        //    {
        //        DateTime date = new DateTime();
        //        date = DateTime.Now;
        //        FishDB.EnterFish(999999,
        //            username, fish.strSpecies, fish.strLocationName, fish.decLengthInches, fish.decWeightLbs, fish.decWaterLevel, fish.decLatitude, fish.decLongitude);
        //        //todo fix this username =999999...not even sure wtf this is. probably from before I added userId to the user DB. Will need to get MY UserID (the int), from DB and
        //        // save to Session for use here and other places I want userID
        //        return true;
        //    }
        //    catch (Exception ex)
        //    {
        //        error.logError(ex.Message, ex.Source, ex.StackTrace, "Enter Fish", "DatabaseClass", "EnterFish", HttpContext.Current.User.Identity.Name, null);
        //        return false;
        //    }
        //}

        public bool EnterFish(Models.FishModels.Fish fish)
        {
            try
            {
                string Id = GetId();

                DateTime dtEntered = new DateTime();
                dtEntered = DateTime.Now;
                //DateTime dtCaught = //TODO: give user option to manually enter datetime caught
                //dateCaught

                FishDB.spEnterFish(Id, fish.FishID, fish.strSpecies, dtEntered, dtEntered, fish.decLengthInches, fish.decWeightLbs);
                //todo fix this username =999999...not even sure wtf this is. probably from before I added userId to the user DB. Will need to get MY UserID (the int), from DB and
                // save to Session for use here and other places I want userID
                //todo: fix dateCaught Parameter. Allow user to change that when entering a fish. It shouldnt always be set to DateEntered

                // add images
                foreach (FishModels.FishImage image in fish.images)
                {
                    // when you write the images to DB the first time, save them to the session.
                    // then when you get here and you have a fishID, come back and update them with fishID.

                    // you will need ot change spEnterFish so it returns the fishID
                }

                return(true);
            }
            catch (Exception ex)
            {
                error.logError(ex.Message, ex.Source, ex.StackTrace, "Enter Fish", "DatabaseClass", "EnterFish", HttpContext.Current.User.Identity.Name, null);
                return(false);
            }
        }
Пример #2
0
        public List <Models.FishModels.Fish> GetFishByUsername(string username)
        {
            try
            {
                List <Models.FishModels.Fish> fishlst = new List <Models.FishModels.Fish>();
                var lst = FishDB.spGetFishByUser(username).ToList();

                foreach (var a in lst)
                {
                    Models.FishModels.Fish f = new Models.FishModels.Fish();

                    f.strSpecies         = a.strSpecies;
                    f.strLocationName    = a.strLocationName;
                    f.dteDateTimeEntered = Convert.ToDateTime(a.dteTimeEntered);

                    f.decLengthInches = a.decLengthInches;
                    f.decWeightLbs    = a.decWeightLbs;

                    f.decWaterLevel = a.decWaterLevel;

                    f.decLatitude  = a.decLatitude;
                    f.decLongitude = a.decLongitude;

                    fishlst.Add(f);
                }

                return(fishlst);
            }
            catch (Exception ex)
            {
                error.logError(ex.Message, ex.Source, ex.StackTrace, "Enter Fish", "DatabaseClass", "getFishByUsername", HttpContext.Current.User.Identity.Name, null);
                return(null);
            }
        }