private async Task UpdateWorkingHour()
        {
            if (ValidateInputs())
            {
                WorkingHourEditVM workingHourEditVM = new WorkingHourEditVM()
                {
                    Id        = workingHour.Id,
                    DayInWeek = TbDayInWeek.Text,
                    TimeStart = TpTimeStart.Value.Value.TimeOfDay,
                    TimeEnd   = TpTimeEnd.Value.Value.TimeOfDay
                };

                ls.LblLoading.Text = "Editing";
                ls.Show();
                bool success = await workingHourApi.UpdateWorkingHour(workingHourEditVM);

                ls.Close();

                if (success)
                {
                    Close();
                }
                else
                {
                    MessageBox.Show("Fail!");
                }
            }
            else
            {
                MessageBox.Show("All input fields are required!");
            }
        }
Exemple #2
0
        public bool EditWorkingHour(WorkingHourEditVM workingHourEditVM)
        {
            WorkingHour workingHour = unitOfWork.WorkingHours.Get(workingHourEditVM.Id);

            workingHour.DayInWeek = workingHourEditVM.DayInWeek;
            workingHour.TimeStart = workingHourEditVM.TimeStart;
            workingHour.TimeEnd   = workingHourEditVM.TimeEnd;

            int success = unitOfWork.Complete();

            return(success > 0);
        }
        public async Task <bool> UpdateWorkingHour(WorkingHourEditVM workingHourEditVM)
        {
            StringContent       content  = GetStringContent(workingHourEditVM);
            HttpClient          request  = new HttpClient();
            HttpResponseMessage response = await request.PutAsync($"{ API_URL }/EditWorkingHour", content);

            if (response.IsSuccessStatusCode)
            {
                bool result = await response.Content.ReadAsAsync <bool>();

                return(result);
            }
            return(false);
        }