public int SavePlace(BookmarkedPlace bookmarkedPlace) { try { if (_ctx.BookmarkedPlaces.Any(b => b.UserName == bookmarkedPlace.UserName && b.VenueID == bookmarkedPlace.VenueID)) { return(-1); } if (!_ctx.Venues.Any(b => b.VenueID == bookmarkedPlace.VenueID)) { var newVenue = new Venue() { Address = bookmarkedPlace.Address, Category = bookmarkedPlace.Category, Name = bookmarkedPlace.VenueName, VenueID = bookmarkedPlace.VenueID, Rating = bookmarkedPlace.Rating }; _ctx.Venues.Add(newVenue); } bookmarkedPlace.TS = DateTime.Now; _ctx.BookmarkedPlaces.Add(bookmarkedPlace); return(_ctx.SaveChanges()); } catch (Exception ex) { log.Error("SavePlace", ex); //Log exception here return(0); } }
public int SavePlace(BookmarkedPlace bookmarkedPlace) { try { if (_ctx.BookmarkedPlaces.Any(b => b.UserName == bookmarkedPlace.UserName && b.VenueID == bookmarkedPlace.VenueID)) { return(-1); } bookmarkedPlace.TS = DateTime.Now; _ctx.BookmarkedPlaces.Add(bookmarkedPlace); return(_ctx.SaveChanges()); } catch (Exception) { //Log exception here return(0); } }