Exemplo n.º 1
0
 public void Execute(PluginExecutionContext context)
 {
     if (context.MessageName == OperationTypeEnum.Create && context.Stage == OperationStage.PreOperation)
     {
         var snr = _serialNumberRuleFinder.FindByEntityId(context.EntityMetadata.EntityId);
         if (snr != null && context.Target.GetStringValue(snr.AttributeName).IsEmpty())
         {
             context.Target.SetAttributeValue(snr.AttributeName, _serialNumberGenerator.Generate(snr.SerialNumberRuleId));
         }
     }
 }
Exemplo n.º 2
0
        public void CreateCourse(CreateCourseDto dto, out int id)
        {
            var createdCourse = new Course
            {
                SerialNumber = _serialNumberGenerator.Generate(),
                Title        = dto.Title,
                Description  = dto.Description,
                CreationDate = DateTime.UtcNow,
                SpendingTime = new Time
                {
                    DayOfWeek = dto.DayOfWeek,
                    StartHour = dto.StartHour,
                    EndHour   = dto.EndHour
                }
            };

            _courseRepository.Insert(createdCourse);

            id = createdCourse.Id;
        }