public string Delete()
        {
            AccessWcfService service    = new AccessWcfService("DeleteUser", "DELETE");
            string           inputJson  = JsonConvert.SerializeObject(Id);
            string           returnJson = service.SendJsonToService(inputJson);

            return(returnJson);
        }
        public string Modify()
        {
            AccessWcfService  service = new AccessWcfService("ModifyUser", "PUT");
            UserLoginContract user    = new UserLoginContract {
                Username = NewUserName, Rank = NewRank, Password = NewPassword, ID = Id
            };
            string inputJson  = JsonConvert.SerializeObject(user);
            string returnJson = service.SendJsonToService(inputJson);

            return(returnJson);
        }
Beispiel #3
0
        public string Modify()
        {
            AccessWcfService service = new AccessWcfService("ModifyAlbum", "PUT");
            AlbumContract    album   = new AlbumContract {
                IdAlbum = Id, AlbumName = NewAlbumName, ArtistName = NewArtistName
            };
            string inputJson = Newtonsoft.Json.JsonConvert.SerializeObject(album);

            string returnJson = service.SendJsonToService(inputJson);

            return(returnJson);
        }
        public string AddUser()
        {
            AccessWcfService  service = new AccessWcfService("AddUser", "POST");
            UserLoginContract user    = new UserLoginContract {
                Username = this.Username, Password = this.Password, Rank = this.Rank
            };
            string inputJson = Newtonsoft.Json.JsonConvert.SerializeObject(user);

            string returnMessage = service.SendJsonToService(inputJson);

            return(returnMessage);
        }
        public string DeleteRating()
        {
            if (ID_rating == "null")
            {
                return("");
            }

            AccessWcfService service = new AccessWcfService("DeleteRating", "DELETE");
            int    id   = Int32.Parse(ID_rating);
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(id);

            return(service.SendJsonToService(json));
        }
        public string ModifyRating()
        {
            if (ID_rating == "null")
            {
                return("");
            }

            AccessWcfService service = new AccessWcfService("ModifyRating", "PUT");
            RatingContract   rating  = new RatingContract {
                IdRating = Int32.Parse(ID_rating), Rating = Int32.Parse(NewRating)
            };
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(rating);

            return(service.SendJsonToService(json));
        }
Beispiel #7
0
 public string AddAlbum()
 {
     try
     {
         AccessWcfService service = new AccessWcfService("AddAlbum", "POST");
         var album = new AlbumContract {
             ArtistName = NewArtistName, AlbumName = NewAlbumName
         };
         string returnMessage = service.SendJsonToService(album);
         return(returnMessage);
     }
     catch (Exception e)
     {
         return("Error: No database connection");
     }
 }
        public string Rate(string user)
        {
            AccessWcfService getUserId    = new AccessWcfService("GetUserByName", "GET", user);
            string           userJsonData = getUserId.GetJsonFromService();
            int idUser = Newtonsoft.Json.JsonConvert.DeserializeObject <UserContract>(userJsonData).IdUser;

            AccessWcfService getAlbumId    = new AccessWcfService("GetAlbum", "GET", Album);
            string           albumJsonData = getAlbumId.GetJsonFromService();
            int idAlbum = Newtonsoft.Json.JsonConvert.DeserializeObject <AlbumContract>(albumJsonData).IdAlbum;

            AccessWcfService serviceAddUser = new AccessWcfService("AddRating", "POST");
            RatingContract   rating         = new RatingContract {
                IdUser = idUser, IdAlbum = idAlbum, Rating = Int32.Parse(Rating)
            };
            string returnMessage = serviceAddUser.SendJsonToService(rating);

            return(returnMessage);
        }
Beispiel #9
0
        public override bool ValidateUser(string username, string password)
        {
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                return(false);
            }

            AccessWcfService service = new AccessWcfService("Login", "POST");

            string jsonString = service.SendJsonToService
                                    (new WcfServiceReference.UserLoginContract {
                Username = username, Password = password
            });

            WcfServiceReference.UserLoginContract user =
                Newtonsoft.Json.JsonConvert.DeserializeObject <WcfServiceReference.UserLoginContract>(jsonString);

            return((user.Username != null) ? true : false);
        }