public ListingsService(ReuseventoryDbContext ctx, IMapper mapper, ICurrentUserService currentUserService, ILogger <ListingsService> logger)
 {
     _ctx                = ctx;
     _mapper             = mapper;
     _currentUserService = currentUserService;
     _logger             = logger;
 }
Ejemplo n.º 2
0
 public static void seed(ReuseventoryDbContext db)
 {
     addAdmins(db);
     addUsers(db);
     db.SaveChanges();
     addListings(db);
     db.SaveChanges();
 }
Ejemplo n.º 3
0
        public void SetUp()
        {
            _ctx     = TestDbContextFactory.GetContext();
            _service = new ListingsService(_ctx, MapperConfigFactory.GetMapper(), new MockCurrentUserService(), new NullLogger <ListingsService>());

            _ctx.Database.EnsureDeleted();
            _ctx.Database.EnsureCreated();
        }
        public ListingsController(ReuseventoryDbContext ctx, ILogger <ListingsController> logger, IListingsService listingService)
        {
            _ctx            = ctx;
            _logger         = logger;
            _listingService = listingService;

            if (_ctx.Listings.Count() == 0)
            {
                for (int user = 0; user < 20; user++)
                {
                    _ctx.Users.Add(new User()
                    {
                        username = "******" + user,
                        password = "******",
                        phone    = DateTime.UtcNow.Ticks.ToString().Substring(8),
                        email    = "test_user_" + user + "@gmail.com",
                        isAdmin  = false
                    });
                }
                _ctx.SaveChanges();

                Random r     = new Random(DateTime.Now.Millisecond);
                int    count = _ctx.Users.Count();
                for (int listing = 0; listing < 100; listing++)
                {
                    ICollection <ListingTag> tags = new List <ListingTag>();
                    int numTags = r.Next(5);
                    for (int t = 0; t < numTags; t++)
                    {
                        tags.Add(
                            new ListingTag()
                        {
                            name = "tag_" + r.Next(35)
                        }
                            );
                    }

                    _ctx.Listings.Add(new Listing()
                    {
                        name        = "listing_" + listing,
                        userId      = _ctx.Users.ToList()[r.Next(count)].id,
                        description = "This is a brief description of the item.",
                        tags        = tags
                    });
                }

                _ctx.SaveChanges();
            }
        }
 public Action <IApplicationBuilder> Configure(Action <IApplicationBuilder> next)
 {
     return(builder =>
     {
         if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development" || Environment.GetEnvironmentVariable("SEED_DATA") == "true")
         {
             using (var scope = builder.ApplicationServices.CreateScope())
             {
                 ReuseventoryDbContext db = scope.ServiceProvider.GetService <ReuseventoryDbContext>();
                 SeedDataHelper.seed(db);
             };
         }
         next(builder);
     });
 }
Ejemplo n.º 6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ReuseventoryDbContext dataContext)
        {
            if (false == IsDevelopment)
            {
                dataContext.Database.Migrate();
            }

            if (env.IsDevelopment())
            {
                //app.UseDeveloperExceptionPage();
                app.UseExceptionHandler("/error-local-development");
            }
            else
            {
                app.UseExceptionHandler("/error");
            }

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "ReuseventoryApi v1");
                c.SupportedSubmitMethods(new Swashbuckle.AspNetCore.SwaggerUI.SubmitMethod[] { });
            });

            app.UseCors(
                options => options
                .AllowAnyHeader()
                .WithMethods("OPTIONS", "GET", "POST")
                .AllowAnyOrigin()
                );

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Ejemplo n.º 7
0
        public UsersController(ReuseventoryDbContext ctx, ILogger <UsersController> logger, IUserService userService, IJwtAuthManager jwtAuthManager, IMapper mapper)
        {
            _ctx            = ctx;
            _userService    = userService;
            _jwtAuthManager = jwtAuthManager;
            _logger         = logger;
            _mapper         = mapper;

            if (_ctx.Users.Count() == 0)
            {
                for (int i = 0; i < 250; i++)
                {
                    _ctx.Users.Add(new User()
                    {
                        username = new Guid().ToString()
                    });
                }
                _ctx.SaveChanges();
            }
        }
Ejemplo n.º 8
0
 private static void addAdmins(ReuseventoryDbContext db)
 {
     db.Users.AddRange(
         new User()
     {
         username = "******",
         email    = "*****@*****.**",
         phone    = "123-456-7890",
         password = BCrypt.Net.BCrypt.HashPassword("Password123!"),
         isAdmin  = true
     },
         new User()
     {
         username = "******",
         email    = "*****@*****.**",
         phone    = "12394214",
         password = BCrypt.Net.BCrypt.HashPassword("Password123!"),
         isAdmin  = true
     }
         );
 }
Ejemplo n.º 9
0
 public ListingImagesController(ReuseventoryDbContext ctx, ILogger <ListingImagesController> logger)
 {
     _ctx    = ctx;
     _logger = logger;
 }
Ejemplo n.º 10
0
 private static void addUsers(ReuseventoryDbContext db)
 {
     db.Users.AddRange(
         new User()
     {
         email    = "*****@*****.**",
         phone    = "607-867-5309",
         username = "******",
         password = BCrypt.Net.BCrypt.HashPassword("Password123!")
     },
         new User()
     {
         email    = "*****@*****.**",
         phone    = "616-738-3338",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "159-566-7867",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "493-408-1096",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "352-223-9238",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "695-802-5193",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "924-562-2035",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "916-831-9954",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "379-343-8639",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "697-298-6344",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "228-859-8214",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "547-988-0944",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "955-714-9726",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "587-918-1029",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "944-995-9942",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "419-119-8985",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "251-470-7452",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "571-447-1593",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "789-992-2540",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "384-593-4949",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "691-676-0057",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "191-247-7580",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "838-236-2446",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "370-594-7742",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "927-932-2764",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "675-529-8596",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "430-600-0452",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "720-420-9034",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "456-806-9929",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "916-419-1299",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "685-952-3262",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "898-406-4483",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "751-485-4191",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "678-440-8381",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "841-808-3321",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "288-598-5411",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "958-330-1967",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "106-345-0742",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "198-827-4831",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "769-138-2988",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "395-572-8880",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "569-732-2251",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "679-576-8585",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "651-685-2953",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "667-366-4254",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "389-146-2446",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "320-325-3694",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "823-518-8780",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "534-613-1216",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "200-847-0324",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "515-714-8266",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "676-720-2324",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "113-909-7456",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "123-977-0228",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "317-804-2690",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "574-241-3275",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "594-651-5726",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "799-288-7873",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "770-102-9093",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "595-667-0295",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "421-540-4610",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "264-452-9401",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "929-156-9146",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "608-190-0197",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "296-236-2113",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "648-136-5844",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "273-681-4543",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "716-869-6304",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "455-382-6674",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "194-996-3513",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "533-847-5816",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "501-209-1932",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "749-843-8532",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "120-659-9790",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "924-893-7546",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "552-609-6515",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "343-534-8208",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "516-233-1275",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "947-436-1403",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "489-254-2746",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "964-361-7834",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "339-376-5832",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "172-303-6953",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "461-225-4435",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "445-970-9447",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "508-137-1439",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "665-954-9395",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "910-510-4492",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "566-934-6721",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "854-755-6593",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "535-758-7889",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "413-748-0979",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "864-791-6374",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "493-198-9441",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "993-251-6401",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "905-502-8984",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "762-623-6656",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "790-327-0394",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "631-688-3639",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "297-118-2901",
         username = "******"
     }, new User()
     {
         email    = "*****@*****.**",
         phone    = "263-847-0285",
         username = "******"
     }
         );
 }
Ejemplo n.º 11
0
 private static User randomUser(ReuseventoryDbContext db)
 {
     return(db.Users.ToList().OrderBy(_ => Guid.NewGuid()).FirstOrDefault());
 }
Ejemplo n.º 12
0
        private static void addListings(ReuseventoryDbContext db)
        {
            DateTime created = randomDate();

            db.Listings.AddRange(new Listing()
            {
                name        = "8,000btu Large air conditioner",
                description = "This is a large older ac unit that still makes a room icy cold. It is an Amana Quietzone for whatever that’s worth. I cleaned it all up for sale and washed the filters. It’s good to go! The catch is that it needs at least a 24” wide window. So measure up!",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 80,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "appliances"
                    }
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/png",
                        fileName    = "image.png",
                        image       = getImage("airconditioner.png"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "Large George Foreman Grill in Great Shape ",
                description = "Bought it for my brother but he already had one! Very lightly used. Great shape. Right downtown. Feel free to text.",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 12,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "appliances",
                    },
                    new ListingTag()
                    {
                        name = "cooking",
                    }
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("grillforeman.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "Dirt Devil EZ Lite Bagless Canister Vacuum",
                description = "Slightly used vacuum. Still works perfectly fine!",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 20,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "appliances",
                    }
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("dustdevil.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "CrockPot",
                description = "Spotless. Clean. Works perfectly. Has been used only once or twice. Please put it to good use.",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 15,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "appliances",
                    },
                    new ListingTag()
                    {
                        name = "cooking",
                    }
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("crockpot.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "Galanz Mini Fridge with Freezer",
                description = "Lightly used Galanz 3.1 cu ft two-door mini fridge with freezer (model number GL31BK). Purchased in 2016. Used and stored indoors. Clean, operates perfectly, in good condition. Minor scuffs on sides and small scrape on exterior of freezer door. All original parts and fittings included.",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 100,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "appliances",
                    },
                    new ListingTag()
                    {
                        name = "storage",
                    }
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("freezer.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "Like new Dresser with Mirror",
                description = "I am so sad to have to part ways with my beautiful dresser with mirror. Paid over $1200 for it new but it doesn't fit up the stairs in my new location.",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 400,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "storage",
                    }
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("dresser.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "CrockPot",
                description = "The perfect size Crock-Pot slow cooker for a 5 pound roast, the SCR500-SP accommodates varied cooking needs and time constraints with high, low and warm settings.",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 15,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "appliances",
                    },
                    new ListingTag()
                    {
                        name = "cooking",
                    }
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("crockpot2.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "Honeywell Fan",
                description = "Honewell Turbo Fans, black and white. Used, but like new. VERY powerful (I use just one fan and it keeps my room cool in this weather).",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 10,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "appliances",
                    }
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("fan.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "CrockPot with self stirring attachment",
                description = "Crock Pot with self-stirring motor option. Comes with two paddles - general purpose for soups and stew paddle for more dense dishes. In excellent condition.",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 20,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "appliances",
                    },
                    new ListingTag()
                    {
                        name = "cooking",
                    }
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("crockpot3.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "LG 32'' Full HD Monitor",
                description = "Bought this monitor last April. Used it very well and packed it again. Almost brand new. Not even peeled stickers off. Moving sale.",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 200,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "electronics",
                    },
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("monitor.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "Piano keyboard",
                description = "Originally 300 on Amazon. Sounds great. Comes with stand and chair. I have no room for it",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 200,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "electronics",
                    },
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("piano.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "HP desktop printer",
                description = "HP Desktop 3755. Print scan copy web Only used a few times. Chords included. Still has lots of ink.",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 40,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "electronics",
                    },
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("printer1.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "HP Deskjet 1512 Printer",
                description = "Good as new. Only printed like 10 page report last school year. Still has lots of ink. Comes with spare ink cartridges.",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 50,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "electronics",
                    },
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("printer2.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "Wireless keyboard and mouse",
                description = "I'm selling my almost new wireless mouse and keyboard because my father gave me other ones as a gift. They have 2 months of use.",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 10,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "electronics",
                    },
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("keyboard.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "Fender “Squire” stratocaster electric guitar, with soft carry case/bac",
                description = "Fender Squire stratocaster electric guitar, with soft carry case/backpack, and fender strap",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 140,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "electronics",
                    },
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("guitar.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "Mirror",
                description = "It's a mirror. It's tall, like 6 feet...ish",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 15,
                userId      = randomUser(db).id,
                images      = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("mirror.jpg"),
                    }
                }
            },
                                 new Listing()
            {
                name        = "Drawers",
                description = "Sterlite- Plastic 3 Drawers. Used for only 2 semesters.",
                created     = randomDate(),
                modified    = randomDate(),
                price       = 10,
                userId      = randomUser(db).id,
                tags        = new List <ListingTag>()
                {
                    new ListingTag()
                    {
                        name = "storage",
                    },
                },
                images = new List <ListingImage>()
                {
                    new ListingImage()
                    {
                        contentType = "image/jpg",
                        fileName    = "image.jpg",
                        image       = getImage("drawers.jpg"),
                    }
                }
            }
                                 );
        }
 public IsOwnerOrAdminHandler(ReuseventoryDbContext ctx, ILogger <IsOwnerOrAdminHandler> logger)
 {
     _ctx    = ctx;
     _logger = logger;
 }
Ejemplo n.º 14
0
 public UserService(ReuseventoryDbContext ctx, IMapper mapper, ICurrentUserService currentUserService)
 {
     _ctx                = ctx;
     _mapper             = mapper;
     _currentUserService = currentUserService;
 }
Ejemplo n.º 15
0
 public CurrentUserService(ReuseventoryDbContext ctx, IHttpContextAccessor accessor)
 {
     _ctx      = ctx;
     _accessor = accessor;
 }