public async Task <IActionResult> CreateLog(LogToCreateDto logToCreate)
        {
            var log = await _service.CreateLog(logToCreate);

            if (log == null)
            {
                return(StatusCode(400));
            }
            return(StatusCode(200, log));
        }
Example #2
0
        public async Task <LogDto> CreateLogAsync(LogToCreateDto log)
        {
            GetClient();
            LogDto createdLog            = null;
            HttpResponseMessage response = await client.PostAsJsonAsync("api/Log/", log);

            if (response.IsSuccessStatusCode)
            {
                createdLog = await response.Content.ReadAsAsync <LogDto>();
            }
            return(createdLog);
        }
        public async Task <LogDto> CreateLog(LogToCreateDto logToCreate)
        {
            TimeLog log = new TimeLog()
            {
                UserId      = logToCreate.UserId,
                ProjectId   = logToCreate.ProjectId,
                Description = logToCreate.Description,
                StartDate   = logToCreate.StartTime,
                EndDate     = logToCreate.StopTime
            };

            return(ConvertToLogDto(await AddAsync(log)));
        }
Example #4
0
        private async void LogTime_Clicked(object sender, EventArgs e)
        {
            //Startuur
            string StartHour = StartTime.Time.Hours.ToString();
            string StartMin  = StartTime.Time.Minutes.ToString();
            string StartT    = $"{StartHour}:{StartMin}";

            //Einduur
            string EndHour = EndTime.Time.Hours.ToString();
            string EndMin  = EndTime.Time.Minutes.ToString();
            string EndT    = $"{EndHour}:{EndMin}";


            string value     = ProjectList.SelectedItem.ToString();
            int    projectid = 0;

            //Zoekt id van project
            foreach (var project in projectsWithKey)
            {
                if (project.Value == value)
                {
                    projectid = project.Key;
                }
            }

            //LOgs toevoegen na validatie uren en description
            if (CheckTimePicker() == true && CheckDescription() == true)
            {
                //Alle gegevens in een log object steken
                LogToCreateDto log = new LogToCreateDto()
                {
                    UserID      = int.Parse(idUser),
                    ProjectID   = projectid,
                    StartTime   = DateTime.Parse(StartT),
                    StopTime    = DateTime.Parse(EndT),
                    Description = DescriptionEntry.Text
                };

                LogDto logDto = await logServices.CreateLogAsync(log);

                Application.Current.MainPage = new MainPage();
            }
        }