예제 #1
0
        public string UpdateFish(FishTO fishTO, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var guid   = new Guid(token);
                var fishDB = (from fish in db.Fish
                              where fish.id == fishTO.id
                              select fish).FirstOrDefault();
                if (fishDB == null)
                {
                    return(null);
                }

                db.Fish.Attach(fishDB);

                fishDB.name    = fishTO.name;
                fishDB.species = fishTO.species;
                fishDB.length  = fishTO.length;
                fishDB.weight  = fishTO.weight;
                fishDB.notes   = fishTO.notes;
                string date = fishTO.caughtDate + " " + fishTO.caughtTime;
                fishDB.caughtDate = DateTime.ParseExact(fishTO.caughtDate, "yyyy-MM-dd HH:mm:ss tt", CultureInfo.InvariantCulture);

                db.SaveChanges();
            }
            return(null);
        }
예제 #2
0
        public void Put([FromBody] FishTO fishTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var fishDB = (from fish in db.Fish
                              where fish.id == fishTO.id
                              select fish).FirstOrDefault();

                fishDB.name    = fishTO.name;
                fishDB.weight  = fishTO.weight;
                fishDB.notes   = fishTO.notes;
                fishDB.length  = fishTO.length;
                fishDB.tripId  = fishTO.tripId;
                fishDB.species = fishTO.species;

                fishDB.girth        = fishTO.girth;
                fishDB.spot         = fishTO.spot;
                fishDB.presentation = fishTO.presentation;
                fishDB.depth        = fishTO.depth;
                fishDB.clarity      = fishTO.clarity;
                fishDB.temperature  = fishTO.temperature;

                fishDB.caughtDate = parseDateTimeExactFromString(fishTO.caughtDate);
                db.SaveChanges();
            }
        }
예제 #3
0
        public string UpdateTrip(TripTO tripTO, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var guid   = new Guid(token);
                var tripDB = (from trip in db.Trips
                              join user in db.Users
                              on trip.userId.Value
                              equals user.id
                              where user.token == guid &&
                              trip.id == tripTO.id
                              select trip).FirstOrDefault();
                if (tripDB == null)
                {
                    return(null);
                }

                tripDB.name      = tripTO.name;
                tripDB.notes     = tripTO.notes;
                tripDB.startDate = parseDateTimeExactFromString(tripTO.startDate);
                tripDB.endDate   = parseDateTimeExactFromString(tripTO.endDate);
                db.SaveChanges();
            }
            return(tripTO.name);
        }
예제 #4
0
 public string CreateUser(UserTO user)
 {
     using (var db = new Fish360Project.f360Entities())
     {
         Users newUser = new Users();
         newUser.username = user.username;
         newUser.password = user.password;
         db.Users.Add(newUser);
         db.SaveChanges();
     }
     return "success";
 }
예제 #5
0
 public string CreateUser(UserTO user)
 {
     using (var db = new Fish360Project.f360Entities())
     {
         Users newUser = new Users();
         newUser.username = user.username;
         newUser.password = user.password;
         db.Users.Add(newUser);
         db.SaveChanges();
     }
     return("success");
 }
예제 #6
0
        public void Register([FromBody] UserTO userTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                Users newUser = new Users();
                newUser.username = userTO.username;
                newUser.password = userTO.password;
                newUser.token    = Guid.NewGuid();

                db.Users.Add(newUser);
                db.SaveChanges();
            }
        }
예제 #7
0
        public void Register([FromBody]UserTO userTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                Users newUser = new Users();
                newUser.username = userTO.username;
                newUser.password = userTO.password;
                newUser.token = Guid.NewGuid();

                db.Users.Add(newUser);
                db.SaveChanges();
            }
        }
예제 #8
0
        public void Post([FromBody] TripTO tripTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                Trips newTrip = new Trips();
                newTrip.name      = tripTO.name;
                newTrip.notes     = tripTO.notes;
                newTrip.startDate = DateTime.Parse(tripTO.startDate); //, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                newTrip.endDate   = DateTime.Parse(tripTO.endDate);   //, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                newTrip.userId    = tripTO.userId;

                db.Trips.Add(newTrip);
                db.SaveChanges();
            }
        }
예제 #9
0
        public void Put([FromBody] TripTO tripTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var tripDB = (from trip in db.Trips
                              where trip.id == tripTO.id
                              select trip).FirstOrDefault();

                tripDB.name      = tripTO.name;
                tripDB.notes     = tripTO.notes;
                tripDB.startDate = parseDateTimeExactFromString(tripTO.startDate);
                tripDB.endDate   = parseDateTimeExactFromString(tripTO.endDate);
                db.SaveChanges();
            }
        }
예제 #10
0
        public void Delete(int id)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var query = (from trip in db.Trips
                             where trip.id == id
                             select trip).FirstOrDefault();

                if (query != null)
                {
                    db.Trips.Attach(query);
                    db.Trips.Remove(query);
                    db.SaveChanges();
                }
            }
        }
예제 #11
0
        public void Delete(int id)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var query = (from trip in db.Trips
                             where trip.id == id
                             select trip).FirstOrDefault();

                if (query != null)
                {
                    db.Trips.Attach(query);
                    db.Trips.Remove(query);
                    db.SaveChanges();
                }
            }
        }
예제 #12
0
        public void Delete(int id)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var query = (from fish in db.Fish
                             where fish.id == id
                             select fish).FirstOrDefault();

                if (query != null)
                {
                    db.Fish.Attach(query);
                    db.Fish.Remove(query);
                    db.SaveChanges();
                }
            }
        }
예제 #13
0
        public void Delete(int id)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var query = (from fish in db.Fish
                             where fish.id == id
                             select fish).FirstOrDefault();

                if (query != null)
                {
                    db.Fish.Attach(query);
                    db.Fish.Remove(query);
                    db.SaveChanges();
                }
            }
        }
예제 #14
0
        public string CreateFish(FishTO fishTO, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                Fish fishDB = new Fish();
                fishDB.name = fishTO.name;
                fishDB.species = fishTO.species;
                fishDB.length = fishTO.length;
                fishDB.weight = fishTO.weight;
                fishDB.caughtDate = DateTime.ParseExact(fishTO.caughtDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                fishDB.tripId = fishTO.tripId;

                db.Fish.Add(fishDB);
                db.SaveChanges();
            }
            return null;
        }
예제 #15
0
        public string CreateTrip(TripTO tripTO, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                UserTO userTO = FindUserForToken(token);

                Trips newTrip = new Trips();
                newTrip.name = tripTO.name;
                newTrip.startDate = DateTime.ParseExact(tripTO.startDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                newTrip.endDate = DateTime.ParseExact(tripTO.endDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                newTrip.userId = userTO.id;

                db.Trips.Add(newTrip);
                db.SaveChanges();
            }
            return null;
        }
예제 #16
0
        public string DeleteFishForId(int fishId, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var guid = new Guid(token);
                var query = (from fish in db.Fish
                             where fish.id == fishId
                             select fish).FirstOrDefault();
                if (query == null)
                    return null;

                db.Fish.Attach(query);
                db.Fish.Remove(query);
                db.SaveChanges();
            }
            return null;
        }
예제 #17
0
        public string CreateTrip(TripTO tripTO, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                UserTO userTO = FindUserForToken(token);

                Trips newTrip = new Trips();
                newTrip.name      = tripTO.name;
                newTrip.notes     = tripTO.notes;
                newTrip.startDate = DateTime.ParseExact(tripTO.startDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                newTrip.endDate   = DateTime.ParseExact(tripTO.endDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                newTrip.userId    = userTO.id;

                db.Trips.Add(newTrip);
                db.SaveChanges();
            }
            return(null);
        }
예제 #18
0
        public string DeleteFishForId(int fishId, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var guid  = new Guid(token);
                var query = (from fish in db.Fish
                             where fish.id == fishId
                             select fish).FirstOrDefault();
                if (query == null)
                {
                    return(null);
                }

                db.Fish.Attach(query);
                db.Fish.Remove(query);
                db.SaveChanges();
            }
            return(null);
        }
예제 #19
0
        public string CreateFish(FishTO fishTO, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                Fish fishDB = new Fish();
                fishDB.name    = fishTO.name;
                fishDB.species = fishTO.species;
                fishDB.length  = fishTO.length;
                fishDB.weight  = fishTO.weight;
                fishDB.notes   = fishTO.notes;
                string date = fishTO.caughtDate + " " + fishTO.caughtTime;
                fishDB.caughtDate = DateTime.ParseExact(fishTO.caughtDate, "yyyy-MM-dd HH:mm:ss tt", CultureInfo.InvariantCulture);
                fishDB.tripId     = fishTO.tripId;

                db.Fish.Add(fishDB);
                db.SaveChanges();
            }
            return(null);
        }
예제 #20
0
        public string DeleteTripForId(int id, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var guid = new Guid(token);
                var query = (from trip in db.Trips
                             join user in db.Users
                             on trip.userId.Value
                             equals user.id
                             where user.token == guid
                             && trip.id == id
                             select trip).FirstOrDefault();
                if (query == null)
                    return null;

                db.Trips.Attach(query);
                db.Trips.Remove(query);
                db.SaveChanges();
            }
            return null;
        }
예제 #21
0
        public string DeleteTripForId(int id, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var guid  = new Guid(token);
                var query = (from trip in db.Trips
                             join user in db.Users
                             on trip.userId.Value
                             equals user.id
                             where user.token == guid &&
                             trip.id == id
                             select trip).FirstOrDefault();
                if (query == null)
                {
                    return(null);
                }

                db.Trips.Attach(query);
                db.Trips.Remove(query);
                db.SaveChanges();
            }
            return(null);
        }
예제 #22
0
        public string LoginUser(UserTO user)
        {
            string validation = ValidateUser(user);
            Guid guid;
            if (validation == "user validated")
            {
                using (var db = new Fish360Project.f360Entities())
                {
                    var users = (from t in db.Users
                                 where t.username == user.username
                                 && t.password == user.password
                                 select t).FirstOrDefault();

                    guid = Guid.NewGuid();

                    users.token = guid;

                    db.SaveChanges();
                }
                return guid.ToString();
            }
            return "unable to login";
        }
예제 #23
0
        public string LoginUser(UserTO user)
        {
            string validation = ValidateUser(user);
            Guid   guid;

            if (validation == "user validated")
            {
                using (var db = new Fish360Project.f360Entities())
                {
                    var users = (from t in db.Users
                                 where t.username == user.username &&
                                 t.password == user.password
                                 select t).FirstOrDefault();

                    guid = Guid.NewGuid();

                    users.token = guid;

                    db.SaveChanges();
                }
                return(guid.ToString());
            }
            return("unable to login");
        }
예제 #24
0
        public void Post([FromBody] FishTO fishTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                Fish newFish = new Fish();
                newFish.name       = fishTO.name;
                newFish.species    = fishTO.species;
                newFish.length     = fishTO.length;
                newFish.weight     = fishTO.weight;
                newFish.notes      = fishTO.notes;
                newFish.caughtDate = DateTime.Parse(fishTO.caughtDate);//, "yyyy-MM-dd HH:mm:ss tt", CultureInfo.InvariantCulture);
                newFish.tripId     = (int)fishTO.tripId;

                newFish.girth        = fishTO.girth;
                newFish.spot         = fishTO.spot;
                newFish.presentation = fishTO.presentation;
                newFish.depth        = fishTO.depth;
                newFish.clarity      = fishTO.clarity;
                newFish.temperature  = fishTO.temperature;

                db.Fish.Add(newFish);
                db.SaveChanges();
            }
        }
예제 #25
0
        public void Put([FromBody]FishTO fishTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var fishDB = (from fish in db.Fish
                              where fish.id == fishTO.id
                              select fish).FirstOrDefault();

                fishDB.name = fishTO.name;
                fishDB.weight = fishTO.weight;
                fishDB.notes = fishTO.notes;
                fishDB.length = fishTO.length;
                fishDB.tripId = fishTO.tripId;
                fishDB.species = fishTO.species;

                fishDB.girth = fishTO.girth;
                fishDB.spot = fishTO.spot;
                fishDB.presentation = fishTO.presentation;
                fishDB.depth = fishTO.depth;
                fishDB.clarity = fishTO.clarity;
                fishDB.temperature = fishTO.temperature;

                fishDB.caughtDate = parseDateTimeExactFromString(fishTO.caughtDate);
                db.SaveChanges();
            }
        }
예제 #26
0
        public void Put([FromBody]FishTO fishTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var fishDB = (from fish in db.Fish
                              where fish.id == fishTO.id
                              select fish).FirstOrDefault();

                fishDB.name = fishTO.name;
            //                fishDB.id = fishTO.id;
                fishDB.weight = fishTO.weight;
                fishDB.length = fishTO.length;
                fishDB.tripId = fishTO.tripId;
                fishDB.species = fishTO.species;
                fishDB.caughtDate = parseDateTimeExactFromString(fishTO.caughtDate);
                db.SaveChanges();
            }
        }
예제 #27
0
        public void Post([FromBody]FishTO fishTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                Fish newFish = new Fish();
                newFish.name = fishTO.name;
                newFish.species = fishTO.species;
                newFish.length = fishTO.length;
                newFish.weight = fishTO.weight;
                newFish.caughtDate = DateTime.ParseExact(fishTO.caughtDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                newFish.tripId = (int)fishTO.tripId;

                db.Fish.Add(newFish);
                db.SaveChanges();
            }
        }
예제 #28
0
        public void Put([FromBody]TripTO tripTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var tripDB = (from trip in db.Trips
                              where trip.id == tripTO.id
                              select trip).FirstOrDefault();

                tripDB.name = tripTO.name;
                tripDB.startDate = parseDateTimeExactFromString(tripTO.startDate);
                tripDB.endDate = parseDateTimeExactFromString(tripTO.endDate);
                db.SaveChanges();
            }
        }
예제 #29
0
        public void Post([FromBody]TripTO tripTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                Trips newTrip = new Trips();
                newTrip.name = tripTO.name;
                newTrip.startDate = DateTime.ParseExact(tripTO.startDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                newTrip.endDate = DateTime.ParseExact(tripTO.endDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                newTrip.userId = tripTO.userId;

                db.Trips.Add(newTrip);
                db.SaveChanges();
            }
        }
예제 #30
0
        public string UpdateFish(FishTO fishTO, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var guid = new Guid(token);
                var fishDB = (from fish in db.Fish
                             where fish.id == fishTO.id
                             select fish).FirstOrDefault();
                if (fishDB == null)
                    return null;

                db.Fish.Attach(fishDB);

                fishDB.name = fishTO.name;
                fishDB.species = fishTO.species;
                fishDB.length = fishTO.length;
                fishDB.weight = fishTO.weight;
                fishDB.notes = fishTO.notes;
                string date = fishTO.caughtDate + " " + fishTO.caughtTime;
                fishDB.caughtDate = DateTime.ParseExact(fishTO.caughtDate, "yyyy-MM-dd HH:mm:ss tt", CultureInfo.InvariantCulture);

                db.SaveChanges();
            }
            return null;
        }
예제 #31
0
        public string UpdateTrip(TripTO tripTO, string token)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                var guid = new Guid(token);
                var tripDB = (from trip in db.Trips
                             join user in db.Users
                             on trip.userId.Value
                             equals user.id
                             where user.token == guid
                             && trip.id == tripTO.id
                             select trip).FirstOrDefault();
                if (tripDB == null)
                    return null;

                tripDB.name = tripTO.name;
                tripDB.notes = tripTO.notes;
                tripDB.startDate = parseDateTimeExactFromString(tripTO.startDate);
                tripDB.endDate = parseDateTimeExactFromString(tripTO.endDate);
                db.SaveChanges();
            }
            return tripTO.name;
        }
예제 #32
0
        public void Post([FromBody]FishTO fishTO)
        {
            using (var db = new Fish360Project.f360Entities())
            {
                Fish newFish = new Fish();
                newFish.name = fishTO.name;
                newFish.species = fishTO.species;
                newFish.length = fishTO.length;
                newFish.weight = fishTO.weight;
                newFish.notes = fishTO.notes;
                newFish.caughtDate = DateTime.Parse(fishTO.caughtDate);//, "yyyy-MM-dd HH:mm:ss tt", CultureInfo.InvariantCulture);
                newFish.tripId = (int)fishTO.tripId;

                newFish.girth = fishTO.girth;
                newFish.spot = fishTO.spot;
                newFish.presentation = fishTO.presentation;
                newFish.depth = fishTO.depth;
                newFish.clarity = fishTO.clarity;
                newFish.temperature = fishTO.temperature;

                db.Fish.Add(newFish);
                db.SaveChanges();
            }
        }