public async Task <ActionResult <V1DTO.WorkingHours> > GetWorkingHours(Guid id)
        {
            var workingHours = await _bll.WorkingHourses.FirstOrDefaultAsync(id);

            if (workingHours == null)
            {
                return(NotFound(new V1DTO.MessageDTO($"WorkingHours with id {id} not found")));
            }

            return(Ok(_mapper.Map(workingHours)));
        }
Пример #2
0
        public async Task <IActionResult> Create(WorkingHoursViewModel workingHoursViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _workingHoursService.AddAsync(WorkingHoursMapper.Map(workingHoursViewModel)).ConfigureAwait(false);

                    return(RedirectToAction("details", "project", new { id = workingHoursViewModel.ProjectId }));
                }

                return(View(workingHoursViewModel));
            }
            catch (Exception)
            {
                ErrorViewModel model = new ErrorViewModel {
                    RequestId = "Kunne ikke indberette arbejdstimer"
                };
                return(View("Error", model));
            }
        }
Пример #3
0
 public void Put(int id, [FromBody] WorkingHoursDto value)
 {
     _workinghoursService.Update(WorkingHoursMapper.Map(value));
 }
Пример #4
0
 public void Post([FromBody] WorkingHoursDto value)
 {
     _workinghoursService.Create(WorkingHoursMapper.Map(value));
 }
Пример #5
0
 public WorkingHoursDto Get(int id)
 {
     return(WorkingHoursMapper.Map(_workinghoursService.Get(id)));
 }
Пример #6
0
 public IEnumerable <WorkingHoursDto> Get()
 {
     return(_workinghoursService.GetAll().Select(a => WorkingHoursMapper.Map(a)).ToList());
 }