public async Task FavouriteReader_ForResponse_CreatesCorrectObjects()
        {
            IEnumerable <IFavourite> result = await TestUtility.ExecuteArrayReaderByTypeAsync <IFavourite>(FAVOURITE_RESPONSE_SINGLE);

            IFavourite favourite = result.First();

            Assert.Multiple(() => {
                Assert.That(favourite.SystemId, Is.EqualTo(21));
                Assert.That(favourite.SystemName, Is.EqualTo("PVOutput Demo"));
                Assert.That(favourite.SystemSize, Is.EqualTo(2450));
                Assert.That(favourite.Postcode, Is.EqualTo(2199));
                Assert.That(favourite.NumberOfPanels, Is.EqualTo(14));
                Assert.That(favourite.PanelPower, Is.EqualTo(175));
                Assert.That(favourite.PanelBrand, Is.EqualTo("Enertech"));
                Assert.That(favourite.NumberOfInverters, Is.EqualTo(1));
                Assert.That(favourite.InverterPower, Is.EqualTo(2000));
                Assert.That(favourite.InverterBrand, Is.EqualTo("CMS"));
                Assert.That(favourite.Orientation, Is.EqualTo(Orientation.North));
                Assert.That(favourite.ArrayTilt, Is.EqualTo(30.5d));
                Assert.That(favourite.Shade, Is.EqualTo(Shade.None));
                Assert.That(favourite.InstallDate, Is.EqualTo(new DateTime(2010, 1, 1)));
                Assert.That(favourite.Location.Latitude, Is.EqualTo(-33.907725d));
                Assert.That(favourite.Location.Longitude, Is.EqualTo(151.026108d));
                Assert.That(favourite.StatusInterval, Is.EqualTo(5));
            });
        }
Exemple #2
0
 public virtual Task <int> InsertAsync(IFavourite entity)
 {
     try
     {
         return(Repository.InsertAsync <Favourite>(Mapper.Map <Favourite>(entity)));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemple #3
0
        public async Task <int> DeleteAsync(IFavourite entity)
        {
            try
            {
                return(await Repository.DeleteAsync(entity));
            }

            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #4
0
        public void CreateFavourite(IFavourite _favourite)
        {
            var favourite = new Favourite
            {
                favouriteId = _favourite.favouriteId,
                MovieId     = _favourite.MovieId,
                UserId      = _favourite.UserId,
                MovieName   = _favourite.MovieName
            };

            favouriteContext.CreateFavourite(favourite);
        }
        //Create in CRUD
        public void CreateFavourite(IFavourite favourite)
        {
            _connection.SqlConnection.Open();
            string query = "INSERT INTO `favourite` (`FavouriteId`, `MovieId`, `UserId`, `MovieName`) VALUES(@FavouriteId, @MovieId, @UserId, @MovieName); ";

            using (MySqlCommand command = new MySqlCommand(query, _connection.SqlConnection))
            {
                command.Parameters.AddWithValue("@FavouriteId", favourite.favouriteId);
                command.Parameters.AddWithValue("@MovieId", favourite.MovieId);
                command.Parameters.AddWithValue("@UserId", favourite.UserId);
                command.Parameters.AddWithValue("@MovieName", favourite.MovieName);

                command.ExecuteNonQuery();
            }
            _connection.SqlConnection.Close();
        }
 public void CreateFavourite(IFavourite favourite)
 {
     _context.CreateFavourite(favourite);
 }
 public FavouritesController()
 {
     favouriteRepository = new FavouriteRepository();
 }
 public FavouriteService(IMapper mapper, IFavourite repo)
 {
     this._mapper = mapper;
     this._repo   = repo;
 }