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); }
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(); } }
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); }
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"; }
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"); }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } } }
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(); } } }
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; }
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; }
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; }
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); }
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); }
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); }
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; }
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); }
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"; }
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"); }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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; }
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; }
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(); } }