Save Date and Time To SQL DAtaBase From ApiService

Enrique4toEnrique4to Member ✭✭

Hello everyone.

I'm new in Xamarin.Forms and I am developing in CrossPlatform and I need some help.

I have a SQL DataBase, and in it, I have a Table with 4 columns

        [id_cita] [int] IDENTITY(0,1) NOT NULL,
        [id_trabajo] [int] NULL,
        [f_inicio] [date] NULL,
        [f_fin] [date] NULL,
        [h_inicio] [time](7) NULL,
        [h_fin] [time](7) NULL,

That DataBase is located on Azure, and I am using an ApiService to get and modify the information on it from my CrossPlatform App.

I Have this Module that refer the Table in the database with the ApiService

        using System;
        using System.ComponentModel.DataAnnotations;

        namespace mLetsTatoo.Models
        {
            public class T_trabajocitas
            {
                [Key]
                public int Id_Cita { get; set; }
                [Required]
                public int Id_Trabajo { get; set; }
                [Required]
                public DateTime F_Inicio { get; set; }
                [Required]
                public DateTime F_Fin { get; set; }
                [Required]
                public TimeSpan H_Inicio { get; set; }
                [Required]
                public TimeSpan H_Fin { get; set; }
            }
        }

To fill that Information, i'm using DatePicker and TimePicker with the next properties:

                                    <Label
                                        FontAttributes="Bold"
                                        FontSize="16"
                                        Text="{i18n:Translate Date}"
                                        TextColor="LightGray"
                                        HorizontalTextAlignment="Start"
                                        VerticalOptions="Center"/>
                                    <DatePicker
                                        Date="{Binding AppointmentDate, Mode=TwoWay}"
                                        Format="dd MMM yyyy"
                                        TextColor="Gray"
                                        VerticalOptions="Center">
                                    </DatePicker>
                                    <Label
                                        FontAttributes="Bold"
                                        FontSize="16"
                                        Text="{i18n:Translate Time}"
                                        TextColor="LightGray"
                                        HorizontalTextAlignment="Start"
                                        VerticalOptions="Center"/>
                                    <TimePicker                                
                                        TextColor="Gray"
                                        Time="{Binding AppointmentTime, Mode=TwoWay}"
                                        VerticalOptions="Center">
                                    </TimePicker>

All dat Binding Porperties has BindingContext from a ViewModel.

This is my question...

How can I save de Time data from the TimePicker to the SQL Database with ApiService?

Best Answer

Answers

Sign In or Register to comment.