Beispiel #1
0
        // DeleteAMiniModel
        /// <summary>
        /// Deletes a miniModel from wishlist and db
        /// </summary>
        /// <param name="id">integer for id</param>
        /// <returns> task completion </returns>
        public async Task Delete(int id)
        {
            MiniWishList wishList = await _context.MiniWishLists.FindAsync(id);

            _context.Entry(wishList).State = EntityState.Deleted;
            await _context.SaveChangesAsync();
        }
Beispiel #2
0
        /// <summary>
        /// Gets a single miniModel in the wishlist
        /// </summary>
        /// <param name="id"> integer for id</param>
        /// <param name="email">users email</param>
        /// <returns> a single wishlistdto object <returns>
        public async Task <MiniWishListDTO> GetMiniModelInWishList(int id, string email)
        {
            MiniWishList wishList = await _context.MiniWishLists.Where(x => x.Email == email)
                                    .FirstOrDefaultAsync(x => x.Id == id);

            MiniWishListDTO wishListDto = new MiniWishListDTO()
            {
                Id           = wishList.Id,
                Name         = wishList.Name,
                Manufacturer = wishList.Manufacturer,
                PartNumber   = wishList.PartNumber,
                Faction      = wishList.Faction,
                PointCost    = wishList.PointCost,
                Price        = wishList.Price,
            };

            return(wishListDto);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a miniWishList and adds it to the db
        /// </summary>
        /// <param name="wishListDto"> dto object</param>
        /// <param name="email"> user email</param>
        /// <returns> a wishlistdto </returns>
        public async Task <MiniWishListDTO> Create(MiniWishListDTO wishListDto, string email)
        {
            MiniWishList wishList = new MiniWishList()
            {
                Name         = wishListDto.Name,
                Manufacturer = wishListDto.Manufacturer,
                PartNumber   = wishListDto.PartNumber,
                Faction      = wishListDto.Faction,
                PointCost    = wishListDto.PointCost,
                Price        = wishListDto.Price,
                Email        = email
            };

            _context.Entry(wishList).State = EntityState.Added;
            await _context.SaveChangesAsync();

            return(wishListDto);
        }