Beispiel #1
0
 public IActionResult SaveTimeRegistration(
     [FromRoute] int projectId,
     [FromBody] TimeRegistrationModel timeRegistrationModel)
 {
     if (timeRegistrationSaveBusinessService.Execute(projectId, timeRegistrationModel))
     {
         return(NoContent());
     }
     return(BadRequest());
 }
Beispiel #2
0
        public void Save(Project project, TimeRegistrationModel timeRegistrationModel)
        {
            var timeRegistration = new TimeRegistration
            {
                TimeLogged = timeRegistrationModel.MinutesWorked,
                CreatedAt  = DateTime.UtcNow,
                Project    = project
            };

            context.TimeRegistrations.Add(timeRegistration);
            context.SaveChanges();
        }
Beispiel #3
0
        public bool Execute(int projectId, TimeRegistrationModel timeRegistrationModel)
        {
            var project = projectLoader.Load(projectId);

            if (CanBeSaved(project))
            {
                timeRegistrationSaver.Save(project, timeRegistrationModel);
                return(true);
            }

            return(false);
        }