Esempio n. 1
0
        [HttpPost("api/logout")] //?username={username}
        public IActionResult Logout(string username)
        {
            var ds = new Dataservice();

            ds.Logout(username);

            return(Ok());
        }
Esempio n. 2
0
        [HttpPost("api/signup/{username}/{password}")] //?username={username}&password={password}
        public IActionResult CreateUser(string username, string password)
        {
            var ds      = new Dataservice();
            var created = ds.CreateUser(username, password);

            if (!created)
            {
                return(Conflict());
            }
            return(Ok());
        }
Esempio n. 3
0
        public void UpdateLocation(int id, string name, string state, string GPS, bool coast, int fishId)
        {
            Location l = Dataservice.Locations.SingleOrDefault(c => c.Id == id);

            l.Name    = name;
            l.State   = state;
            l.GPS     = GPS;
            l.IsCoast = coast;
            l.FishId  = fishId;
            Dataservice.SubmitChanges();
        }
Esempio n. 4
0
        public IActionResult RemoveRating(string username, string id)
        {
            var  ds   = new Dataservice();
            bool done = ds.DeleteRating(username, id);

            if (!done)
            {
                return(NotFound());
            }

            return(Ok());
        }
Esempio n. 5
0
        public void UpdateBoat(int id, string name, string hullNum, int powerId, int memberId, int size, bool deleted)
        {
            Boat b = Dataservice.Boats.SingleOrDefault(c => c.Id == id);

            b.Name       = name;
            b.HullNumber = hullNum;
            b.PowerId    = powerId;
            b.MemberId   = memberId;
            b.Size       = size;
            b.IsDeleted  = deleted;
            Dataservice.SubmitChanges();
        }
Esempio n. 6
0
        public void AddBoat(string name, string hullNum, int powerId, int memberId, int size)
        {
            Boat b = new Boat();

            b.Name       = name;
            b.HullNumber = hullNum;
            b.PowerId    = powerId;
            b.MemberId   = memberId;
            b.Size       = size;
            Dataservice.Boats.InsertOnSubmit(b);
            Dataservice.SubmitChanges();
        }
Esempio n. 7
0
        public void AddLocation(string name, string state, string GPS, bool coast, int fishId)
        {
            Location l = new Location();

            l.Name    = name;
            l.State   = state;
            l.GPS     = GPS;
            l.IsCoast = coast;
            l.FishId  = fishId;
            Dataservice.Locations.InsertOnSubmit(l);
            Dataservice.SubmitChanges();
        }
Esempio n. 8
0
        public IActionResult RemoveBookmark(string username, string id, bool movie)
        {
            var  ds   = new Dataservice();
            bool done = ds.DeleteBookmark(username, id, movie);

            if (!done)
            {
                return(NotFound());
            }

            return(Ok());
        }
Esempio n. 9
0
        public IActionResult Bookmark(string username, string id, bool movie)
        {
            var  ds       = new Dataservice();
            bool bookmark = ds.CreateBookmark(username, id, movie);

            if (!bookmark)
            {
                return(NotFound());
            }

            return(Ok());
        }
Esempio n. 10
0
        public IActionResult Rate(string username, string tconst, int rating)
        {
            var ds      = new Dataservice();
            var success = ds.Rate(username, tconst, rating);

            if (!success)
            {
                return(NotFound());
            }

            return(Ok());
        }
Esempio n. 11
0
        public IActionResult Login(string username, string password)
        {
            var ds      = new Dataservice();
            var success = ds.Login(username, password);

            if (!success)
            {
                return(NotFound());
            }

            return(Ok());
        }
Esempio n. 12
0
        public IActionResult PopularActors(int amount, int page, int pagesize)
        {
            var ds     = new Dataservice();
            var result = ds.GetPopularActors(amount, page, pagesize);

            if (!result.Any())
            {
                return(NotFound());
            }

            var populatedresult = CreatePopularActorResult(page, pagesize, result);

            return(Ok(populatedresult));
        }
Esempio n. 13
0
        public IActionResult Bookmarked(string username, int page = 0, int pagesize = 50)
        {
            var ds           = new Dataservice();
            var searchresult = ds.GetBookmarked(username, page, pagesize);

            if (searchresult == null)
            {
                return(NotFound());
            }

            var populatedresult = CreateBookmarkedResult(username, searchresult, page, pagesize);

            return(Ok(populatedresult));
        }
Esempio n. 14
0
        public void UpdateFish(int id, decimal lenght, decimal weight, string type, int loactionId, string notes, int boatId,
                               int memberId, bool deleted)
        {
            Fish f = Dataservice.Fishes.SingleOrDefault(c => c.Id == id);

            f.Length     = lenght;
            f.Weight     = weight;
            f.Type       = type;
            f.LocationId = loactionId;
            f.BoatId     = boatId;
            f.MemberId   = memberId;
            f.IsDeleted  = deleted;
            Dataservice.SubmitChanges();
        }
Esempio n. 15
0
        public void AddFish(decimal length, decimal weight, string type, int loactionId, string notes, int boatId,
                            int memberId)
        {
            Fish f = new Fish();

            f.Length     = length;
            f.Weight     = weight;
            f.Type       = type;
            f.LocationId = loactionId;
            f.BoatId     = boatId;
            f.MemberId   = memberId;
            Dataservice.Fishes.InsertOnSubmit(f);
            Dataservice.SubmitChanges();
        }
Esempio n. 16
0
        public IActionResult RatingHistory(string username, int page = 0, int pagesize = 10)
        {
            var ds           = new Dataservice();
            var searchresult = ds.GetRatingHistory(username, page, pagesize);

            if (searchresult == null)
            {
                return(NotFound());
            }

            var populatedresult = CreateRatingHistoryResult(username, page, pagesize, searchresult);

            return(Ok(populatedresult));
        }
Esempio n. 17
0
        public IActionResult GetSpecificMovie(string tconst)
        {
            var ds           = new Dataservice();
            var searchresult = ds.GetSpecificMovie(tconst);

            if (searchresult is null)
            {
                return(NotFound());
            }

            // var populatedresult = CreateSpecificMovieResult(page, pagesize, searchresult);
            return(Ok(searchresult));
            //return Ok();
        }
Esempio n. 18
0
        public IActionResult CoActorSearch(string searchstring, int page, int pagesize)
        {
            var ds           = new Dataservice();
            var searchresult = ds.FindCoActor(searchstring);

            if (searchresult == null)
            {
                return(NotFound());
            }

            var populatedresult = CreateCoActorSearchResult(page, pagesize, searchresult);

            return(Ok(populatedresult));
        }
Esempio n. 19
0
        public IActionResult NameSearch(string username, string searchstring, int page = 0, int pagesize = 10)
        {
            var ds           = new Dataservice();
            var searchresult = ds.FindActors(username, searchstring, page, pagesize);

            if (!searchresult.Item1.Any())
            {
                return(NotFound());
            }

            var populatedresult = CreateNameSearchResult(page, pagesize, searchresult.Item1, searchresult.Item2);

            return(Ok(populatedresult));
        }
Esempio n. 20
0
        public void UpDateMember(int id, string first, string last, string email, string phone, string address,
                                 string address2, string city, string state, string zip, bool ative)
        {
            Member m = Dataservice.Members.SingleOrDefault(c => c.Id == id);

            m.FirstName = first;
            m.LastName  = last;
            m.Email     = email;
            m.Phone     = phone;
            m.Address   = address;
            m.Address2  = address2;
            m.City      = city;
            m.State     = state;
            m.Zip       = zip;
            m.IsAtive   = ative;
            Dataservice.SubmitChanges();
        }
Esempio n. 21
0
        public void AddMember(string first, string last, string email, string phone, string address,
                              string address2, string city, string state, string zip)
        {
            Member m = new Member();

            m.FirstName = first;
            m.LastName  = last;
            m.Email     = email;
            m.Phone     = phone;
            m.Address   = address;
            m.Address2  = address2;
            m.City      = city;
            m.State     = state;
            m.Zip       = zip;
            m.IsAtive   = true;
            m.DateAdded = DateTime.Now;
            Dataservice.Members.InsertOnSubmit(m);
            Dataservice.SubmitChanges();
        }
Esempio n. 22
0
        public IActionResult GetMovie(string tconst)
        {
            var ds    = new Dataservice();
            var movie = ds.GetTitle(tconst);

            if (movie == null)
            {
                return(NotFound());
            }

            movie.Tconst = movie.Tconst.Trim();
            var mapped = _mapper.Map <TitleDto>(movie);

            mapped.Bookmarklink = Url.Link(nameof(BookmarkController.Bookmark), new { id = movie.Tconst, movie = true });
            mapped.Ratelink     = Url.Link(nameof(Rate), new { movie.Tconst, rating = 5 });


            return(Ok(mapped));
        }
Esempio n. 23
0
        private object CreateSearchHistoryResult(string username, int page, int pageSize, IList <Searchhistory> histories)
        {
            var ds = new Dataservice();

            var count = ds.numberOfSearchHistories(username);

            var mappedhistory = histories.Select(MapSearchElement);

            var navigationUrls = CreatePagingNavigation(page, pageSize, count, nameof(SearchHistory));

            var result = new
            {
                navigationUrls.prev,
                navigationUrls.cur,
                navigationUrls.next,
                count,
                mappedhistory
            };

            return(result);
        }
Esempio n. 24
0
        private object CreateBookmarkedResult(string username, IList <Bookmark> bookmarks, int page = 1, int pageSize = 50)
        {
            var ds = new Dataservice();

            var count = ds.numberOfBookmarks(username);

            var personlist = bookmarks.Select(MapBookmarks);

            var navigationUrls = CreatePagingNavigation(page, pageSize, count, nameof(Bookmarked));

            var result = new
            {
                navigationUrls.prev,
                navigationUrls.cur,
                navigationUrls.next,
                count,
                personlist
            };

            return(result);
        }
Esempio n. 25
0
        public IActionResult GetPerson(string nconst)
        {   //definere ds
            var ds = new Dataservice();
            //kalder vores ds.getperson
            var result = ds.GetPerson(nconst);

            //intet resultat return null.
            if (result == null)
            {
                return(NotFound());
            }
            //hvis resultat, mapper vores resultat til persondto
            var mapped = _mapper.Map <PersonDto>(result);

            //trimmer dataen
            result.Nconst = result.Nconst.Trim();
            //mapper vores url
            mapped.Link = Url.Link(nameof(BookmarkController.Bookmark), new { id = result.Nconst, movie = false });

            return(Ok(mapped));
        }