diff options
author | marcinzelent <marcin@zelent.net> | 2017-05-06 18:17:19 +0200 |
---|---|---|
committer | marcinzelent <marcin@zelent.net> | 2017-05-06 18:17:19 +0200 |
commit | a49c1d4f2ab03baa3a8fc48c6965473594848c4c (patch) | |
tree | 8c5d4f400a6187d64c7b42f3897056c97f70f352 | |
parent | efc710fd68fcd3d2616223398fe70391243eea77 (diff) |
Finished login system.
18 files changed, 260 insertions, 141 deletions
diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj index 5f4f7da..086b0da 100644 --- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj +++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj @@ -12,7 +12,7 @@ <DefaultLanguage>en-US</DefaultLanguage> <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier> <TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.14393.0</TargetPlatformVersion> - <TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion> + <TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion> <MinimumVisualStudioVersion>14</MinimumVisualStudioVersion> <FileAlignment>512</FileAlignment> <ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> @@ -101,14 +101,16 @@ <Compile Include="Common\RelayCommand.cs" /> <Compile Include="Controls\NavMenuListView.cs" /> <Compile Include="Handler\BoardApartmentsHandler.cs" /> + <Compile Include="Handler\LoginHandler.cs" /> <Compile Include="Handler\ResidentsHandler.cs" /> <Compile Include="Model\Apartment.cs" /> - <Compile Include="Model\ApartmentsCatalogSingleton.cs" /> + <Compile Include="Singletons\ApartmentsCatalogSingleton.cs" /> <Compile Include="Model\Defect.cs" /> <Compile Include="Model\NavMenuItem.cs" /> - <Compile Include="Model\CatalogSingleton.cs" /> + <Compile Include="Singletons\CatalogSingleton.cs" /> <Compile Include="Model\Resident.cs" /> <Compile Include="Model\User.cs" /> + <Compile Include="Singletons\UserSingleton.cs" /> <Compile Include="Persistency\ApiClient.cs" /> <Compile Include="Persistency\PersistenceFacade.cs" /> <Compile Include="Properties\Annotations.cs" /> @@ -145,11 +147,6 @@ </Compile> </ItemGroup> <ItemGroup> - <AppxManifest Include="Package.appxmanifest"> - <SubType>Designer</SubType> - </AppxManifest> - </ItemGroup> - <ItemGroup> <Content Include="Assets\BrokenDownpipe.jpg" /> <Content Include="Assets\Person1.jpg" /> <Content Include="Assets\Person2.jpg" /> @@ -222,10 +219,21 @@ <Version>5.3.3</Version> </PackageReference> </ItemGroup> - <ItemGroup /> + <ItemGroup> + <AppxManifest Include="Package.appxmanifest"> + <SubType>Designer</SubType> + </AppxManifest> + </ItemGroup> <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' "> <VisualStudioVersion>14.0</VisualStudioVersion> </PropertyGroup> + <PropertyGroup> + <SignAssembly>true</SignAssembly> + </PropertyGroup> + <PropertyGroup> + <AssemblyOriginatorKeyFile> + </AssemblyOriginatorKeyFile> + </PropertyGroup> <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/ApartmentManager/ApartmentManager/AppShell.xaml b/ApartmentManager/ApartmentManager/AppShell.xaml index e775b93..7f374de 100644 --- a/ApartmentManager/ApartmentManager/AppShell.xaml +++ b/ApartmentManager/ApartmentManager/AppShell.xaml @@ -7,7 +7,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:model="using:ApartmentManager.Model" - xmlns:viewModel="using:ApartmentManager.ViewModel" + xmlns:vm="using:ApartmentManager.ViewModel" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" TabNavigation="Cycle" mc:Ignorable="d"> @@ -71,12 +71,10 @@ <ColumnDefinition Width="200"/> </Grid.ColumnDefinitions> - <Image Grid.Column="0" Source="/Assets/Images/fvacanceslogo.png" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="200,5,0,5" Height="40" /> - <StackPanel x:Name="StackPanel1" Grid.Column="1" Orientation="Horizontal"> - <AppBarButton Icon="AddFriend" Label="Sign up" Style="{StaticResource SignButtonStyle}" Width="Auto"/> - <AppBarButton Icon="Contact" Label="Sign in" Style="{StaticResource SignButtonStyle}" Width="Auto"/> - </StackPanel> - <StackPanel x:Name="StackPanel2" Grid.Column="1" Orientation="Horizontal" Visibility="Collapsed"> + <StackPanel x:Name="LoginBar" Grid.Column="1" Orientation="Horizontal"> + <StackPanel.DataContext> + <vm:LoginViewModel/> + </StackPanel.DataContext> <AppBarButton Icon="Contact" Label="My account" Style="{StaticResource SignButtonStyle}" Width="Auto"/> <AppBarButton Icon="Sync" Label="Logout" Style="{StaticResource SignButtonStyle}" Width="Auto" Command="{Binding LogOutCommand}"/> </StackPanel> diff --git a/ApartmentManager/ApartmentManager/AppShell.xaml.cs b/ApartmentManager/ApartmentManager/AppShell.xaml.cs index d3c0ca2..5ccff1c 100644 --- a/ApartmentManager/ApartmentManager/AppShell.xaml.cs +++ b/ApartmentManager/ApartmentManager/AppShell.xaml.cs @@ -135,17 +135,5 @@ namespace ApartmentManager { TogglePaneButton.IsChecked = true; } - - public void MakeStackPanel1Visible() - { - StackPanel1.Visibility = Visibility.Visible; - StackPanel2.Visibility = Visibility.Collapsed; - } - - public void MakeStackPanel2Visible() - { - StackPanel1.Visibility = Visibility.Collapsed; - StackPanel2.Visibility = Visibility.Visible; - } } }
\ No newline at end of file diff --git a/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs new file mode 100644 index 0000000..a91fc2b --- /dev/null +++ b/ApartmentManager/ApartmentManager/Handler/LoginHandler.cs @@ -0,0 +1,36 @@ +using ApartmentManager.Model; +using ApartmentManager.Persistency; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ApartmentManager.Handler +{ + public static class LoginHandler + { + public static void LogIn(string username, string password) + { + + string serializedUser = ApiClient.GetData($"api/Users/by-username/{username}"); + if (serializedUser != null) + { + User user = JsonConvert.DeserializeObject<User>(serializedUser); + if (user.Password == password) + { + UserSingleton.CurrentUser = user; + } + else throw new Exception("Wrong password!"); + } + else throw new Exception("Wrong username!"); + + } + + public static void LogOut() + { + UserSingleton.CurrentUser = null; + } + } +} diff --git a/ApartmentManager/ApartmentManager/Model/User.cs b/ApartmentManager/ApartmentManager/Model/User.cs index d9591ab..65fd778 100644 --- a/ApartmentManager/ApartmentManager/Model/User.cs +++ b/ApartmentManager/ApartmentManager/Model/User.cs @@ -9,27 +9,28 @@ namespace ApartmentManager.Model { public class User { - public string Name { get; set; } + public int ApartmentNr { get; set; } + public string Username { get; set; } + public string Password { get; set; } + public string Type { get; set; } + public string FirstName { get; set; } public string LastName { get; set; } - public int Phone { get; set; } public DateTime BirthDate { get; set; } + public string Phone { get; set; } public string Email { get; set; } public Image Picture { get; set; } - public int ApartmentNr { get; set; } public string SecondName { get; set; } public string SecondLastName { get; set; } public string SecondBirthDate { get; set; } public string SecondPhone { get; set; } public string SecondEmail { get; set; } - public string Username { get; set; } - public string Password { get; set; } public User() { } - public User(string Name, string LastName, int Phone, DateTime BirthDate, string Email, int ApartmentNr) + public User(string FirstName, string LastName, string Phone, DateTime BirthDate, string Email, int ApartmentNr) { - this.Name = Name; + this.FirstName = FirstName; this.LastName = LastName; this.Phone = Phone; this.BirthDate = BirthDate; @@ -40,7 +41,7 @@ namespace ApartmentManager.Model public override string ToString() { - return string.Format($"Name {Name} LastName {LastName} Phone {Phone}"); + return string.Format($"First name {FirstName} Last name {LastName} Phone {Phone}"); } } diff --git a/ApartmentManager/ApartmentManager/Model/ApartmentsCatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/ApartmentsCatalogSingleton.cs index f19d776..c65c241 100644 --- a/ApartmentManager/ApartmentManager/Model/ApartmentsCatalogSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/ApartmentsCatalogSingleton.cs @@ -23,7 +23,7 @@ namespace ApartmentManager.Model private ApartmentsCatalogSingleton() { User = new ObservableCollection<User>(); - User.Add(new User("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 2, 27, 0), "Bibis@mail.com", 1)); + User.Add(new User("Bibis", "Kiausiai", "3214568", new DateTime(2017, 1, 5, 2, 27, 0), "Bibis@mail.com", 1)); Apartment = new ObservableCollection<Apartment>(); Apartment.Add(new Apartment(1, "30 Square meters", 2, "200", 0, "adresas")); diff --git a/ApartmentManager/ApartmentManager/Model/CatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs index 346d652..3a4c706 100644 --- a/ApartmentManager/ApartmentManager/Model/CatalogSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs @@ -19,7 +19,7 @@ namespace ApartmentManager.Model private CatalogSingleton() { User = new ObservableCollection<User>(); - User.Add(new User("Bibis", "Kiausiai", 3214568, new DateTime(2017, 1, 5, 2, 27, 0), "Bibis@mail.com", 1)); + User.Add(new User("Bibis", "Kiausiai", "3214568", new DateTime(2017, 1, 5, 2, 27, 0), "Bibis@mail.com", 1)); Apartment = new ObservableCollection<Apartment>(); Apartment.Add(new Apartment(1,"30 Square meters",2,"200",0,"adresas")); Residents = new ObservableCollection<Resident>(); diff --git a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs new file mode 100644 index 0000000..aa09cf2 --- /dev/null +++ b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ApartmentManager.Model +{ + class UserSingleton + { + private static UserSingleton instance; + public static User CurrentUser; + + private UserSingleton() { } + + public static UserSingleton Instance + { + get + { + if (instance == null) + { + instance = new UserSingleton(); + } + return instance; + } + } + } +} diff --git a/ApartmentManager/ApartmentManager/View/LoginPage.xaml b/ApartmentManager/ApartmentManager/View/LoginPage.xaml index 80071d1..fc9c463 100644 --- a/ApartmentManager/ApartmentManager/View/LoginPage.xaml +++ b/ApartmentManager/ApartmentManager/View/LoginPage.xaml @@ -5,15 +5,20 @@ xmlns:local="using:ApartmentManager.View" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:vm="using:ApartmentManager.ViewModel" mc:Ignorable="d"> + <Page.DataContext> + <vm:LoginViewModel/> + </Page.DataContext> + <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Height="200" Width="300"> - <TextBlock Margin="0,10,0,10" Text="User Name"></TextBlock> - <TextBox ></TextBox> - <TextBlock Margin="0,10,0,10" Text="Password"></TextBlock> - <TextBox ></TextBox> - <Button Margin="0,10,0,10" Content="Log In" HorizontalAlignment="Stretch" Click="click"></Button> + <TextBlock Margin="0,10,0,10" Text="Username"/> + <TextBox Text="{Binding Username, Mode=TwoWay}"/> + <TextBlock Margin="0,10,0,10" Text="Password"/> + <PasswordBox Password="{Binding Password, Mode=TwoWay}"/> + <Button x:Name="LogInButton" Margin="0,10,0,10" Content="Log In" HorizontalAlignment="Stretch" Command="{Binding LogInCommand}" Click="LogInButton_Click"/> </StackPanel> </Grid> </Page> diff --git a/ApartmentManager/ApartmentManager/View/LoginPage.xaml.cs b/ApartmentManager/ApartmentManager/View/LoginPage.xaml.cs index 4bb12ec..73d6bd7 100644 --- a/ApartmentManager/ApartmentManager/View/LoginPage.xaml.cs +++ b/ApartmentManager/ApartmentManager/View/LoginPage.xaml.cs @@ -1,24 +1,10 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; +using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; - -// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 namespace ApartmentManager.View { /// <summary> - /// An empty page that can be used on its own or navigated to within a Frame. + /// Page used to login to the Apartment Manager /// </summary> public sealed partial class LoginPage : Page { @@ -27,34 +13,9 @@ namespace ApartmentManager.View this.InitializeComponent(); } - private void click(object sender, RoutedEventArgs e) + private void LogInButton_Click(object sender, RoutedEventArgs e) { - AppShell appShell = Window.Current.Content as AppShell; - - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active - if (appShell == null) - { - // Create a AppShell to act as the navigation context and navigate to the first page - appShell = new AppShell(); - - // Set the default language - appShell.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; - - } - - // Place our app shell in the current Window - Window.Current.Content = appShell; - - if (appShell.AppFrame.Content == null) - { - // When the navigation stack isn't restored, navigate to the first page - // suppressing the initial entrance animation. - appShell.AppFrame.Navigate(typeof(BoardMembersPage)); - } - - // Ensure the current window is active - Window.Current.Activate(); + } } } diff --git a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs index 51dabb5..9f1d7f7 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/LoginViewModel.cs @@ -1,13 +1,102 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using ApartmentManager.Annotations; +using ApartmentManager.Common; +using ApartmentManager.Handler; +using ApartmentManager.Model; +using ApartmentManager.View; +using System; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Windows.Input; +using Windows.UI.Popups; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; namespace ApartmentManager.ViewModel { - class LoginViewModel + public class LoginViewModel { + public static string Username { get; set; } + public static string Password { get; set; } + public bool IsPasswordCorrect { get; set; } + public ICommand LogInCommand { get; set; } + public ICommand LogOutCommand { get; set; } + public LoginViewModel() + { + LogInCommand = new RelayCommand(LogIn); + LogOutCommand = new RelayCommand(LogOut); + } + + private void LogIn() + { + try + { + LoginHandler.LogIn(Username, Password); + NavigateToMainPage(); + } + catch(Exception ex) + { + var msg = new MessageDialog(ex.Message); + msg.ShowAsync(); + } + } + + private void LogOut() + { + LoginHandler.LogOut(); + NavigateToLoginPage(); + Username = null; + Password = null; + } + + private void NavigateToMainPage() + { + AppShell appShell = Window.Current.Content as AppShell; + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (appShell == null) + { + // Create a AppShell to act as the navigation context and navigate to the first page + appShell = new AppShell(); + + // Set the default language + appShell.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; + + } + + // Place our app shell in the current Window + Window.Current.Content = appShell; + + if (appShell.AppFrame.Content == null) + { + // When the navigation stack isn't restored, navigate to the first page + // suppressing the initial entrance animation. + if (UserSingleton.CurrentUser.Type == "B") appShell.AppFrame.Navigate(typeof(BoardMembersPage)); + else appShell.AppFrame.Navigate(typeof(ApartmentPage)); + } + + // Ensure the current window is active + Window.Current.Activate(); + } + + private void NavigateToLoginPage() + { + Frame rootFrame = Window.Current.Content as Frame; + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == null) + { + // Create a Frame to act as the navigation context and navigate to the first page + rootFrame = new Frame(); + + // Place the frame in the current Window + Window.Current.Content = rootFrame; + } + + rootFrame.Navigate(typeof(LoginPage)); + Window.Current.Activate(); + } } } diff --git a/ApartmentManager/HousingWebApi/Controllers/UsersController.cs b/ApartmentManager/HousingWebApi/Controllers/UsersController.cs index af3ac1d..a8c03af 100644 --- a/ApartmentManager/HousingWebApi/Controllers/UsersController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/UsersController.cs @@ -1,14 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Entity; +using System.Data.Entity; using System.Data.Entity.Infrastructure; using System.Linq; using System.Net; -using System.Net.Http; using System.Web.Http; using System.Web.Http.Description; -using HousingWebApi; namespace HousingWebApi.Controllers { @@ -23,18 +18,18 @@ namespace HousingWebApi.Controllers } // GET: api/Users/by-username/username - //[ResponseType(typeof(User))] - //[Route("api/Users/by-username/{username:string}")] - //public IHttpActionResult GetUserByUsername(string username) - //{ - // User user = db.Users.Find(username); - // if (user == null) - // { - // return NotFound(); - // } - - // return Ok(user); - //} + [ResponseType(typeof(User))] + [Route("api/Users/by-username/{username}")] + public IHttpActionResult GetUserByUsername(string username) + { + User user = db.Users.SingleOrDefault(u => u.Username == username); + if (user == null) + { + return NotFound(); + } + + return Ok(user); + } // GET: api/Users/5 [ResponseType(typeof(User))] diff --git a/ApartmentManager/HousingWebApi/DataModel.cs b/ApartmentManager/HousingWebApi/DataModel.cs index b4e7556..6fe5c68 100644 --- a/ApartmentManager/HousingWebApi/DataModel.cs +++ b/ApartmentManager/HousingWebApi/DataModel.cs @@ -71,51 +71,59 @@ namespace HousingWebApi modelBuilder.Entity<Resident>() .Property(e => e.FirstName) - .IsFixedLength(); + .IsUnicode(false); modelBuilder.Entity<Resident>() .Property(e => e.LastName) - .IsFixedLength(); + .IsUnicode(false); modelBuilder.Entity<Resident>() .Property(e => e.Email) - .IsFixedLength(); + .IsUnicode(false); modelBuilder.Entity<User>() .Property(e => e.Username) - .IsFixedLength(); + .IsUnicode(false); modelBuilder.Entity<User>() .Property(e => e.Password) - .IsFixedLength(); + .IsUnicode(false); + + modelBuilder.Entity<User>() + .Property(e => e.Type) + .IsUnicode(false); modelBuilder.Entity<User>() .Property(e => e.FirstName) - .IsFixedLength(); + .IsUnicode(false); modelBuilder.Entity<User>() .Property(e => e.LastName) - .IsFixedLength(); + .IsUnicode(false); modelBuilder.Entity<User>() .Property(e => e.Phone) - .IsFixedLength(); + .IsUnicode(false); modelBuilder.Entity<User>() .Property(e => e.Email) - .IsFixedLength(); + .IsUnicode(false); modelBuilder.Entity<User>() .Property(e => e.SecondName) - .IsFixedLength(); + .IsUnicode(false); modelBuilder.Entity<User>() .Property(e => e.SecondLastName) - .IsFixedLength(); + .IsUnicode(false); + + modelBuilder.Entity<User>() + .Property(e => e.SecondPhone) + .IsUnicode(false); modelBuilder.Entity<User>() .Property(e => e.SecondEmail) - .IsFixedLength(); + .IsUnicode(false); } } } diff --git a/ApartmentManager/HousingWebApi/HousingWebAPI.csproj b/ApartmentManager/HousingWebApi/HousingWebAPI.csproj index f824c8e..63d4995 100644 --- a/ApartmentManager/HousingWebApi/HousingWebAPI.csproj +++ b/ApartmentManager/HousingWebApi/HousingWebAPI.csproj @@ -151,12 +151,12 @@ </Reference> </ItemGroup> <ItemGroup> + <Compile Include="Models\Apartment.cs" /> <Compile Include="Controllers\ApartmentsController.cs" /> <Compile Include="Controllers\DefectsController.cs" /> <Compile Include="Controllers\PastContractOwnersController.cs" /> <Compile Include="Controllers\ResidentsController.cs" /> <Compile Include="Controllers\UsersController.cs" /> - <Compile Include="Models\Apartment.cs" /> <Compile Include="App_Start\BundleConfig.cs" /> <Compile Include="App_Start\FilterConfig.cs" /> <Compile Include="App_Start\RouteConfig.cs" /> @@ -198,8 +198,8 @@ <Compile Include="Models\PastContractOwner.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Models\Resident.cs" /> + <Compile Include="Models\ResidentList.cs" /> <Compile Include="Models\User.cs" /> - <Compile Include="ResidentList.cs" /> </ItemGroup> <ItemGroup> <Content Include="Areas\HelpPage\HelpPage.css" /> @@ -238,7 +238,9 @@ <Content Include="Scripts\modernizr-2.6.2.js" /> <Content Include="Scripts\respond.js" /> <Content Include="Scripts\respond.min.js" /> - <Content Include="Web.config" /> + <Content Include="Web.config"> + <SubType>Designer</SubType> + </Content> <Content Include="Web.Debug.config"> <DependentUpon>Web.config</DependentUpon> </Content> diff --git a/ApartmentManager/HousingWebApi/Models/Resident.cs b/ApartmentManager/HousingWebApi/Models/Resident.cs index 00fc439..a34cf80 100644 --- a/ApartmentManager/HousingWebApi/Models/Resident.cs +++ b/ApartmentManager/HousingWebApi/Models/Resident.cs @@ -9,13 +9,8 @@ namespace HousingWebApi public partial class Resident { [Key] - [Column(Order = 0)] - [DatabaseGenerated(DatabaseGeneratedOption.None)] public int ResidentNr { get; set; } - [Key] - [Column(Order = 1)] - [DatabaseGenerated(DatabaseGeneratedOption.None)] public int ApartmentNr { get; set; } [Required] diff --git a/ApartmentManager/HousingWebApi/ResidentList.cs b/ApartmentManager/HousingWebApi/Models/ResidentList.cs index 1fd4b30..1fd4b30 100644 --- a/ApartmentManager/HousingWebApi/ResidentList.cs +++ b/ApartmentManager/HousingWebApi/Models/ResidentList.cs diff --git a/ApartmentManager/HousingWebApi/Models/User.cs b/ApartmentManager/HousingWebApi/Models/User.cs index bce5318..e260ede 100644 --- a/ApartmentManager/HousingWebApi/Models/User.cs +++ b/ApartmentManager/HousingWebApi/Models/User.cs @@ -8,6 +8,10 @@ namespace HousingWebApi public partial class User { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.None)] + public int ApartmentNr { get; set; } + [Required] [StringLength(15)] public string Username { get; set; } @@ -17,11 +21,15 @@ namespace HousingWebApi public string Password { get; set; } [Required] - [StringLength(15)] + [StringLength(1)] + public string Type { get; set; } + + [Required] + [StringLength(20)] public string FirstName { get; set; } [Required] - [StringLength(15)] + [StringLength(20)] public string LastName { get; set; } [Column(TypeName = "date")] @@ -30,16 +38,12 @@ namespace HousingWebApi [StringLength(12)] public string Phone { get; set; } - [StringLength(26)] + [StringLength(30)] public string Email { get; set; } [Column(TypeName = "image")] public byte[] Picture { get; set; } - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int ApartmentNr { get; set; } - [StringLength(20)] public string SecondName { get; set; } @@ -49,9 +53,10 @@ namespace HousingWebApi [Column(TypeName = "date")] public DateTime? SecondBirthDate { get; set; } - public int? SecondPhone { get; set; } + [StringLength(12)] + public string SecondPhone { get; set; } - [StringLength(25)] + [StringLength(30)] public string SecondEmail { get; set; } public virtual Apartment Apartment { get; set; } diff --git a/ApartmentManager/HousingWebApi/Web.config b/ApartmentManager/HousingWebApi/Web.config index 50e386b..8ea32e7 100644 --- a/ApartmentManager/HousingWebApi/Web.config +++ b/ApartmentManager/HousingWebApi/Web.config @@ -20,7 +20,7 @@ <httpModules> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> </httpModules> - <customErrors mode="Off"/> + <customErrors mode="Off" /> </system.web> <system.webServer> <handlers> @@ -81,5 +81,5 @@ </entityFramework> <connectionStrings> - <add name="DataModel" connectionString="data source=housingdb.database.windows.net;initial catalog=housingdb;persist security info=True;user id=deltaadmin;password=Delta123!;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /></connectionStrings> + <add name="DataModel" connectionString="data source=housingdb.database.windows.net;initial catalog=housingdb;persist security info=True;user id=deltaadmin;password=Delta123!;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.SqlClient" /></connectionStrings> </configuration>
\ No newline at end of file |