コード例 #1
0
        internal async Task <int> InsertNote(NoteTable note)
        {
            string url         = GetBaseUrl() + Constants.REST_URL_INSERTNOTE;
            string contentType = Constants.CONTENT_TYPE;
            HttpResponseMessage response;

            InsertNoteModel noteModel = new InsertNoteModel()
            {
                shiftId   = note.ShiftKey,
                noteText  = note.Note,
                timeStamp = note.Date
            };
            string      json    = JsonConvert.SerializeObject(noteModel);
            HttpContent content = new StringContent(json, Encoding.UTF8, contentType);

            using (HttpClient client = new HttpClient())
            {
                response = await client.PostAsync(url, content);
            }

            if (response.IsSuccessStatusCode)
            {
                InsertNoteResponse result = JsonConvert.DeserializeObject <InsertNoteResponse>(response.Content.ReadAsStringAsync().Result);

                if (result.Success)
                {
                    return(result.Result);
                }
                else
                {
                    return(-2);
                }
            }
            else
            {
                return(-1);
            }
        }
コード例 #2
0
        private void Add()
        {
            if (Instruction == "Break")
            {
                if (!CheckValidHuboEntry(HuboStart))
                {
                    return;
                }

                if (!CheckValidHuboEntry(HuboEnd))
                {
                    return;
                }

                BreakTable breakAdd = new BreakTable()
                {
                    StartDate     = BreakStart.ToString(Resource.DateFormat),
                    EndDate       = BreakEnd.ToString(Resource.DateFormat),
                    StartLocation = LocationStart,
                    EndLocation   = LocationEnd
                };
                MessagingCenter.Send(this, "Break_Added", breakAdd);
            }
            else if (Instruction == "Note")
            {
                NoteTable note = new NoteTable()
                {
                    Date = NoteTime.ToString(Resource.DateFormat),
                    Note = NoteDetail
                };
                MessagingCenter.Send(this, "Note_Added", note);
            }
            else if (Instruction == "Drive Shift")
            {
                if (!CheckValidHuboEntry(HuboStart))
                {
                    return;
                }

                if (!CheckValidHuboEntry(HuboEnd))
                {
                    return;
                }

                List <VehicleTable> vehicleKey = new List <VehicleTable>();
                vehicleKey = GetVehicles();

                DriveTable drive = new DriveTable()
                {
                    StartDate     = DriveStartTime.ToString(Resource.DateFormat),
                    EndDate       = DriveEndTime.ToString(Resource.DateFormat),
                    StartHubo     = int.Parse(HuboStart),
                    EndHubo       = int.Parse(HuboEnd),
                    ActiveVehicle = false,
                    VehicleKey    = vehicleKey[SelectedVehicle].Key
                };
                MessagingCenter.Send(this, "Drive_Added", drive);
            }

            Navigation.PopModalAsync();
        }