Ejemplo n.º 1
0
		public Promise LoadActivities(string courseId)
		{
			Promise promise = new Promise();

			try
			{
				Uri serverUri = new Uri(appSettings.ServerURI, UriKind.RelativeOrAbsolute);
				Uri restUri = new Uri(serverUri, "rest/");

				ActivityRepository repo = new ActivityRepository(restUri);
				if (repo == null)
				{
					throw new Exception("ActivityRepository is not initialized.");
				}
							
				repo.GetActivities(courseId, (response) =>
				{
					if (response.Success)
					{
						promise.Resolve(response.Items);
					}
					else
					{
						promise.Reject(new Exception(response.Error));
					}
				});                   
			}
			catch (Exception e)
			{
				promise.Reject(e);
			}

			return promise;
		}
        public static void UpdateGame(Game game)
        {
            List<ActivityPoint> points = null;

            using (var repository = new TweetRepository())
            {
                points = (from tweet in repository.GetAll().AsParallel()
                          where tweet.GameId == game.Id
                          group tweet by tweet.Timestamp.AddSeconds(-tweet.Timestamp.Second) into minute
                          select new ActivityPoint()
                          {
                              Time = minute.Key,
                              GameId = game.Id,
                              TweetCount = minute.Count()
                          }).ToList();
            }

            using (var repository = new ActivityRepository())
            {
                if (!repository.AddRange(points))
                {
                    Console.WriteLine("Error occurred with saving points");
                }
            }
        }
 public StockInformationRepository()
 {
     _itemRepository = new ItemRepository();
     _unitOfIssueRepository = new UnitRepository();
     _manufacturerRepository = new ManufacturerRepository();
     _physicalStoreRepository = new PhysicalStoreRepository();
     _activityRepository = new ActivityRepository();
 }
        public IEnumerable<ActivityPoint> Get(long gameId)
        {
            List<ActivityPoint> points = null;

            using (var repository = new ActivityRepository())
            {
                points = (from p in repository.GetAll()
                          where p.GameId == gameId
                          select p).OrderByDescending(p => p.Time).ToList();
            }
            return points;
        }
 public RequestRepository()
 {
     _clientRepository = new ClientRepository();
     _itemRepository = new ItemRepository();
     _unitOfIssueRepository = new UnitRepository();
     _modeService = new ModeService();
     _paymentTermService = new PaymentTermRepository();
     _orderStatusService = new OrderStatusService();
     _manufacturerRepository = new ManufacturerRepository();
     _physicalStoreRepository = new PhysicalStoreRepository();
     _activityRepository = new ActivityRepository();
 }
		public ActivityListViewModel ()
		{
			this.IsLoading = true;

			//RefreshCommand = new Command (LoadActivites);
			AddNewActivityCommand = new Command(NavigateToAddNewActivity);
			DeleteCommand = new Command<Activity> (a => Delete(a));

			this._activityRepository = new ActivityRepository ();

			LoadActivites ();

		}
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            GenericEventHubDb context = new GenericEventHubDb();

            IGenericRepository<Event> genericEventRepo = new GenericRepository<Event>(context);
            IEventRepository eventRepo = new EventRepository(genericEventRepo);

            IGenericRepository<Activity> genericActivityRepo = new GenericRepository<Activity>(context);
            IActivityRepository activityRepo = new ActivityRepository(genericActivityRepo);

            var generator = new EventGenerator(eventRepo, activityRepo);

            // Generate events for next week
            generator.CreateEventsForNextWeek();
        }
        public void Run()
        {
            _logger.Info("EventMonitorEntryPoint Running");

            _repository = new ActivityRepository(_logger, _config.ApplicationPaths, _fileSystem);
            _repository.Initialize();

            if (VersionCheck.IsVersionValid(_appHost.ApplicationVersion, _appHost.SystemUpdateLevel) == false)
            {
                _logger.Info("ERROR : Plugin not compatible with this server version");
                return;
            }

            _sessionManager.PlaybackStart   += _sessionManager_PlaybackStart;
            _sessionManager.PlaybackStopped += _sessionManager_PlaybackStop;

            // start playback monitor
            System.Threading.Tasks.Task.Run(() => PlaybackMonitoringTask());
        }
 public FeedManagementService(FeedItemRepository feedItemRepository,
                              BoardRepository boardRepository,
                              ActivityRepository activityRepository,
                              JunaUserRepository junaUserRepository,
                              ActivityManagementService activityManagementService,
                              FCMSenderService fCMSenderService,
                              TelemetryClient telemetryClient,
                              Stream.StreamClient streamClient
                              )
 {
     _feedItemRepository        = feedItemRepository;
     _boardRepository           = boardRepository;
     _activityRepository        = activityRepository;
     _junaUserRepository        = junaUserRepository;
     _activityManagementService = activityManagementService;
     _fcmSenderService          = fCMSenderService;
     logger        = telemetryClient;
     _streamClient = streamClient;
 }
        public override Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken)
        {
            var username = actionContext.RequestContext.Principal.Identity.Name;

            using (var db = new ActivityRepository())
            {
                var activity = new Activity
                {
                    Name          = username,
                    DatePerformed = DateTime.Now,
                    Action        = actionContext.ActionDescriptor.ActionName,
                    Controller    = actionContext.ControllerContext.ControllerDescriptor.ControllerName
                };

                db.CreateActivity(activity);
            }

            return(base.OnActionExecutingAsync(actionContext, cancellationToken));
        }
Ejemplo n.º 11
0
        public async Task <ICommandResult> ExecuteAsync(CreateCommand <TViewModel> command)
        {
            var activity = await ActivityRepository.SearchItemsAsync(x => x.Name == $"{typeof(TViewModel)}{nameof(CreateCommandHandler<CreateCommand<TViewModel>, TEntity>)}");

            if (await Authorizer.IsAuthorized(activity.FirstOrDefault()))
            {
                return(new ForbidResult());
            }

            if (command == null)
            {
                return(new ErrorResult("New item cannot be null"));
            }

            var entity = Translator.Translate(command.Data);
            var id     = await CreateRepository.CreateItemAsync(entity);

            return(new CreateResult(id));
        }
Ejemplo n.º 12
0
 public void MissionInsert()
 {
     using (IUnitOfWork uow = UnitOfWorkFactory.Create())
     {
         ActivityRepository activityRepository = new ActivityRepository(uow);
         OperatorRepository operatorRepository = new OperatorRepository(uow);
         MissionRepository  missionRepository  = new MissionRepository(uow);
         var     fA         = activityRepository.GetAll().FirstOrDefault();
         var     fO         = operatorRepository.GetAll().FirstOrDefault();
         Mission newMission = new Mission()
         {
             Description = "OnlyForTest",
             WFOperator  = fO,
             Activity    = fA,
             StartDate   = DateTime.Now
         };
         missionRepository.Insert(newMission);
     }
 }
Ejemplo n.º 13
0
        public void DeleteNormal()
        {
            var options = new DbContextOptionsBuilder <ProjectManagerContext>()
                          .UseInMemoryDatabase(databaseName: "save")
                          .Options;

            using (var context = new ProjectManagerContext(options, null))
            {
                context.Projects.Add(new Project
                {
                    Name            = "teste1",
                    InitialDate     = DateTime.Now,
                    FinalDate       = DateTime.Now.AddMonths(1),
                    PercentComplete = 0,
                    Late            = false,
                    Removed         = false
                });

                context.Activities.Add(new Activity
                {
                    Name        = "teste1",
                    InitialDate = DateTime.Now,
                    FinalDate   = DateTime.Now.AddDays(1),
                    ProjectId   = 1,
                    Finished    = false
                });

                context.SaveChanges();
            }

            using (var context = new ProjectManagerContext(options, null))
            {
                var repoA = new ActivityRepository(context);

                var service = new ActivityService(repoA);

                service.Delete(1, 1).Wait();

                var activity = service.Get(1).Result;

                Assert.Null(activity);
            }
        }
Ejemplo n.º 14
0
        public ActionResult Delete(int id)
        {
            var existProject = new Project();

            existProject = db.Projects.FirstOrDefault(x => x.ProjectId == id);
            if (TeamRepository.IsUserManagerOfTeam(UserRepository.GetUserId(), existProject.TeamId ?? default(int)))
            {
                db.Projects.Remove(existProject);
                db.SaveChanges();

                ActivityRepository.ActivityCreator
                    ("deleted " + existProject.Name + " project.",
                    existProject.ProjectId, null);

                return(RedirectToAction("Index", "Project", new { id = existProject.TeamId }));
            }

            return(RedirectToAction("Login", "User"));
        }
Ejemplo n.º 15
0
        public ActionResult CreateBacklog(BacklogViewModel backlogModel)
        {
            var backlogEpic = db.Epics.FirstOrDefault(x => x.EpicId == backlogModel.Backlog.EpicId);

            if (backlogEpic != null)
            {
                backlogModel.Backlog.EpicName = backlogEpic.Name;
                db.ProductBacklogs.Add(backlogModel.Backlog);
                db.SaveChanges();

                ActivityRepository.ActivityCreator
                    ("created " + backlogModel.Backlog.Name + " backlog.",
                    backlogModel.Backlog.ProjectId, backlogModel.Backlog.ProductBacklogId);

                return(RedirectToAction("EditBacklog", new { id = backlogModel.Backlog.ProductBacklogId, sprintNo = backlogModel.ViewSprintNo, sortBy = backlogModel.ViewSortBy }));
            }

            return(Content("Please assign a epic task first."));
        }
Ejemplo n.º 16
0
        public JsonResult ReassignmentConfirm(ReassignmentViewModel model)
        {
            bool isSuccess = true;

            try
            {
                ActivityRepository repository = new ActivityRepository(false);
                var settingTask = repository.GetSettingTasks(st => st.Id == model.Id).FirstOrDefault();
                if (settingTask != null)
                {
                    settingTask.ExecutorId = Guid.Parse(model.ExecutorId.Id);
                    //settingTask.TaskTypeId = model.TaskTypeId;
                    repository.UpdateSettingTask(settingTask);
                }
                else
                {
                    var activityId = repository.GetActivityTypeIdByCode(model.ActivityTypeCode);
                    var taskTypeId = repository.GetTaskTypeIdByCode(model.TaskTypeCode);

                    var parentSettingTask = repository.GetSettingTasks(st => st.EXP_AgreementProcSettingsActivities.ActivityTypeId == activityId && st.TaskTypeId == taskTypeId).OrderByDescending(st => st.OrderNum).FirstOrDefault();

                    settingTask = new EXP_AgreementProcSettingsTasks()
                    {
                        Id           = Guid.NewGuid(),
                        ActivityId   = parentSettingTask.ActivityId,
                        TaskTypeId   = taskTypeId.Value,
                        ExecutorId   = Guid.Parse(model.ExecutorId.Id),
                        ParentTaskId = parentSettingTask.Id,
                        OrderNum     = parentSettingTask.OrderNum + 1
                    };
                    repository.AddSettingTask(settingTask);
                }

                repository.Save();
            }
            catch (Exception e)
            {
                isSuccess = false;
            }

            return(Json(new { IsSuccess = isSuccess }, JsonRequestBehavior.AllowGet));
        }
        public void Can_Filter_On_DateDuration()
        {
            // arrange
            var contextMock = GetMockedChirpingContext();
            var repository  = new ActivityRepository(contextMock);

            // set up filter
            var filter = new Filter();

            filter.NrOfParticipants = 10; // default to 10 so that MaxParticipants doensn't play a filter role
            filter.DateDuration     = new TimeFrame(DateTime.Now.AddDays(2).ToShortDateString());

            // act
            var actual = repository.GetAll(filter).ToList();

            // assert
            Assert.AreEqual <int>(2, actual.Count, "Filter returns more activites than 2");
            Assert.AreEqual <int>(1, actual[0].Id);
            Assert.AreEqual <int>(3, actual[1].Id);
        }
Ejemplo n.º 18
0
        public ActionResult GreenBacklog(int id)
        {
            if (UserRepository.IsUserSigned())
            {
                var existBacklog = db.ProductBacklogs.FirstOrDefault(x => x.ProductBacklogId == id);
                if (TeamRepository.IsProjectManager(existBacklog.ProjectId))
                {
                    existBacklog.Done = false;
                    db.SaveChanges();

                    ActivityRepository.ActivityCreator
                        ("uncompleted " + existBacklog.Name + " backlog.",
                        existBacklog.ProjectId, existBacklog.ProductBacklogId);

                    return(RedirectToAction("IndexBacklog", "Project", new { projectId = existBacklog.ProjectId }));
                }
                return(Content("There are errors, you cannot green this backlog."));
            }
            return(RedirectToAction("Login", "User"));
        }
        public void Can_Filter_On_BetweenTime()
        {
            // arrange
            var contextMock = GetMockedChirpingContext();
            var repository  = new ActivityRepository(contextMock);

            // set up filter
            var filter = new Filter();

            filter.BetweenTime = new BetweenTime(7, 14);

            // act
            var actual = repository.GetAll(filter).ToList();

            // assert
            Assert.AreEqual <int>(3, actual.Count, "Filter returns more activites than 3");
            Assert.AreEqual <int>(10, actual[0].Date.Hour);
            Assert.AreEqual <int>(12, actual[1].Date.Hour);
            Assert.AreEqual <int>(7, actual[2].Date.Hour);
        }
Ejemplo n.º 20
0
        public ActionResult ReassignmentDialog(Guid id, string documentTypeCode, string activityTypeCode = null, string taskTypeCode = null)
        {
            ActivityRepository repository = new ActivityRepository(false);
            var settingTask = repository.GetSettingTasks(st => st.Id == id).FirstOrDefault();

            var rvm = new ReassignmentViewModel()
            {
                Id         = settingTask?.Id ?? Guid.NewGuid(),
                ExecutorId = new Item()
                {
                    Id = settingTask?.ExecutorId.ToString()
                },
                ExecutionDate    = DateTime.Now,
                DocumentTypeCode = documentTypeCode,
                ActivityTypeCode = activityTypeCode ?? AgreementController.GetActivityTypeByDocTypeCode(documentTypeCode),
                TaskTypeCode     = string.IsNullOrEmpty(taskTypeCode) ? Dictionary.ExpTaskType.Agreement: taskTypeCode,
            };

            return(PartialView(rvm));
        }
        public Approval()
        {
            _requestService             = new RequestRepository();
            _stockInformationRepository = new StockInformationRepository();
            _forcastingRepository       = new ForcastingRepository();
            _activityRepository         = new ActivityRepository();
            _manufacturerRepository     = new ManufacturerRepository();
            _physicalRepository         = new PhysicalStoreRepository();
            _consumptionRepository      = new ConsumptionSettingRespository();
            InitializeComponent();

            //Edit Valued Changed Listener
            lkManufacturer.EditValueChanged            += ColumnLookup_EditValueChanged;
            lkActivity.EditValueChanged                += ColumnLookup_EditValueChanged;
            lkExpiryPreference.EditValueChanged        += ColumnLookup_EditValueChanged;
            lkPhysicalStorePreference.EditValueChanged += ColumnLookup_EditValueChanged;

            gridOrderDetailView.CellMerge     += gridViewOrderDetailsForApproval_CellMerge;
            gridOrderDetailView.ShowingEditor += gridViewOrderDetailsForApproval_ShowingEditor;
        }
        public Approval()
        {
            _requestService = new RequestRepository();
            _stockInformationRepository = new StockInformationRepository();
            _forcastingRepository = new ForcastingRepository();
            _activityRepository = new ActivityRepository();
            _manufacturerRepository = new ManufacturerRepository();
            _physicalRepository = new PhysicalStoreRepository();
            _consumptionRepository = new ConsumptionSettingRespository();
            InitializeComponent();

            //Edit Valued Changed Listener
            lkManufacturer.EditValueChanged += ColumnLookup_EditValueChanged;
            lkActivity.EditValueChanged += ColumnLookup_EditValueChanged;
            lkExpiryPreference.EditValueChanged += ColumnLookup_EditValueChanged;
            lkPhysicalStorePreference.EditValueChanged += ColumnLookup_EditValueChanged;

            gridOrderDetailView.CellMerge += gridViewOrderDetailsForApproval_CellMerge;
            gridOrderDetailView.ShowingEditor += gridViewOrderDetailsForApproval_ShowingEditor;
        }
Ejemplo n.º 23
0
        //
        // GET: /Brands/Edit/5

        public ActionResult SaveOrEdit(int id = 0, int selectedStoreId = 0)
        {
            Activity activity = new Activity();

            activity.StoreId = GetStoreId(selectedStoreId);
            if (id != 0)
            {
                activity             = ActivityRepository.GetSingle(id);
                activity.UpdatedDate = DateTime.Now;
            }
            else
            {
                activity.CreatedDate = DateTime.Now;
                activity.State       = true;
                activity.Ordering    = 1;
                activity.UpdatedDate = DateTime.Now;
            }

            return(View(activity));
        }
Ejemplo n.º 24
0
        public UserActivityAPI(ILogManager logger,
                               IFileSystem fileSystem,
                               IServerConfigurationManager config,
                               IJsonSerializer jsonSerializer,
                               IUserManager userManager,
                               ILibraryManager libraryManager)
        {
            _logger         = logger.GetLogger("PlaybackReporting - UserActivityAPI");
            _jsonSerializer = jsonSerializer;
            _fileSystem     = fileSystem;
            _config         = config;
            _userManager    = userManager;
            _libraryManager = libraryManager;

            _logger.Info("UserActivityAPI Loaded");
            var repo = new ActivityRepository(_logger, _config.ApplicationPaths, _fileSystem);

            //repo.Initialize();
            Repository = repo;
        }
Ejemplo n.º 25
0
        public void Given_ActivityRepository_When_AddingMoreNewActivities_Then_TheActivitiesShouldBeProperlyAdded()
        {
            RunOnDatabase(sut =>
            {
                //Arrange

                var repository     = new ActivityRepository(sut);
                var activity       = Activity.Create("Swim", "Go to Vivertine", "leisure", new Guid(), new DateTime(2017, 11, 11), new DateTime(2017, 12, 11));
                var secondActivity = Activity.Create("Sing", "Study Eminem music", "leisure", new Guid(), new DateTime(2017, 10, 10), new DateTime(2017, 11, 11));
                var thirdActivity  = Activity.Create("Read Books", "Study .NET books", "study/work", new Guid(), new DateTime(2017, 2, 2), new DateTime(2017, 3, 3));

                //Act
                repository.Add(activity);
                repository.Add(secondActivity);
                repository.Add(thirdActivity);

                //Assert
                var activitys = repository.GetAll();
                Assert.AreEqual(3, activitys.Count);
            });
        }
        public void ActivityRepository()
        {
            Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>();
            Mock<DbSet<Activity>> dbSet = new Mock<DbSet<Activity>>();

            factory.Setup(m => m.CreateDbSet<Activity>()).Returns(dbSet.Object);

            ActivityRepository repo = new ActivityRepository(factory.Object);

            var activity = new Activity();

            var sequence = new MockSequence();
            dbSet.InSequence(sequence).Setup(e => e.Add(activity));
            dbSet.InSequence(sequence).Setup(e => e.Find(activity.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(activity.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(activity.Id));
            repo.Create(activity);
            repo.Get(activity.Id);
            repo.Update(activity);
            repo.Delete(activity.Id);
        }
Ejemplo n.º 27
0
        public void ValidDatesWithoutException()
        {
            var options = new DbContextOptionsBuilder <ProjectManagerContext>()
                          .UseInMemoryDatabase(databaseName: "save")
                          .Options;

            using (var context = new ProjectManagerContext(options, null))
            {
                var repoA = new ActivityRepository(context);

                var service = new ActivityService(repoA);
                try
                {
                    service.ValidDates(DateTime.Now, DateTime.Now.AddDays(-1));
                    Assert.True(true);
                }
                catch {
                    Assert.True(false);
                }
            }
        }
        public async Task <ICommandResult> ExecuteAsync(TCommand command)
        {
            var activity = await ActivityRepository.SearchItemsAsync(x => x.Name == $"{typeof(TEntity)}{nameof(CreateOwnedCommandHandler<TCommand, TEntity>)}");

            if (await Authorizer.IsAuthorized(activity.FirstOrDefault()))
            {
                return(new ForbidResult());
            }

            if (command == null)
            {
                return(new ErrorResult("New item cannot be null"));
            }

            var entity = Translator.Translate(command);

            entity.OwnerId = ApplicationUser.Id;
            var id = await CreateRepository.CreateItemAsync(entity);

            return(new CreateResult(id));
        }
Ejemplo n.º 29
0
        public ActionResult CommentBacklog(Comment commentModel)
        {
            var newComment = new Comment();

            newComment.ProductBacklogId = commentModel.ProductBacklogId;
            newComment.MemberId         = commentModel.MemberId;
            var existMember = db.Members.FirstOrDefault(x => x.MemberId == newComment.MemberId);

            newComment.MemberShortName = existMember.Name;
            newComment.MemberComment   = commentModel.MemberComment;
            newComment.CreatedDate     = DateTime.Now;
            db.Comments.Add(newComment);
            db.SaveChanges();

            var existBacklog = db.ProductBacklogs.FirstOrDefault(x => x.ProductBacklogId == commentModel.ProductBacklogId);

            ActivityRepository.ActivityCreator
                ("commented " + existBacklog.Name + " backlog.", existBacklog.ProjectId, existBacklog.ProductBacklogId);

            return(RedirectToAction("EditBacklog", new { id = newComment.ProductBacklogId }));
        }
Ejemplo n.º 30
0
        public async Task <ICommandResult> ExecuteAsync(UpdateBagCommand command)
        {
            var activity = await ActivityRepository.SearchItemsAsync(x => x.Name == $"{nameof(UpdateBagCommandHandler)}");

            if (await Authorizer.IsAuthorized(activity.FirstOrDefault()))
            {
                return(new ForbidResult());
            }

            if (command == null)
            {
                return(new ErrorResult("Update item cannot be null"));
            }

            var previousEntity = await GetRepository.GetItemAsync(command.Id);

            var entity = Translator.Translate(command.Data, previousEntity);
            await UpdateRepository.UpdateItemAsync(command.Id, entity);

            return(new OkResult());
        }
Ejemplo n.º 31
0
        public ActionResult AssignBacklog(int memberId, int backlogId, int?from)
        {
            if (UserRepository.IsUserSigned())
            {
                var _backlogToMember = new BacklogToMember();
                var existBacklog     = new ProductBacklog();
                existBacklog = db.ProductBacklogs.FirstOrDefault(x => x.ProductBacklogId == backlogId);
                var existProject = new Project();
                existProject = db.Projects.FirstOrDefault(x => x.ProjectId == existBacklog.ProjectId);
                if (existProject != null)
                {
                    if (memberId != 0)
                    {
                        var existMember     = db.Members.FirstOrDefault(x => x.MemberId == memberId);
                        var existAssignment = db.BacklogToMembers.FirstOrDefault
                                                  (x => x.ProductBacklogId == existBacklog.ProductBacklogId && x.MemberId == memberId);
                        if (existAssignment != null)
                        {
                            return(Content("Member already assigned that backlog."));
                        }
                        else
                        {
                            _backlogToMember.ProductBacklogId = backlogId;
                            _backlogToMember.MemberId         = memberId;
                            _backlogToMember.MemberName       = existMember.Name;
                            db.BacklogToMembers.Add(_backlogToMember);
                            db.SaveChanges();

                            ActivityRepository.ActivityCreator
                                ("assigned " + existMember.Name + " to the backlog " + existBacklog.Name,
                                existBacklog.ProjectId, existBacklog.ProductBacklogId);

                            return(RedirectToAction("EditBacklog", new { id = backlogId }));
                        }
                    }
                }
                return(Content("There are errors, you cannot assign to this backlog."));
            }
            return(RedirectToAction("Login", "User"));
        }
Ejemplo n.º 32
0
        public ActionResult Edit(int?id)
        {
            AppointmentRepository      repository  = new AppointmentRepository();
            Appointment                appointment = repository.GetById(id);
            AppointmentCreateViewModel model       = new AppointmentCreateViewModel();

            model.UserId        = appointment.UserId;
            model.StartDateTime = appointment.StartDateTime;

            ActivityRepository activityRepo = new ActivityRepository();
            List <Activity>    act          = activityRepo.GetAll();
            int counter = -1;

            model.SelectedActivities = new List <SelectListItem>();
            foreach (var activity in act)
            {
                counter++;
                model.SelectedActivities.Add(new SelectListItem
                {
                    Text     = activity.Name,
                    Value    = activity.Id.ToString(),
                    Selected = false
                });

                foreach (var item in appointment.Activities)
                {
                    if (activity.Id == item.Id)
                    {
                        model.SelectedActivities[counter].Selected = true;
                        break;
                    }
                }
            }

            if (appointment == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
Ejemplo n.º 33
0
        public void Add_GetWithRelation_Activity_With_Account_From_Repository()
        {
            using (var context = new AcManContext(OptionsRandom)) {
                string randomAccountName = "Account " + Guid.NewGuid();
                var    account           = new Account {
                    Name = randomAccountName
                };
                var accountRepository = new AccountRepository(context);
                var accountId         = accountRepository.Add(account);

                var activity = new Activity {
                    Caption   = "Test activity",
                    AccountId = accountId
                };
                var activityRepository = new ActivityRepository(context);
                var activityId         = activityRepository.Add(activity);

                var resultActivity = activityRepository.GetWithRelation(activityId);
                Assert.IsTrue(resultActivity.AccountId == accountId);
                Assert.IsTrue(resultActivity.Account.Id == accountId);
            }
        }
Ejemplo n.º 34
0
        public void ActivityRepository()
        {
            Mock <IDbSetFactory>     factory = new Mock <IDbSetFactory>();
            Mock <DbSet <Activity> > dbSet   = new Mock <DbSet <Activity> >();

            factory.Setup(m => m.CreateDbSet <Activity>()).Returns(dbSet.Object);

            ActivityRepository repo = new ActivityRepository(factory.Object);

            var activity = new Activity();

            var sequence = new MockSequence();

            dbSet.InSequence(sequence).Setup(e => e.Add(activity));
            dbSet.InSequence(sequence).Setup(e => e.Find(activity.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(activity.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(activity.Id));
            repo.Create(activity);
            repo.Get(activity.Id);
            repo.Update(activity);
            repo.Delete(activity.Id);
        }
Ejemplo n.º 35
0
        public ActionResult UnAssignUserFromEditBacklog(int backlogId, int memberId)
        {
            if (UserRepository.IsUserSigned())
            {
                var existBacklog = db.ProductBacklogs.FirstOrDefault(x => x.ProductBacklogId == backlogId);
                if (existBacklog != null)
                {
                    if (memberId != 0)
                    {
                        ProjectRepository.UnAssignUser(backlogId, memberId);
                        var existMember = db.Members.FirstOrDefault(x => x.MemberId == memberId);
                        ActivityRepository.ActivityCreator
                            ("unassigned " + existMember.Name + " to the backlog " + existBacklog.Name,
                            existBacklog.ProjectId, existBacklog.ProductBacklogId);

                        return(RedirectToAction("EditBacklog", new { id = existBacklog.ProductBacklogId }));
                    }
                }
                return(Content("There are errors, you cannot unassign from this backlog."));
            }
            return(RedirectToAction("Login", "User"));
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Method to save user activities on the basis of store survey data
        /// </summary>
        /// <param name="activities">activities performed</param>
        /// <returns>returns status</returns>
        public int SaveSurveyUserResponse(IList <SurveyUserResponseDTO> activities, long userID, bool saveImage = true)
        {
            int result = 0;
            List <SurveyUserResponse>     storeSurveys  = new List <SurveyUserResponse>();
            IList <SurveyUserResponseDTO> storeActivies = activities.Where(k => k.SurveyResponseID != 0).ToList();

            if (storeActivies.Count > 0)
            {
                ObjectMapper.Map(storeActivies, storeSurveys);
                result += ActivityRepository.SaveSurveyUserResponse(storeSurveys, userID, saveImage);
            }

            List <GeneralUserResponse>    generalSurveys  = new List <GeneralUserResponse>();
            IList <SurveyUserResponseDTO> generalActivies = activities.Where(k => k.SurveyResponseID == 0).ToList();

            if (generalActivies.Count > 0)
            {
                ObjectMapper.Map(generalActivies, generalSurveys);
                result += ActivityRepository.SaveGeneralUserResponse(generalSurveys, userID, saveImage);
            }
            return(result);
        }
Ejemplo n.º 37
0
        public void SaveWithoutField()
        {
            var options = new DbContextOptionsBuilder <ProjectManagerContext>()
                          .UseInMemoryDatabase(databaseName: "save")
                          .Options;

            using (var context = new ProjectManagerContext(options, null))
            {
                context.Projects.Add(new Project
                {
                    Name            = "teste1",
                    InitialDate     = DateTime.Now,
                    FinalDate       = DateTime.Now.AddMonths(1),
                    PercentComplete = 0,
                    Late            = false,
                    Removed         = false
                });
                context.SaveChanges();
            }

            using (var context = new ProjectManagerContext(options, null))
            {
                var repoA = new ActivityRepository(context);

                var service = new ActivityService(repoA);

                Assert.ThrowsAsync <AggregateException>(
                    () => service.Save(new Activity
                {
                    Name        = "testeException",
                    InitialDate = DateTime.Now,
                    FinalDate   = DateTime.Now.AddDays(1),
                    Finished    = false
                }
                                       )
                    );
            }
        }
        public void Dispose()
        {
            if (UserRepository != null)
            {
                UserRepository.Dispose();
                UserRepository = null;
            }

            if (ActivityRepository != null)
            {
                ActivityRepository.Dispose();
                ActivityRepository = null;
            }

            if (AgencyContactRepository != null)
            {
                AgencyContactRepository.Dispose();
                AgencyContactRepository = null;
            }

            if (BookingRepository != null)
            {
                BookingRepository.Dispose();
                BookingRepository = null;
            }

            if (SeriesRepository != null)
            {
                SeriesRepository.Dispose();
                SeriesRepository = null;
            }

            if (AgencyRepository != null)
            {
                AgencyRepository.Dispose();
                AgencyRepository = null;
            }
        }
Ejemplo n.º 39
0
 public void Dispose()
 {
     if (StoreProcedureRepository != null)
     {
         StoreProcedureRepository.Dispose();
         StoreProcedureRepository = null;
     }
     if (CruiseRepository != null)
     {
         CruiseRepository.Dispose();
         CruiseRepository = null;
     }
     if (BookingRepository != null)
     {
         BookingRepository.Dispose();
         BookingRepository = null;
     }
     if (AgencyRepository != null)
     {
         AgencyRepository.Dispose();
         AgencyRepository = null;
     }
     if (AgencyContactRepository != null)
     {
         AgencyContactRepository.Dispose();
         AgencyContactRepository = null;
     }
     if (ActivityRepository != null)
     {
         ActivityRepository.Dispose();
         ActivityRepository = null;
     }
     if (UserRepository != null)
     {
         UserRepository.Dispose();
         UserRepository = null;
     }
 }
Ejemplo n.º 40
0
 public ActivityControllerShunt(ActivityRepository activityRepository, ISecurityService securityService, ITeamRepository teams, IEmailService emailService)
     : base(securityService, activityRepository, teams, emailService,null)
 {
 }
        public void Update()
        {
            // Delete everything
            using (var repository = new TopEventRepository())
            {
                var evnts = (from evnt in repository.GetAll() select evnt).ToList();
                foreach(var evnt in evnts)
                {
                    repository.Delete(evnt);
                }
            }

            // update top points by count
            List<ActivityPoint> topPoints = new List<ActivityPoint>();
            List<GameEvent> topEvents = new List<GameEvent>();
            int skipPoints = 0;

            while (topEvents.Count < 10)
            {
                ActivityPoint point = null;
                GameEvent gameEvent = null;
                using (var repository = new ActivityRepository())
                {
                    point = (from p in repository.DataSet.Include("Game")
                             where p.Game.TweetCount > 0 &&
                             (p.Time < p.Game.HalftimeStart || p.Game.HalftimeEnd < p.Time)
                             select p).OrderByDescending(p => p.TweetCount).Skip(skipPoints).Take(1).First();
                }
                using (var repository = new GameEventRepository())
                {
                    gameEvent = (from evnt in repository.GetAll()
                                 where evnt.GameId == point.GameId
                                 && evnt.Timestamp < point.Time
                                 select evnt).OrderByDescending(evnt => evnt.Timestamp).Take(1).SingleOrDefault();
                }

                if (gameEvent == null
                    || gameEvent.Type == GameEventType.FIRST_HALF_START
                    || gameEvent.Type == GameEventType.FIRST_HALF_END
                    || gameEvent.Type == GameEventType.SECOND_HALF_START
                    || gameEvent.Type == GameEventType.SECOND_HALF_END
                    || topEvents.Where(evnt => evnt.Id == gameEvent.Id).Count() > 0)
                {
                    // this event is already in the list
                    skipPoints++;
                }
                else
                {
                    topEvents.Add(gameEvent);
                    topPoints.Add(point);
                }
            }

            using (var repository = new TopEventRepository())
            {
                for (int i = 0; i < topPoints.Count; i++)
                {
                    TopEvent evnt = new TopEvent()
                    {
                        IsRelativeTop = false,
                        Rank = i + 1,
                        GameId = topPoints[i].GameId,
                        ActivityId = topPoints[i].Id,
                        EventId = topEvents[i].Id
                    };
                    repository.Save(evnt);
                }
            }

            // update top points by percentage
            topPoints = new List<ActivityPoint>();
            topEvents = new List<GameEvent>();
            skipPoints = 0;

            while (topEvents.Count < 10)
            {
                ActivityPoint point = null;
                GameEvent gameEvent = null;
                using (var repository = new ActivityRepository())
                {
                    point = (from p in repository.DataSet.Include("Game")
                             where p.Game.TweetCount > 0 &&
                             (p.Time < p.Game.HalftimeStart || p.Game.HalftimeEnd < p.Time)
                             select p).OrderByDescending(p => (double)p.TweetCount / (double)p.Game.TweetCount).Skip(skipPoints).Take(1).First();
                }
                using (var repository = new GameEventRepository())
                {
                    gameEvent = (from evnt in repository.GetAll()
                                 where evnt.GameId == point.GameId
                                 && evnt.Timestamp < point.Time
                                 select evnt).OrderByDescending(evnt => evnt.Timestamp).Take(1).SingleOrDefault();
                }

                if (gameEvent == null
                    || gameEvent.Type == GameEventType.FIRST_HALF_START
                    || gameEvent.Type == GameEventType.FIRST_HALF_END
                    || gameEvent.Type == GameEventType.SECOND_HALF_START
                    || gameEvent.Type == GameEventType.SECOND_HALF_END
                    || topEvents.Where(evnt => evnt.Id == gameEvent.Id).Count() > 0)
                {
                    // this event is already in the list
                    skipPoints++;
                }
                else
                {
                    topEvents.Add(gameEvent);
                    topPoints.Add(point);
                }
            }

            using (var repository = new TopEventRepository())
            {
                for (int i = 0; i < topPoints.Count; i++)
                {
                    TopEvent evnt = new TopEvent()
                    {
                        IsRelativeTop = true,
                        Rank = i + 1,
                        GameId = topPoints[i].GameId,
                        ActivityId = topPoints[i].Id,
                        EventId = topEvents[i].Id
                    };
                    repository.Save(evnt);
                }
            }
        }
Ejemplo n.º 42
0
 public MockupEmailService(ActivityRepository activityRepository, ITeamRepository teamRepository)
     : base(activityRepository, teamRepository)
 {
 }
		public AddNewActivityViewModel ()
		{
			this._activityRepository = new ActivityRepository ();

			this.ActivityStatuses = new List<string> ();

			this.Date = DateTime.Now;

			foreach (var item in Enum.GetValues (typeof(EnumActivityType))) {
				this.ActivityStatuses.Add (item.ToString());
			}

			this.SaveCommand = new Command (this.Save);
			this.CancelCommand = new Command (this.Cancel);

		}