diff options
author | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-26 18:32:16 +0200 |
---|---|---|
committer | Donatas Adamonis <dona0169@edu.easj.dk> | 2017-05-26 18:32:16 +0200 |
commit | d4ccb42366044c86d54fbbdefae491d436b7cf42 (patch) | |
tree | e9283bce51240f9d165cc5000d05b7971e010d17 | |
parent | 8e8f14bcd7e7a6d30535e65e4b73506fb353c535 (diff) |
final version of Defect comments
9 files changed, 182 insertions, 152 deletions
diff --git a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs index 52310cc..52849aa 100644 --- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -12,6 +13,7 @@ using Newtonsoft.Json; using Windows.Storage; using ApartmentManager.Common; using Windows.Storage.Pickers; +using ApartmentManager.Singletons; using ApartmentManager.View; namespace ApartmentManager.Handler @@ -32,10 +34,16 @@ namespace ApartmentManager.Handler public void GetApartment() { - string serializedApartment = ApiClient.GetData("api/Apartments/" + ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId); - - Apartment apartment = JsonConvert.DeserializeObject<Apartment>(serializedApartment); - ApartmentViewModel.CatalogSingleton.Apartment = apartment; + try + { + string serializedApartment = ApiClient.GetData("api/Apartments/" + ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId); + Apartment apartment = JsonConvert.DeserializeObject<Apartment>(serializedApartment); + ApartmentViewModel.CatalogSingleton.Apartment = apartment; + } + catch (Exception e) + { + new MessageDialog(e.Message).ShowAsync(); + } } /// <summary> @@ -43,17 +51,19 @@ namespace ApartmentManager.Handler /// </summary> public void GetApartmentResidents() { - Resident resident = new Resident(); - resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; - - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); - IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); - - ApartmentViewModel.CatalogSingleton.Residents.Clear(); - ApartmentViewModel.NewResident = new Resident(); - foreach (var resident2 in residentlist) + try { - ApartmentViewModel.CatalogSingleton.Residents.Add(resident2); + var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + UserSingleton.Instance.CurrentUser.ApartmentId); + var residentlist = JsonConvert.DeserializeObject<ObservableCollection<Resident>>(residentsFromDatabase); + ApartmentViewModel.CatalogSingleton.Residents.Clear(); + foreach (var resident in residentlist) + { + ApartmentViewModel.CatalogSingleton.Residents.Add(resident); + } + } + catch (Exception e) + { + new MessageDialog(e.Message).ShowAsync(); } } @@ -62,21 +72,18 @@ namespace ApartmentManager.Handler { try { - Resident resident = new Resident(); - resident = ApartmentViewModel.NewResident; - resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; - - ApiClient.PostData("api/residents/", resident); - - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); - IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); - ApartmentViewModel.CatalogSingleton.Residents.Clear(); - ApartmentViewModel.NewResident = new Resident(); - foreach (var resident2 in residentlist) + Resident resident = ApartmentViewModel.NewResident ?? new Resident(); + resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; + if (string.IsNullOrEmpty(resident.Picture)) { - ApartmentViewModel.CatalogSingleton.Residents.Add(resident2); + resident.Picture = "http://i.imgur.com/8KNkU26.png"; } + if (!string.IsNullOrEmpty(resident.FirstName) && !string.IsNullOrEmpty(resident.FirstName)) + { + ApiClient.PostData("api/residents/", resident); + } + GetApartmentResidents(); } catch (Exception e) { @@ -88,21 +95,11 @@ namespace ApartmentManager.Handler { try { - Resident resident = new Resident(); - resident = ApartmentViewModel.NewResident; + Resident resident = ApartmentViewModel.NewResident ?? new Resident(); resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; ApiClient.DeleteData("api/residents/" + resident.ResidentId); - - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); - IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); - - ApartmentViewModel.CatalogSingleton.Residents.Clear(); - ApartmentViewModel.NewResident = new Resident(); - foreach (var resident2 in residentlist) - { - ApartmentViewModel.CatalogSingleton.Residents.Add(resident2); - } + GetApartmentResidents(); } catch (Exception e) { @@ -114,20 +111,11 @@ namespace ApartmentManager.Handler { try { - Resident resident = new Resident(); - resident = ApartmentViewModel.NewResident; + Resident resident = ApartmentViewModel.NewResident ?? new Resident(); resident.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; ApiClient.PutData("api/residents/" + resident.ResidentId, resident); - var residentsFromDatabase = ApiClient.GetData("api/ApartmentResidents/" + resident.ApartmentId); - IEnumerable<Resident> residentlist = JsonConvert.DeserializeObject<IEnumerable<Resident>>(residentsFromDatabase); - - ApartmentViewModel.CatalogSingleton.Residents.Clear(); - ApartmentViewModel.NewResident = new Resident(); - foreach (var resident2 in residentlist) - { - ApartmentViewModel.CatalogSingleton.Residents.Add(resident2); - } + GetApartmentResidents(); } catch (Exception e) { @@ -146,6 +134,7 @@ namespace ApartmentManager.Handler } catch (Exception e) { + new MessageDialog(e.Message).ShowAsync(); } } /// <summary> @@ -157,10 +146,10 @@ namespace ApartmentManager.Handler try { ApartmentViewModel.UserSingleton.CurrentUser.Picture = await ImgurPhotoUploader.UploadPhotoAsync(); - } catch (Exception e) { + new MessageDialog(e.Message).ShowAsync(); } } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -168,8 +157,7 @@ namespace ApartmentManager.Handler { try { - User user = new User(); - user = ApartmentViewModel.UserSingleton.CurrentUser; + User user = ApartmentViewModel.UserSingleton.CurrentUser ?? new User(); ApiClient.PutData("api/users/" + user.Username, user); } catch (Exception e) @@ -182,75 +170,74 @@ namespace ApartmentManager.Handler /// </summary> public void GetApartmentDefects() { - Defect defect = new Defect(); - defect.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; + Defect Defect = new Defect(); + Defect.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; - var defectsFromDatabase = ApiClient.GetData("api/ApartmentDefects/" + defect.ApartmentId); - IEnumerable<Defect> defecttlist = JsonConvert.DeserializeObject<IEnumerable<Defect>>(defectsFromDatabase); + var defectsFromDatabase = ApiClient.GetData("api/ApartmentDefects/" + Defect.ApartmentId); + var defecttlist = JsonConvert.DeserializeObject<ObservableCollection<Defect>>(defectsFromDatabase); - foreach (var qwe in defecttlist) + foreach (var defect in defecttlist) { - var picturesFromDatabase = ApiClient.GetData("api/DefectPictures/" + qwe.DefectId); + var picturesFromDatabase = ApiClient.GetData("api/DefectPictures/" + defect.DefectId); if (picturesFromDatabase != "[]") { - IEnumerable<DefectPicture> picturetlist = JsonConvert.DeserializeObject<IEnumerable<DefectPicture>>(picturesFromDatabase); - ApartmentViewModel.CatalogSingleton.DefectPictures.Clear(); - foreach (var asd in picturetlist) - { - - ApartmentViewModel.CatalogSingleton.DefectPictures.Add(asd); - } - qwe.MainPicture = ApartmentViewModel.CatalogSingleton.DefectPictures[0].Picture; + ApartmentViewModel.CatalogSingleton.DefectPictures = JsonConvert.DeserializeObject<ObservableCollection<DefectPicture>>(picturesFromDatabase); + defect.MainPicture = ApartmentViewModel.CatalogSingleton.DefectPictures[0].Picture; } - - - } - - ApartmentViewModel.CatalogSingleton.Defects.Clear(); - ApartmentViewModel.NewResident = new Resident(); - foreach (var defect2 in defecttlist) - { - ApartmentViewModel.CatalogSingleton.Defects.Add(defect2); } + ApartmentViewModel.CatalogSingleton.Defects = defecttlist; ApartmentViewModel.CatalogSingleton.DefectPictures.Clear(); } /////////////////////////////////////////////////////////////////////////////////////////////////// public void DeleteDefectPicture() { - ApartmentViewModel.CatalogSingleton.DefectPictures.Remove(ApartmentViewModel.SelectedDefectPicture); + try + { + ApartmentViewModel.CatalogSingleton.DefectPictures.Remove(ApartmentViewModel.SelectedDefectPicture); + } + catch (Exception e) + { + new MessageDialog(e.Message).ShowAsync(); + } } public async void UploadDefectPhoto() { try { - ApartmentViewModel.SelectedDefectPicture = new DefectPicture(); - ApartmentViewModel.SelectedDefectPicture.Picture = await ImgurPhotoUploader.UploadPhotoAsync(); ApartmentViewModel.CatalogSingleton.DefectPictures.Add(ApartmentViewModel.SelectedDefectPicture); } catch (Exception e) { + new MessageDialog(e.Message).ShowAsync(); } } /////////////////////////////////////////////////////////////////////////////////////////////////// public void CreateDefect() { - Defect defect = new Defect(); - defect = ApartmentViewModel.NewDefect; - defect.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; - defect.Status = "New"; - defect.UploadDate = DateTime.Now; + try + { + Defect defect = ApartmentViewModel.NewDefect; + defect.ApartmentId = ApartmentViewModel.UserSingleton.CurrentUser.ApartmentId; + defect.Status = "New"; + defect.UploadDate = DateTime.Now; - var response = ApiClient.PostData("api/defects/", defect); - var defectResponse = JsonConvert.DeserializeObject<Defect>(response); - defect.DefectId = defectResponse.DefectId; + var response = ApiClient.PostData("api/defects/", defect); + var defectResponse = JsonConvert.DeserializeObject<Defect>(response); + defect.DefectId = defectResponse.DefectId; - foreach (var picture in ApartmentViewModel.CatalogSingleton.DefectPictures) + foreach (var picture in ApartmentViewModel.CatalogSingleton.DefectPictures) + { + picture.DefectId = defect.DefectId; + ApiClient.PostData("api/defectpictures/", picture); + } + GetApartmentDefects(); + } + catch (Exception e) { - picture.DefectId = defect.DefectId; - ApiClient.PostData("api/defectpictures/", picture); + new MessageDialog(e.Message).ShowAsync(); } - GetApartmentDefects(); + } /////////////////////////////////////////////////////////////////////////////////////////////////// public bool CreateDefect_CanExecute() @@ -263,29 +250,49 @@ namespace ApartmentManager.Handler /////////////////////////////////////////////////////////////////////////////////////////////////// public void GetDefectInfo() { - var id = ApartmentViewModel.NewDefect.DefectId; - Defect defect = new Defect(); - defect.DefectId = id; - - var defectFromDatabase = ApiClient.GetData("api/defects/" + defect.DefectId); - var defect2 = JsonConvert.DeserializeObject<Defect>(defectFromDatabase); - ApartmentViewModel.CatalogSingleton.Defect = defect2; - - var picturesFromDatabase = ApiClient.GetData("api/DefectPictures/" + defect.DefectId); - ApartmentViewModel.CatalogSingleton.DefectPictures2.Clear(); - if (picturesFromDatabase != "[]") + try + { + var defectFromDatabase = ApiClient.GetData("api/defects/" + ApartmentViewModel.NewDefect.DefectId); + ApartmentViewModel.CatalogSingleton.Defect = JsonConvert.DeserializeObject<Defect>(defectFromDatabase); + var picturesFromDatabase = ApiClient.GetData("api/DefectPictures/" + ApartmentViewModel.NewDefect.DefectId); + ApartmentViewModel.CatalogSingleton.DefectPictures = JsonConvert.DeserializeObject<ObservableCollection<DefectPicture>>(picturesFromDatabase); + var defectComments = ApiClient.GetData("api/Defectcomments/" + ApartmentViewModel.NewDefect.DefectId); + ApartmentViewModel.CatalogSingleton.DefectComments = JsonConvert.DeserializeObject<ObservableCollection<DefectComments>>(defectComments); + CatalogSingleton.Instance.DefectId = ApartmentViewModel.NewDefect.DefectId; + } + catch (Exception e) + { + new MessageDialog(e.Message).ShowAsync(); + } + + } + /////////////////////////////////////////////////////////////////////////////////////////////////// + public void CreateDefectComment() + { + try { - IEnumerable<DefectPicture> picturetlist = - JsonConvert.DeserializeObject<IEnumerable<DefectPicture>>(picturesFromDatabase); - foreach (var asd in picturetlist) + DefectComments Comment = new DefectComments(); + Comment.Comment = ApartmentViewModel.NewDefectComment.Comment; + Comment.DefectId = CatalogSingleton.Instance.Defect.DefectId; + Comment.Name = UserSingleton.Instance.CurrentUser.FirstName + " " + UserSingleton.Instance.CurrentUser.LastName; + Comment.Date = DateTimeOffset.Now; + if (!string.IsNullOrEmpty(Comment.Comment)) { - - ApartmentViewModel.CatalogSingleton.DefectPictures2.Add(asd); + ApiClient.PostData("api/Defectcomments/", Comment); + } + var response = ApiClient.GetData("api/Defectcomments/" + CatalogSingleton.Instance.DefectId); + var commentlist = JsonConvert.DeserializeObject<ObservableCollection<DefectComments>>(response); + CatalogSingleton.Instance.DefectComments.Clear(); + foreach (var comment in commentlist) + { + CatalogSingleton.Instance.DefectComments.Add(comment); } } + catch (Exception e) + { + new MessageDialog(e.Message).ShowAsync(); + } } /////////////////////////////////////////////////////////////////////////////////////////////////// - - } } diff --git a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs index a14c7d5..39f352e 100644 --- a/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/CatalogSingleton.cs @@ -7,7 +7,7 @@ using ApartmentManager.Model; namespace ApartmentManager.Singletons { - public class CatalogSingleton : INotifyPropertyChanged + public class CatalogSingleton { private static CatalogSingleton instance = new CatalogSingleton(); @@ -16,41 +16,20 @@ namespace ApartmentManager.Singletons public Apartment Apartment { get; set; } public ObservableCollection<Resident> Residents { get; set; } - public ObservableCollection<Defect> defects { get; set; } + public ObservableCollection<Defect> Defects { get; set; } public ObservableCollection<DefectPicture> DefectPictures { get; set; } - public ObservableCollection<DefectPicture> DefectPictures2 { get; set; } + public int DefectId { get; set; } + public ObservableCollection<DefectComments> DefectComments { get; set; } public Defect Defect { get; set; } - private CatalogSingleton() { DefectComments = new ObservableCollection<DefectComments>(); - DefectComments.Add(new DefectComments( ){Date = DateTimeOffset.Now, Comment = "Comment",CommentId = 1,DefectId = 1,Name = "Name"} ); - DefectComments.Add(new DefectComments() { Date = DateTimeOffset.Now, Comment = "Comment", CommentId = 1, DefectId = 1, Name = "Name" }); - DefectComments.Add(new DefectComments() { Date = DateTimeOffset.Now, Comment = "Comment", CommentId = 1, DefectId = 1, Name = "Name" }); - DefectComments.Add(new DefectComments() { Date = DateTimeOffset.Now, Comment = "Comment", CommentId = 1, DefectId = 1, Name = "Name" }); Residents = new ObservableCollection<Resident>(); - defects = new ObservableCollection<Defect>(); + Defects = new ObservableCollection<Defect>(); DefectPictures = new ObservableCollection<DefectPicture>(); - DefectPictures2 = new ObservableCollection<DefectPicture>(); - } - public ObservableCollection<Defect> Defects - { - get => this.defects; - set - { - this.defects = value; - OnPropertyChanged(nameof(Defect)); - - } - } - - public event PropertyChangedEventHandler PropertyChanged; - - [NotifyPropertyChangedInvocator] - protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } } diff --git a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml index 2c7e322..406cb8c 100644 --- a/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml +++ b/ApartmentManager/ApartmentManager/View/ApartmentDefectViewPage.xaml @@ -23,7 +23,7 @@ </StackPanel> <StackPanel Orientation="Horizontal" Margin="20,0,20,20"> <StackPanel Width="620" Margin="0,50,0,0"> - <GridView ItemsSource="{Binding CatalogSingleton.DefectPictures2, Mode=TwoWay}" Height="420" Width="500" > + <GridView ItemsSource="{Binding CatalogSingleton.DefectPictures, Mode=TwoWay}" Height="420" Width="500" > <GridView.ItemTemplate> <DataTemplate> <Image Source="{Binding Picture}" Width="220" Margin="10,0,10,10"></Image> @@ -47,8 +47,8 @@ <TextBlock Text="Comments" FontSize="30" FontWeight="Bold" Margin="10,0,0,10"/> <StackPanel Orientation="Horizontal"> - <TextBox Width="500" Height="80" TextWrapping="Wrap"></TextBox> - <Button Content="Comment" Margin="10,0,0,0"></Button> + <TextBox Width="500" Height="80" TextWrapping="Wrap" Text="{Binding NewDefectComment.Comment, Mode=TwoWay}"></TextBox> + <Button Content="Comment" Margin="10,0,0,0" Command="{Binding CreateDefectComment}"></Button> </StackPanel> @@ -61,13 +61,24 @@ <ListView.ItemTemplate> <DataTemplate> - <Grid Height="150" Margin="0,10,0,10"> + <Grid Margin="10"> <StackPanel> - <TextBlock Text="Full Name" FontWeight="Bold" Margin="5,0,0,0"></TextBlock> - <TextBlock Height="90" Margin="5" TextWrapping="WrapWholeWords" Text="Žmonija sparčiai naudoja Žemės naudingųjų iškasenų atsargas. Mokslininkai mus perspėja - jei taip ir toliau, kai kurių dalykų greitai pradės trūksti. Tiesa, dažniausiai taip kalbama apie naftą, nors, kaip ima aiškėti, greitai pritrūksime kur kas paprastesnės medžiagos."></TextBlock> - <TextBlock Text="Comment Date" HorizontalAlignment="Right" Margin="5" FontWeight="Bold"></TextBlock> + <TextBlock Text="{Binding Name}" FontWeight="Bold" Margin="5,0,0,0"></TextBlock> + <TextBlock Margin="5" TextWrapping="WrapWholeWords" Text="{Binding Comment}"></TextBlock> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> + <TextBlock Margin="0,0,0,5"> + <Run Text="{Binding Date.Year}" FontWeight="Bold"/> + <Run Text="-" FontWeight="Bold"/> + <Run Text="{Binding Date.Month}" FontWeight="Bold"/> + <Run Text="-" FontWeight="Bold"/> + <Run Text="{Binding Date.Day}" FontWeight="Bold"/> + <Run Text=" " FontWeight="Bold"/> + <Run Text="{Binding Date.Hour}" FontWeight="Bold"/> + <Run Text=":" FontWeight="Bold"/> + <Run Text="{Binding Date.Minute}" FontWeight="Bold"/> + </TextBlock> + </StackPanel> </StackPanel> - </Grid> </DataTemplate> </ListView.ItemTemplate> diff --git a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs index dad140a..9c1542b 100644 --- a/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs +++ b/ApartmentManager/ApartmentManager/ViewModel/ApartmentViewModel.cs @@ -24,8 +24,9 @@ namespace ApartmentManager.ViewModel private User _newUser; private Resident _newResident; - private Defect _newDefect; + private Defect _newDefect = new Defect(); private DefectPicture _selectedDefectPicture; + private DefectComments _newDefectComment; @@ -43,12 +44,13 @@ namespace ApartmentManager.ViewModel public ICommand UploadDefectPicture { get; set; } public ICommand CreateDefect { get; set; } public ICommand DefectInfo { get; set; } - + public ICommand CreateDefectComment { get; set; } public ApartmentViewModel() { NewUser = new User(); NewResident = new Resident(); - NewDefect = new Defect(); + //NewDefect = new Defect(); + NewDefectComment = new DefectComments(); SelectedDefectPicture = new DefectPicture(); ApartmentHandler = new ApartmentHandler(this); @@ -68,10 +70,19 @@ namespace ApartmentManager.ViewModel UploadDefectPicture = new RelayCommand(ApartmentHandler.UploadDefectPhoto); DeleteDefectPicture = new RelayCommand(ApartmentHandler.DeleteDefectPicture); CreateDefect = new RelayCommand(ApartmentHandler.CreateDefect, ApartmentHandler.CreateDefect_CanExecute); - DefectInfo = new RelayCommand(ApartmentHandler.GetDefectInfo); + DefectInfo = new RelayCommand(ApartmentHandler.GetDefectInfo); + CreateDefectComment = new RelayCommand(ApartmentHandler.CreateDefectComment); } - + public DefectComments NewDefectComment + { + get => _newDefectComment; + set + { + _newDefectComment = value; + OnPropertyChanged(); + } + } public Defect NewDefect { get => _newDefect; diff --git a/ApartmentManager/HousingWebApi/Controllers/DefectCommentsController.cs b/ApartmentManager/HousingWebApi/Controllers/DefectCommentsController.cs index a4fc8e8..8174962 100644 --- a/ApartmentManager/HousingWebApi/Controllers/DefectCommentsController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/DefectCommentsController.cs @@ -16,10 +16,13 @@ namespace HousingWebApi.Controllers { private DataModel db = new DataModel(); - // GET: api/DefectComments - public IQueryable<DefectComment> GetDefectComments() + [Route("api/DefectComments/{id}")] + public IQueryable<DefectComment> GetDefectComments(int id) { - return db.DefectComments; + var commentlist = from defectComment in db.DefectComments + where (defectComment.DefectId == id) + orderby defectComment.CommentId descending select defectComment; + return commentlist; } // GET: api/DefectComments/5 diff --git a/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs b/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs index 1ec5ca3..587805f 100644 --- a/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs +++ b/ApartmentManager/HousingWebApi/Controllers/DefectsController.cs @@ -21,6 +21,7 @@ namespace HousingWebApi.Controllers { var defectlist = from defect in db.Defects where (defect.ApartmentId == id) + orderby defect.DefectId descending select defect; return defectlist; } diff --git a/ApartmentManager/HousingWebApi/DataModel.cs b/ApartmentManager/HousingWebApi/DataModel.cs index 64826a3..78fd1f2 100644 --- a/ApartmentManager/HousingWebApi/DataModel.cs +++ b/ApartmentManager/HousingWebApi/DataModel.cs @@ -86,6 +86,10 @@ namespace HousingWebApi .Property(e => e.Comment) .IsUnicode(false); + modelBuilder.Entity<ChangeComment>() + .Property(e => e.Name) + .IsUnicode(false); + modelBuilder.Entity<ChangeDocument>() .Property(e => e.Document) .IsUnicode(false); @@ -116,6 +120,10 @@ namespace HousingWebApi .Property(e => e.Comment) .IsUnicode(false); + modelBuilder.Entity<DefectComment>() + .Property(e => e.Name) + .IsUnicode(false); + modelBuilder.Entity<DefectPicture>() .Property(e => e.Picture) .IsUnicode(false); diff --git a/ApartmentManager/HousingWebApi/Models/ChangeComment.cs b/ApartmentManager/HousingWebApi/Models/ChangeComment.cs index 3c5d8d8..b8ee58e 100644 --- a/ApartmentManager/HousingWebApi/Models/ChangeComment.cs +++ b/ApartmentManager/HousingWebApi/Models/ChangeComment.cs @@ -17,6 +17,11 @@ namespace HousingWebApi public string Comment { get; set; } + [StringLength(50)] + public string Name { get; set; } + + public DateTime? Date { get; set; } + public virtual ApartmentChange ApartmentChange { get; set; } } } diff --git a/ApartmentManager/HousingWebApi/Models/DefectComment.cs b/ApartmentManager/HousingWebApi/Models/DefectComment.cs index c65bac2..41733aa 100644 --- a/ApartmentManager/HousingWebApi/Models/DefectComment.cs +++ b/ApartmentManager/HousingWebApi/Models/DefectComment.cs @@ -16,6 +16,11 @@ namespace HousingWebApi public string Comment { get; set; } + [StringLength(50)] + public string Name { get; set; } + + public DateTime? Date { get; set; } + public virtual Defect Defect { get; set; } } } |