public IActionResult StopActivity([FromBody] ActivityStopDto activity) { if (activity == null) { return(BadRequest("Activity object cannot be null")); } _activityService.StopActivity(activity); return(NoContent()); // successfull stop }
public void StopActivity(ActivityStopDto activity) { var entity = GetCurrentlyActiveActivity(); // update properties entity.TimeEnd = activity.TimeEnd ?? DateTime.Now; entity.TimeTotal = (int)((entity.TimeEnd - entity.TimeStart).Value.TotalSeconds); // TODO Validate TimeEnd value _context.Activities.Update(entity); _context.SaveChanges(); }