Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
2018-app-inutralia
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
inutralia
2018-app-inutralia
Commits
22e5b72e
Commit
22e5b72e
authored
Feb 07, 2019
by
Javier Piris
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_javi' of
http://git.setisl.com/inutraliaapp/2018-app-inutralia
into dev_javi
parents
8b0af342
fc4efc82
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
190 additions
and
92 deletions
+190
-92
Message.cs
inutralia/inutralia.Models/Questions/Message.cs
+13
-5
NewQuestionViewModel.cs
...ia/ViewModels/QuestionsSpecialist/NewQuestionViewModel.cs
+163
-4
PendingReadViewModel.cs
...ia/ViewModels/QuestionsSpecialist/PendingReadViewModel.cs
+4
-4
HistoryView.xaml.cs
inutralia/inutralia/Views/Question/HistoryView.xaml.cs
+1
-1
NewConsultationView.xaml
inutralia/inutralia/Views/Question/NewConsultationView.xaml
+4
-5
NewConsultationView.xaml.cs
...alia/inutralia/Views/Question/NewConsultationView.xaml.cs
+3
-72
PendingReadView.xaml.cs
inutralia/inutralia/Views/Question/PendingReadView.xaml.cs
+2
-1
No files found.
inutralia/inutralia.Models/Questions/Message.cs
View file @
22e5b72e
namespace
inutralia.Models.Questions
{
using
MvvmHelpers
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Converters
;
using
System
;
...
...
@@ -10,6 +9,14 @@
public
class
Message
:
ObservableEntityData
{
public
enum
Estatus
{
Pendiente
,
Respondida_por_cliente
,
Respondida_por_nutricionista
,
Cerrado
};
public
string
StatusImg
=>
imgStatus
[
StateId
];
[
JsonProperty
(
"text"
,
Required
=
Required
.
Always
)]
...
...
@@ -46,7 +53,8 @@
public
int
StateId
{
get
;
set
;
}
[
JsonProperty
(
"status"
,
Required
=
Required
.
Always
)]
public
string
State
{
get
;
set
;
}
[
JsonConverter
(
typeof
(
StringEnumConverter
))]
public
Estatus
State
{
get
;
set
;
}
[
JsonProperty
(
"subject"
,
Required
=
Required
.
Always
)]
public
string
Subject
...
...
@@ -57,11 +65,11 @@
string
_subject
;
string
[]
imgStatus
=
new
string
[
2
]
string
[]
imgStatus
=
new
string
[
4
]
{
"pendiente.png"
,
// 1 - Pendiente de responder
//
"respondida_por_cliente.png", // 2 - Respondida por cliente
//
"respondida_por_nutricionista", // 3- Respondida por nutricionista
"respondida_por_cliente.png"
,
// 2 - Respondida por cliente
"respondida_por_nutricionista"
,
// 3- Respondida por nutricionista
"cerrada"
// 4 - Conversación cerrada
};
}
...
...
inutralia/inutralia/ViewModels/QuestionsSpecialist/NewQuestionViewModel.cs
View file @
22e5b72e
...
...
@@ -3,14 +3,40 @@
using
inutralia.Models.Questions
;
using
MvvmHelpers
;
using
System
;
using
System.Collections.Generic
;
using
System.Net.Http
;
using
System.Threading.Tasks
;
using
System.Windows.Input
;
using
Xamarin.Forms
;
public
class
NewQuestionViewModel
:
BaseViewModel
public
class
NewQuestionViewModel
:
Base
Navigation
ViewModel
{
public
ObservableRangeCollection
<
Message
>
ListMessages
{
get
;
}
public
enum
Estatus
{
Pendiente
=
1
,
Respondida_por_cliente
=
2
,
Respondida_por_nutricionista
=
3
,
Cerrado
=
4
}
public
Estatus
State
=>
(
Estatus
)
Message
?.
StateId
;
public
Message
Message
{
private
set
;
get
;
}
public
ICommand
SendCommand
{
get
;
set
;
}
public
ObservableRangeCollection
<
Message
>
_ListMessages
;
// LOADING LIST
Command
_LoadNewQuestionCommand
;
// UODATE LIST
Command
_RefreshNewQuestionCommand
;
// DELETE LIST
Command
_DeleteNewQuestionCommand
;
public
NewQuestionViewModel
()
{
IsBusy
=
true
;
...
...
@@ -28,11 +54,9 @@
MessageDateTime
=
DateTime
.
Now
};
ListMessages
.
Add
(
message
);
OutText
=
""
;
}
});
IsBusy
=
false
;
...
...
@@ -44,5 +68,140 @@
set
{
SetProperty
(
ref
_outText
,
value
);
}
}
string
_outText
=
string
.
Empty
;
// LIST MESSAGES
public
ObservableRangeCollection
<
Message
>
ListMessages
{
get
{
return
_ListMessages
??
(
_ListMessages
=
new
ObservableRangeCollection
<
Message
>());
}
set
{
_ListMessages
=
value
;
OnPropertyChanged
(
"ListMessages"
);
}
}
// LOAD
public
Command
LoadNewQuestionCommand
{
get
{
return
_LoadNewQuestionCommand
??
(
_LoadNewQuestionCommand
=
new
Command
(
async
()
=>
await
ExecuteLoadNewQuestionCommand
()));
}
}
public
async
Task
ExecuteLoadNewQuestionCommand
()
{
LoadNewQuestionCommand
.
ChangeCanExecute
();
//if (Authorizations.Count < 1)
await
FetchNewQuestion
();
LoadNewQuestionCommand
.
ChangeCanExecute
();
}
// REFRESH
public
Command
RefreshNewQuestionCommand
{
get
{
return
_RefreshNewQuestionCommand
??
(
_RefreshNewQuestionCommand
=
new
Command
(
async
()
=>
await
ExecuteRefreshNewQuestionCommand
()));
}
}
public
async
Task
ExecuteRefreshNewQuestionCommand
()
{
try
{
RefreshNewQuestionCommand
.
ChangeCanExecute
();
await
FetchNewQuestion
();
RefreshNewQuestionCommand
.
ChangeCanExecute
();
}
catch
(
Exception
e
)
{
string
err
=
e
.
Message
;
}
}
// DELETE
public
Command
DeleteNewQuestionCommand
{
get
{
return
_DeleteNewQuestionCommand
??
(
_DeleteNewQuestionCommand
=
new
Command
(
async
(
parameter
)
=>
await
ExecuteDeleteNewQuestionCommand
(
parameter
as
Message
)));
}
}
async
Task
ExecuteDeleteNewQuestionCommand
(
Message
message
)
{
if
(
message
!=
null
)
{
IsBusy
=
true
;
await
App
.
API
.
DeleteItemAsync
(
message
);
await
FetchNewQuestion
();
IsBusy
=
false
;
}
}
// FETCH
async
Task
FetchNewQuestion
()
{
IsBusy
=
true
;
try
{
ListMessages
=
new
ObservableRangeCollection
<
Message
>(
await
App
.
API
.
RefreshListAsync
<
Message
>());
}
catch
(
Exception
e
)
{
string
err
=
e
.
Message
;
}
}
// SAVE MESSAGE
public
async
Task
SaveMessage
(
string
text
)
{
var
q
=
Message
;
HttpMethod
method
=
HttpMethod
.
Post
;
IsBusy
=
true
;
if
(
q
.
Id
<
0
)
{
var
data
=
new
Dictionary
<
string
,
string
>()
{
{
"subject"
,
q
.
Subject
},{
"message"
,
text
}
};
await
App
.
API
.
RawMessage
(
method
,
string
.
Format
(
"messages"
),
data
,
q
);
}
IsBusy
=
false
;
ListMessages
=
new
ObservableRangeCollection
<
Message
>();
}
// UPDATE MESSAGE
public
async
Task
UpdateMessage
()
{
var
q
=
Message
;
HttpMethod
method
=
HttpMethod
.
Post
;
IsBusy
=
true
;
await
App
.
API
.
UpdateItemAsync
(
q
);
if
(
await
App
.
API
.
RefreshItemAsync
(
Message
))
{
Title
=
Message
.
StatusImg
;
OnPropertyChanged
(
"State"
);
}
IsBusy
=
false
;
}
public
bool
IsClosedOrPending
=>
(
State
==
Estatus
.
Pendiente
||
State
==
Estatus
.
Cerrado
||
State
==
Estatus
.
Respondida_por_cliente
||
State
==
Estatus
.
Respondida_por_nutricionista
);
public
bool
MayBeClosed
=>
!
IsClosedOrPending
;
}
}
inutralia/inutralia/ViewModels/QuestionsSpecialist/PendingReadViewModel.cs
View file @
22e5b72e
...
...
@@ -2,7 +2,6 @@
{
using
System
;
using
System.Threading.Tasks
;
using
inutralia.Models
;
using
inutralia.Models.Questions
;
public
class
PendingReadViewModel
:
BaseNavigationViewModel
...
...
@@ -18,7 +17,7 @@
public
PendingReadViewModel
(
Message
message
)
{
Message
=
message
;
Title
=
message
?.
Stat
e
;
Title
=
message
?.
Stat
usImg
;
}
public
PendingReadViewModel
()
{
}
...
...
@@ -33,7 +32,8 @@
public
DateTime
MessageDateTime
=>
(
DateTime
)
Message
?.
MessageDateTime
;
public
async
Task
RefresData
()
// REFRESH
public
async
Task
RefreshData
()
{
if
(
Message
==
null
)
return
;
...
...
@@ -42,7 +42,7 @@
if
(
await
App
.
API
.
RefreshItemAsync
(
Message
))
{
Title
=
Message
.
Stat
e
;
Title
=
Message
.
Stat
usImg
;
OnPropertyChanged
(
"State"
);
}
...
...
inutralia/inutralia/Views/Question/HistoryView.xaml.cs
View file @
22e5b72e
...
...
@@ -19,7 +19,7 @@
protected
async
void
ItemTapped
(
object
sender
,
ItemTappedEventArgs
e
)
{
var
respon
=
e
.
Item
as
Message
;
if
(
respon
.
Stat
e
==
"Respondida"
)
if
(
respon
.
Stat
usImg
==
"Respondida"
)
{
await
DisplayAlert
(
"ERROR"
,
"La pregunta ya está respondida"
,
"Entendido"
);
}
...
...
inutralia/inutralia/Views/Question/NewConsultationView.xaml
View file @
22e5b72e
...
...
@@ -35,14 +35,13 @@
Footer=""/>
</ScrollView>
<StackLayout Orientation="Horizontal" Grid.Row="1" BackgroundColor="White" Padding="
0,0,0,1
0">
<StackLayout Orientation="Horizontal" Grid.Row="1" BackgroundColor="White" Padding="
10,0,10,10" HeightRequest="4
0">
<Entry HorizontalOptions="FillAndExpand"
Placeholder=" Escriba aquí su mensaje"
Text="{Binding OutText}"
Keyboard="Chat"
Margin="4"/>
Text="{Binding OutText}"
HeightRequest="10"/>
<Image Source="btn_enviar_chat.png" WidthRequest="4
5" HeightRequest="5" Margin="4" BackgroundColor="#FFA2C300
">
<Image Source="btn_enviar_chat.png" WidthRequest="4
0" VerticalOptions="FillAndExpand" BackgroundColor="#FFA2C300" Aspect="AspectFit
">
<Image.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding SendCommand}" />
...
...
inutralia/inutralia/Views/Question/NewConsultationView.xaml.cs
View file @
22e5b72e
...
...
@@ -21,82 +21,12 @@
{
var
target
=
vm
.
ListMessages
[
vm
.
ListMessages
.
Count
-
1
];
MessagesListView
.
ScrollTo
(
target
,
ScrollToPosition
.
End
,
true
);
};
//newQuest.IsEnabled = true;
//buttonNewQuestion.IsEnabled = false;
//buttonNewQuestion.Clicked += ButtonNewQuestion_Clicked;
};
}
protected
void
ItemTapped
(
object
sender
,
ItemTappedEventArgs
e
)
{
((
ListView
)
sender
).
SelectedItem
=
null
;
}
//protected override void OnBindingContextChanged()
//{
// base.OnBindingContextChanged();
// ViewModel.PropertyChanged += ViewModel_PropertyChanged;
//}
//private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
//{
// OnDataRefreshed();
//}
//private async void ButtonNewQuestion_Clicked(object sender, EventArgs e)
//{
// if (String.IsNullOrWhiteSpace(newQuest.Text))
// {
// newQuest.Text = "";
// return;
// }
// await ViewModel.SaveQuestion(newQuest.Text);
// listNewConsultation.SelectedItem = null;
// //OnDataRefreshed();
//}
///// <summary>
///// Método llamado cada vez que una página pasa a ser visible
///// </summary>
//protected override async void OnAppearing()
//{
// base.OnAppearing();
// await ViewModel.RefreshData();
// OnDataRefreshed();
//}
///// <summary>
///// Método llamado al hacer tap en un elemento de la lista. Navega a la página de detalle
///// de la notificación seleccionada
///// </summary>
///// <param name="sender">La ListiView</param>
///// <param name="e">Argumentos del evento</param>
//void ItemTapped(object sender, ItemTappedEventArgs e)
//{
// if (e == null) return; // has been set to null, do not 'process' tapped event
// QuestionMessage item = (QuestionMessage)e.Item;
// if (ViewModel.NewQuestion.Last() == item && item.FromUser)
// {
// buttonNewQuestion.IsEnabled = true;
// newQuest.IsEnabled = true;
// newQuest.Text = item.Text;
// }
// else
// {
// ((ListView)sender).SelectedItem = null; // de-select the row
// }
//}
//private void OnDataRefreshed()
//{
// newQuest.Text = "";
// newQuest.IsEnabled = !(ViewModel.IsCloseOrPending);
// newQuest.Placeholder = (ViewModel.IsCloseOrPending) ? ((ViewModel.QuestionSpecialist.State == QuestionSpecialist.Estatus.Closed) ? "La pregunta está cerrada" : "Esperando respuesta") : "Realiza una pregunta";
// buttonNewQuestion.IsEnabled = !(ViewModel.IsCloseOrPending);
//}
}
}
}
\ No newline at end of file
inutralia/inutralia/Views/Question/PendingReadView.xaml.cs
View file @
22e5b72e
...
...
@@ -40,7 +40,7 @@
protected
override
async
void
OnAppearing
()
{
base
.
OnAppearing
();
await
ViewModel
.
RefresData
();
await
ViewModel
.
Refres
h
Data
();
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment