コード例 #1
0
        public void Create_inputDtoAddActivity_AreSame()
        {
            var input = new InputDtoAddActivity("name", 1, 1, 1);
            var unit  = new Unit("type");

            unit.Id = 1;
            var category = new Category("name");

            category.Id = 1;

            var activityFromDto = new Activity(input.Name, input.Repetitions, unit, category);
            var activityInDb    = new Activity(input.Name, input.Repetitions, unit, category);

            activityInDb.Id = 1;

            _activityFactory.CreateFromValues(input.Name, input.Repetitions, unit, category)
            .Returns(activityFromDto);
            _unitRepository.GetById(input.UnitId).Returns(unit);
            _categoryRepository.GetById(input.CategoryId).Returns(category);
            _activityRepository.Create(activityFromDto).Returns(activityInDb);//ok

            OutputDtoAddActivity expected = new OutputDtoAddActivity
            {
                Id           = activityInDb.Id,
                CategoryName = activityInDb.Category.Name,
                Name         = activityInDb.Name,
                Repetitions  = activityInDb.Repetitions,
                UnitType     = activityInDb.Unit.Type
            };

            var res = _activityService.Create(input);

            Assert.AreEqual(expected, res);
        }
コード例 #2
0
ファイル: ActivityService.cs プロジェクト: jrocket/MOG
        public void LogProjectCreation(Project project)
        {
            Activity act = new Activity();

            act.ProjectId = project.Id;
            act.Who       = project.Creator;
            act.When      = DateTime.Now;
            act.Type      = ActivityType.Create | ActivityType.Project;
            repoActivity.Create(act);

            notifyProjectCreation(project);
        }
コード例 #3
0
 public void AddActivity(Activity activity)
 {
     activity.LastModifiedDateUtc = DateTime.UtcNow;
     activity.CreatedDateUtc      = DateTime.UtcNow;
     activity.LastModifiedBy      = 1;
     _repository.Create(activity);
 }
コード例 #4
0
        public void Create(ActivityLogEntry entry)
        {
            entry.Date = DateTime.UtcNow;

            _repo.Create(entry);

            EntryCreated?.Invoke(this, new GenericEventArgs <ActivityLogEntry>(entry));
        }
コード例 #5
0
ファイル: ActivityManager.cs プロジェクト: zxz2020/Emby
        public void Create(ActivityLogEntry entry)
        {
            entry.Date = DateTime.UtcNow;

            _repo.Create(entry);

            EventHelper.FireEventIfNotNull(EntryCreated, this, new GenericEventArgs <ActivityLogEntry>(entry), _logger);
        }
コード例 #6
0
        public async Task Create(ActivityLogEntry entry)
        {
            entry.Id   = Guid.NewGuid().ToString("N");
            entry.Date = DateTime.UtcNow;

            await _repo.Create(entry).ConfigureAwait(false);

            EventHelper.FireEventIfNotNull(EntryCreated, this, new GenericEventArgs <ActivityLogEntry>(entry), _logger);
        }
コード例 #7
0
        public void ShouldCreateAnActivity()
        {
            var activity = new Activity(Discipline, "Activity 1", DateTime.Now, 10, 50, 15, null);

            _AREP.Create(activity);
            var activityDB = _AREP.Get(activity.Id);

            Activities.Add(activity.Id);
            Assert.IsNotNull(activityDB);
            Assert.AreEqual(activity.Description, activityDB.Description);
            Assert.AreEqual(activity.Discipline.Id, activityDB.Discipline.Id);
        }
コード例 #8
0
        public ICommandResult Handle(ActivityInputGiveGrade command)
        {
            var activity = new Activity(command.ActivityId, new Student(command.StudentId), command.Grade, command.Value);
            var result   = new StandardResult();

            result.AddRange(activity.Notifications);
            if (result.Notifications.Count == 0)
            {
                _AREP.Create(activity);
                result.Notifications.Add("Success", "A nota foi lançada.");
            }
            return(result);
        }
コード例 #9
0
        public async Task <long> CreateActivity(Activity activity)
        {
            activity = _activityRepository.Create(activity);
            await _unit.Commit();

            await _feedEventService.GenerateFeedEvent(activity);

            await UpdateGoals(activity.UserId);

            _userBadgeService.CheckActivityBadgeProgress(activity.UserId, activity);
            await _unit.Commit();

            return(activity.Id);
        }
コード例 #10
0
        public IActionResult Post([FromBody] ActivityCreationDTO _activityCreationDTO)
        {
            if (_activityCreationDTO == null)
            {
                return(BadRequest());
            }

            var _activity = Mapper.Map <Activity>(_activityCreationDTO);

            _activity.Date = DateTime.Now;

            _activityRepository.Create(_activity);
            _activityRepository.Save();

            return(CreatedAtRoute(nameof(FTActivityController.Get), new { id = _activity.ActivityId }, _activity));
        }
コード例 #11
0
        public ICommandResult Handle(ActivityInputRegister command)
        {
            decimal points = 0;

            if (command.ValidateTotalGrade)
            {
                points = _AREP.GetByDiscipline(command.Activity.DisciplineId, new Semester()).Sum(x => x.Value);
            }
            var activity = new Activity(new Discipline(command.Activity.DisciplineId), command.Activity.Description, command.Activity.Date, command.Activity.Value, points, command.Activity.MaxValue, null);
            var result   = new StandardResult();

            result.AddRange(activity.Notifications);
            if (result.Notifications.Count == 0)
            {
                _AREP.Create(activity);
                result.Notifications.Add("Success", "A atividade foi criada.");
            }
            return(result);
        }
コード例 #12
0
        /*
         * Créer une activité
         */
        public OutputDtoAddActivity Create(InputDtoAddActivity inputDtoAddActivity)
        {
            var unit     = _unitRepository.GetById(inputDtoAddActivity.UnitId);
            var category = _categoryRepository.GetById(inputDtoAddActivity.CategoryId);


            var activityFromDto = _activityFactory.CreateFromValues(inputDtoAddActivity.Name,
                                                                    inputDtoAddActivity.Repetitions, unit, category);
            var activityInDb = _activityRepository.Create(activityFromDto);

            return(new OutputDtoAddActivity
            {
                Id = activityInDb.Id,
                CategoryName = activityInDb.Category.Name,
                Name = activityInDb.Name,
                Repetitions = activityInDb.Repetitions,
                UnitType = activityInDb.Unit.Type
            });
        }
 /// <summary>
 /// Handles the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 public void Handle(RegisterSingleActivityCommand message)
 {
     try
     {
         // Cria o objeto de atividade
         var activity = new Activity(message.Id, message.Message, message.CreateBy, message.AssignedTo, message.Company);
         // Envia para o repositório.
         _repository.Create(activity);
         // Dispara um evento de criado.
         _bus.RaiseEvent(
             new SingleActivityRegisteredEvent(message.Id, message.Message, message.CreateBy, message.AssignedTo, message.Company)
             );
     }
     // TODO: Definir a excessão de domínio.
     catch (Exception e)
     {
         // TODO: Definir o evento e erro.
     }
 }
コード例 #14
0
 public async Task <IActionResult> PutActivity([FromBody] Dto.ActivityForCreate activity)
 {
     if (activity == null)
     {
         return(BadRequest());
     }
     if (activity.ProjectId == null)
     {
         return(BadRequest());
     }
     if (activity.ProjectId == "")
     {
         return(BadRequest());
     }
     Models.Activity activityModel = new Models.Activity {
         Name = activity.Name, ProjectId = activity.ProjectId
     };
     if (await Repo.Create(activityModel))
     {
         return(Ok());
     }
     return(BadRequest());
 }
コード例 #15
0
 public Task <Activity> Create(Activity activity)
 {
     return(_activityRepository.Create(activity));
 }
コード例 #16
0
 public Activity Create(Activity activity)
 {
     Repo.Create(activity);
     Unit.SaveChanges();
     return(activity);
 }