public HomeController(DatingAppContext context, ILogger <HomeController> logger) { _context = context; _logger = logger; random = new Random(); personRepository = new PersonRepository(context); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, DatingAppContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(builder => { builder.Run(async handler => { handler.Response.StatusCode = (int)HttpStatusCode.InternalServerError; var error = handler.Features.Get <IExceptionHandlerFeature>(); if (error != null) { handler.Response.AddApplicationError(error.Error.Message); await handler.Response.WriteAsync(error.Error.Message); } }); }); app.UseHsts(); } context.SeedData(); //SEED app.UseCors(o => o.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseAuthentication(); app.UseHttpsRedirection(); app.UseMvc(); }
/// <summary> /// Repository method to create new user in db /// </summary> /// <param name="newUser">Repository User Entity</param> /// <returns>User Entity</returns> public async Task <User> CreateNewUser(User newUser) { using (var context = new DatingAppContext()) { //validate that the new user entity isn't empty if (newUser == null) { throw new Exception("User not provided"); } //update status to be true and created / updates dates newUser.Status = true; newUser.CreatedDate = DateTime.Now; newUser.UpdatedDate = DateTime.Now; context.Users.Add(newUser); await context.SaveChangesAsync(); //pull user that has just been created var createdUser = await context.Users.FirstOrDefaultAsync(u => u.Username == newUser.Username); return(createdUser); } }
public PersonController(DatingAppContext context) { _context = context; personRepository = new PersonRepository(context); postRepository = new PostRepository(context); requestRepository = new FriendRequestRepository(context); }
/// <summary> /// Repository method to pull users by location /// </summary> /// <param name="location">Location as string</param> /// <returns>List of User Entities</returns> public async Task <List <User> > GetUsersByLocation(string location) { using (var context = new DatingAppContext()) { return(await context.Users.Where(u => u.Location == location) .ToListAsync()); } }
/// <summary> /// Repository method to pull list of users from database by userId /// </summary> /// <param name="userIds">List of User Ids</param> /// <returns>List of Users Entity</returns> public async Task <List <User> > GetUsersByUserId(List <long> userIds) { using (var context = new DatingAppContext()) { return(await context.Users .Where(u => userIds.Any(id => u.Id == id)).ToListAsync()); } }
/// <summary> /// Repository method to delete existing user account /// </summary> /// <param name="userId">User Id</param> /// <returns>Completed Task</returns> public async Task DeleteUserAccount(long userId) { using (var context = new DatingAppContext()) { var existingUser = await context.Users.FirstOrDefaultAsync(u => u.Id == userId); context.Users.Remove(existingUser); await context.SaveChangesAsync(); } }
/// <summary> /// Repository method to pull individual user from database /// </summary> /// <returns>User Entity</returns> public async Task <User> GetUserByUserName(string userName) { using (var context = new DatingAppContext()) { User existingUser = new User(); existingUser = await context.Users .FirstOrDefaultAsync(u => u.Username == userName); return(existingUser); } }
/// <summary> /// Repository method to update a user's login / logout status /// </summary> /// <param name="userName">Username</param> /// <returns>Completed Task</returns> public async Task UpdateUserStatus(long userId, bool status) { using (var context = new DatingAppContext()) { //pull user account var user = await context.Users.FirstOrDefaultAsync(u => u.Id == userId); //update status user.Status = status; await context.SaveChangesAsync(); } }
public RegisterModel( UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager, ILogger <RegisterModel> logger, IEmailSender emailSender, DatingAppContext context, IWebHostEnvironment hostEnvironment) { _userManager = userManager; _signInManager = signInManager; _logger = logger; _emailSender = emailSender; _context = context; _hostEnvironment = hostEnvironment; }
/// <summary> /// Repository method to update individual user's profile /// </summary> /// <param name="updatedUser">Repository User Entity</param> /// <returns>Completed Task</returns> public async Task UpdateUserProfile(User updatedUser) { using (var context = new DatingAppContext()) { var userProfile = await context.Users.FirstOrDefaultAsync(u => u.Username == updatedUser.Username); userProfile.FirstName = updatedUser.FirstName; userProfile.LastName = updatedUser.LastName; userProfile.Password = updatedUser.Password; userProfile.Location = updatedUser.Location; userProfile.Gender = updatedUser.Gender; userProfile.About = updatedUser.About; userProfile.Interests = updatedUser.Interests; userProfile.UpdatedDate = DateTime.Now; await context.SaveChangesAsync(); } }
/// <summary> /// Agent that runs a scheduled task /// </summary> /// <param name="task"> /// The invoked task /// </param> /// <remarks> /// This method is called when a periodic or resource intensive task is invoked /// </remarks> protected override void OnInvoke(ScheduledTask task) { //TODO: Add code to perform your task in background if (task.Name == "DatingDiaryTask") { if (task is PeriodicTask) { // Execute periodic task actions here. ShellTile TileToFind = ShellTile.ActiveTiles.First(); // OrDefault(x => x.NavigationUri.ToString().Contains("DefaultTitle=DatingApp")); if (TileToFind != null) { string ConnectionString = @"isostore:/DatingDiaryDB.sdf"; DatingAppContext ctx = new DatingAppContext(ConnectionString); // get the number of dates there are today ... int dateCount = ctx.Dates.Count(x => x.DateOfMeeting.Date == DateTime.Now.Date); // get the next date Date nextDate = ctx.Dates.FirstOrDefault(x => x.DateOfMeeting.Date == DateTime.Now.Date); StandardTileData NewTileData = new StandardTileData { Title = dateCount > 0 ? "Dating Diary" : string.Empty, Count = dateCount, BackTitle = nextDate.Person.FullName, BackBackgroundImage = new Uri("BackBackground.png", UriKind.RelativeOrAbsolute), BackContent = string.Format("Today @ {0}", nextDate.DateOfMeeting.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern, CultureInfo.CurrentCulture.DateTimeFormat)) }; TileToFind.Update(NewTileData); } } else { // Execute resource-intensive task actions here. } } ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(3)); NotifyComplete(); }
public MovieDetailsController(DatingAppContext context) { _context = context; }
public UserRepository(DatingAppContext context) : base(context) { }
public Repository(DatingAppContext context) { this.context = context; }
public AuthRepository(DatingAppContext context) { _context = context; }
public ValueRepository(DatingAppContext context) : base(context) { this._context = context; }
public PostApiController(DatingAppContext context) { _context = context; personRepository = new PersonRepository(context); }
public AuthRepository(DatingAppContext datingAppContext, IConfiguration configuration) { _configuration = configuration; _datingAppContext = datingAppContext; }
public Repository(DatingAppContext dataContext) { DataTable = dataContext.GetTable <T>(); }
public ValuesController(DatingAppContext context) { _context = context; }
public BaseRepository(DatingAppContext Context) { this._ctx = Context; }
private void TestData() { using (DatingAppContext db = new DatingAppContext(AppContext.Instance.ConnectionString)) { if (db.DatabaseExists() == false) { // Create the local database. db.CreateDatabase(); Note n1 = new Note { CreatedDate = DateTime.Now, Content = "This is a note" }; Note n2 = new Note { CreatedDate = DateTime.Now, Content = "This is another note and this is extra text to push it onto another line but will it" }; db.Notes.InsertOnSubmit(n1); db.Notes.InsertOnSubmit(n2); Venue v1 = new Venue { Name = "Zizzi Chislehurst", Latitude = 51.417493, Longitude = 0.067863, IsFavourite = true }; Venue v2 = new Venue { Name = "TGI Friday New York", Latitude = 40.706681, Longitude = -74.013169 }; Venue v3 = new Venue { Name = "Bella Italia Leicester Square", Latitude = 51.510687, Longitude = -0.129290 }; Venue v4 = new Venue { Name = "Hyde Park", Latitude = 51.507432, Longitude = -0.165708 }; Venue v5 = new Venue { Name = "Sea Life Centre Brighton", Latitude = 50.819573, Longitude = -0.135351, IsFavourite = true }; db.Venues.InsertOnSubmit(v1); db.Venues.InsertOnSubmit(v2); db.Venues.InsertOnSubmit(v3); db.Venues.InsertOnSubmit(v4); db.Venues.InsertOnSubmit(v5); Interest i1 = new Interest() { Description = "Football", Weighting = 3 }; Interest i2 = new Interest() { Description = "Tennis", Weighting = 2 }; Interest i3 = new Interest() { Description = "Ping Pong", Weighting = 1 }; Interest i4 = new Interest() { Description = "Hockey", Weighting = 1 }; Interest i5 = new Interest() { Description = "Squash", Weighting = 3 }; Interest i6 = new Interest() { Description = "Judo", Weighting = 2 }; db.Interests.InsertOnSubmit(i1); db.Interests.InsertOnSubmit(i2); db.Interests.InsertOnSubmit(i3); db.Interests.InsertOnSubmit(i4); db.Interests.InsertOnSubmit(i5); db.Interests.InsertOnSubmit(i6); Date d1 = new Date { Venue = v1, DateOfMeeting = DateTime.Now.AddMinutes(25), Rating = 2.5, Notes = new EntitySet <Note>() { n1, n2 } }; Date d2 = new Date { Venue = v2, DateOfMeeting = DateTime.Now.AddDays(26), Rating = 5, IsFavourite = true }; Date d3 = new Date { Venue = v3, DateOfMeeting = DateTime.Now.AddDays(1), Rating = 3, IsFavourite = true }; Date d4 = new Date { Venue = v4, DateOfMeeting = DateTime.Now.AddDays(2), Rating = 4, IsFavourite = true }; Date d5 = new Date { Venue = v5, DateOfMeeting = DateTime.Now.AddDays(5), Rating = 1 }; Date d6 = new Date { Venue = v5, DateOfMeeting = DateTime.Now.AddDays(25), Rating = 1 }; Date d7 = new Date { Venue = v5, DateOfMeeting = DateTime.Now.AddDays(14), Rating = 5 }; db.Dates.InsertOnSubmit(d1); db.Dates.InsertOnSubmit(d2); db.Dates.InsertOnSubmit(d3); db.Dates.InsertOnSubmit(d4); db.Dates.InsertOnSubmit(d5); db.Dates.InsertOnSubmit(d6); db.Dates.InsertOnSubmit(d7); //Country c1 = new Country() { Name = "United Kingdom" }; //db.Countries.InsertOnSubmit(c1); // Prepopulate the categories. db.Persons.InsertOnSubmit(new Person { FirstName = "Alex", SecondName = "Williams", PhoneNumber = "067878768", Email = "*****@*****.**", IsFavourite = true, Dates = new EntitySet <Date>() { d1, d2, d6, d7 }, Interests = new EntitySet <Interest>() { i1, i2, i3, i4, i5, i6 } }); db.Persons.InsertOnSubmit(new Person { FirstName = "Rachel", SecondName = "Scott", PhoneNumber = "0345234545", Email = "*****@*****.**", IsFavourite = true, Dates = new EntitySet <Date>() { d3 } }); db.Persons.InsertOnSubmit(new Person { FirstName = "Iain", SecondName = "Smith", PhoneNumber = "032234324", Email = "*****@*****.**", IsFavourite = true, Dates = new EntitySet <Date>() { d4 } }); db.Persons.InsertOnSubmit(new Person { FirstName = "John", SecondName = "Benson", PhoneNumber = "03454353", Email = "*****@*****.**", Dates = new EntitySet <Date>() { d5 } }); db.Persons.InsertOnSubmit(new Person { FirstName = "Peter", SecondName = "Parker", PhoneNumber = "034324324", Email = "*****@*****.**" }); db.Persons.InsertOnSubmit(new Person { FirstName = "Amit", SecondName = "Dam", PhoneNumber = "0234324", Email = "*****@*****.**" }); db.Persons.InsertOnSubmit(new Person { FirstName = "Helen", SecondName = "Johnson", PhoneNumber = "04365435", Email = "*****@*****.**" }); //db.Persons.InsertOnSubmit(new Person { FirstName = "Alex", SecondName = "Williams", PhoneNumber = "067878768", Email = "*****@*****.**", Country = c1, IsFavourite = true, Dates = new EntitySet<Date>() { d1, d2, d6, d7 }, Interests = new EntitySet<Interest>() { i1, i2, i3, i4, i5, i6 } }); //db.Persons.InsertOnSubmit(new Person { FirstName = "Rachel", SecondName = "Scott", PhoneNumber = "0345234545", Email = "*****@*****.**", Country = c1, IsFavourite = true, Dates = new EntitySet<Date>() { d3 } }); //db.Persons.InsertOnSubmit(new Person { FirstName = "Iain", SecondName = "Smith", PhoneNumber = "032234324", Email = "*****@*****.**", Country = c1, IsFavourite = true, Dates = new EntitySet<Date>() { d4 } }); //db.Persons.InsertOnSubmit(new Person { FirstName = "John", SecondName = "Benson", PhoneNumber = "03454353", Email = "*****@*****.**", Country = c1, Dates = new EntitySet<Date>() { d5 } }); //db.Persons.InsertOnSubmit(new Person { FirstName = "Peter", SecondName = "Parker", PhoneNumber = "034324324", Email = "*****@*****.**", Country = c1 }); //db.Persons.InsertOnSubmit(new Person { FirstName = "Amit", SecondName = "Dam", PhoneNumber = "0234324", Email = "*****@*****.**", Country = c1 }); //db.Persons.InsertOnSubmit(new Person { FirstName = "Helen", SecondName = "Johnson", PhoneNumber = "04365435", Email = "*****@*****.**", Country = c1 }); //db.Countries.InsertOnSubmit(new Country() { Name = "Albania" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Algeria" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Andorra" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Angola" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Argentina" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Armenia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Australia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Austria" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Bangladesh" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Barbados" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Belarus" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Belgium" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Belize" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Bolivia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Bosnia and Herzegovina" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Brazil" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Bulgaria" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Cambodia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Cameroon" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Canada" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Chile" }); //db.Countries.InsertOnSubmit(new Country() { Name = "China" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Colombia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Costa Rica" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Croatia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Cuba" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Cyprus" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Czech Republic" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Denmark" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Ecuador" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Egypt" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Estonia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Fiji" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Finland" }); //db.Countries.InsertOnSubmit(new Country() { Name = "France" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Georgia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Germany" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Ghana" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Greece" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Grenada" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Hungary" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Iceland" }); //db.Countries.InsertOnSubmit(new Country() { Name = "India" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Indonesia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Ireland" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Israel" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Italy" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Jamaica" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Japan" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Jordan" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Kenya" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Korea, South" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Kuwait" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Latvia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Lebanon" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Liberia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Liechtenstein" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Lithuania" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Luxembourg" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Macedonia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Malaysia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Malta" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Mauritius" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Mexico" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Moldova" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Monaco" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Mongolia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Montenegro" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Morocco" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Mozambique" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Myanmar (Burma)" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Netherlands" }); //db.Countries.InsertOnSubmit(new Country() { Name = "New Zealand" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Nigeria" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Norway" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Oman" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Pakistan" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Panama" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Paraguay" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Peru" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Philippines" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Poland" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Portugal" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Romania" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Russia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Saint Kitts and Nevis" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Saint Lucia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Saint Vincent and the Grenadines" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Samoa" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Senegal" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Serbia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Singapore" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Slovakia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Slovenia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "South Africa" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Spain" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Sri Lanka" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Sudan" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Sweden" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Switzerland" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Thailand" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Togo" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Tonga" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Trinidad and Tobago" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Tunisia" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Turkey" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Uganda" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Ukraine" }); //db.Countries.InsertOnSubmit(new Country() { Name = "United Arab Emirates" }); //db.Countries.InsertOnSubmit(new Country() { Name = "United States" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Uruguay" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Venezuela" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Vietnam" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Yemen" }); //db.Countries.InsertOnSubmit(new Country() { Name = "Zambia" }); // Save categories to the database. db.SubmitChanges(); } } }
public UserController(DatingAppContext context) { _context = context; }
/// <summary> /// Default ctor /// </summary> /// <param name="datingAppContext"><see cref="DatingAppContext"/></param> public GroupRepository(DatingAppContext datingAppContext) { _rDatingAppContext = datingAppContext ?? throw new ArgumentNullException(nameof(datingAppContext)); }
public UnityOfWork(DatingAppContext context) { _context = context; Users = new UserRepository(_context); Photos = new PhotoRepository(_context); }
public UserRepository(DatingAppContext ctx) : base(ctx) { this.context = ctx; }
public GenericRepository(DatingAppContext context) { this._context = context; _entitySet = _context.Set <TEntity> (); }
public ValuesRepository(DatingAppContext datingAppContext) { _datingAppContext = datingAppContext; }
public ValuesController(DatingAppContext datingAppContext) { this.datingAppContext = datingAppContext; }