Exemplo n.º 1
0
 public IActionResult SaveTimeRegistration(
     [FromRoute] int projectId,
     [FromBody] TimeRegistrationModel timeRegistrationModel)
 {
     if (timeRegistrationSaveBusinessService.Execute(projectId, timeRegistrationModel))
     {
         return(NoContent());
     }
     return(BadRequest());
 }
Exemplo n.º 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();
        }
Exemplo n.º 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);
        }