Beispiel #1
0
 public ActionResult Create(TimeRecordViewModel model)
 {
     if (ModelState.IsValid)
     {
         //Add validation.
         var userId       = new UserId(UserContext.Current.UserId);
         var timeRecordId = Guid.NewGuid();
         var command      = new CreateTimeRecord(new TimeRecordId(timeRecordId), userId, new ProjectId(model.Project.ProjectId),
                                                 model.Description, model.Effort, model.StartDate,
                                                 model.EndDate);
         _commandSender.Send(command);
     }
     return(RedirectToAction("Index"));
 }
Beispiel #2
0
        /// <summary>
        /// Handles the specified <see cref="CreateTimeRecord"/>command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <exception cref="System.ArgumentNullException">When TimeRecordId is null.</exception>
        public void Handle(CreateTimeRecord command)
        {
            if (command.Id == null)
            {
                throw new ArgumentNullException("TimeRecordId", "TimeRecordId must be specified.");
            }

            var timeRecord = this.GetOrCreateTimeRecord(command.Id);

            timeRecord.CreateTimeRecord(command.UserId, command.ProjectId, command.Effort, command.Description,
                                        command.StartDate, command.EndDate);

            this.timeRecordRepository.Save(timeRecord);
        }