Beispiel #1
0
        public static async Task SendPostMessageAsync(Models.Goal goal, string reqUrl)
        {
            var tokenProvider    = TokenProvider.CreateSharedAccessSignatureTokenProvider(KeyName, AccessKey);
            var messagingFactory = MessagingFactory.Create(BaseAddress, tokenProvider);
            var sender           = messagingFactory.CreateMessageSender(QueueName);

            var messageModel = new MessageModel()
            {
                TitleMessage     = "New Goal record {" + goal.GoalId + "} added at " + DateTime.UtcNow,
                CustomerGuid     = goal.CustomerId,
                LastModifiedDate = goal.LastModifiedDate,
                URL           = reqUrl + "/" + goal.GoalId,
                IsNewCustomer = false,
                TouchpointId  = goal.LastModifiedBy
            };

            var msg = new BrokeredMessage(new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(messageModel))))
            {
                ContentType = "application/json",
                MessageId   = goal.CustomerId + " " + DateTime.UtcNow
            };

            //msg.ForcePersistence = true; Required when we save message to cosmos
            await sender.SendAsync(msg);
        }
Beispiel #2
0
        public ActionResult AddGoal(string name, int[] acts, int id, string col)
        {
            Models.Goal            goal    = new Models.Goal();
            Models.GoalAct1        goalAct = new Models.GoalAct1();
            List <Models.GoalAct1> asd     = new List <Models.GoalAct1>();

            goal.Name   = name;
            goal.UserId = User.Identity.GetUserId();
            goal.Volume = 0;
            goal.Id     = id;
            goal.Color  = col;
            foreach (var temp in acts)
            {
                goalAct        = new Models.GoalAct1();
                goalAct.Id     = MainDb.GoalAct1.Count() + 1;
                goalAct.ActId  = temp;
                goalAct.GoalId = id;
                goalAct.Done   = 0;
                goal.Volume   += (from act in MainDb.Acts where act.Id == temp select act.Importance).FirstOrDefault();
                goalAct.Name   = (from act in MainDb.Acts where act.Id == temp select act.Name).FirstOrDefault();
                var Color = (from act in MainDb.Acts where act.Id == temp select act.SphereId).FirstOrDefault();
                goalAct.Color = (from sp in MainDb.Spheres where sp.Id == Color select sp.Color).FirstOrDefault();
                goalAct.Imp   = (from act in MainDb.Acts where act.Id == temp select act.Importance).FirstOrDefault();
                MainDb.GoalAct1.Add(goalAct);
                MainDb.SaveChanges();
            }
            MainDb.Goals.Add(goal);
            MainDb.SaveChanges();
            return(RedirectToAction("Goal"));
        }
Beispiel #3
0
 public void AddGoal(ResultsSheet resultsSheet, DateTime date, ResultsSheet.ResultsSheetPlayer player)
 {
     Models.Goal goal = new Models.Goal(player.Player.PlayerId, resultsSheet.GameWeekId, player.Player.ManagerId);
     goal.Created   = date;
     goal.CreatedBy = "Reconciliation";
     db.Goals.Add(goal);
     var playerT = db.Players.Where(x => x.PlayerId == goal.PlayerId).FirstOrDefault();
     //auditService.Log("Goal", "Goal Added", "Reconciliation", string.Format("Goal scored for {0} ({1})", playerT?.FullName, playerT?.ManagerPlayers.FirstOrDefault()?.Manager?.Name ?? "Unattached"), resultsSheet.GameWeekId);
 }
Beispiel #4
0
        public Models.Goal CreateGoal(Models.Goal g, String uid)
        {
            var createdGoal = _acc.CreateGoal(g);
            var ug          = new UserGoal
            {
                GoalID       = createdGoal.ID,
                DateAssigned = DateTime.Now,
                UserID       = uid,
            };

            _ugAcc.CreateUserGoal(ug);
            return(createdGoal);
        }
Beispiel #5
0
        public async Task <ResourceResponse <Document> > CreateGoalAsync(Models.Goal goal)
        {
            var collectionUri = DocumentDBHelper.CreateDocumentCollectionUri();

            var client = DocumentDBClient.CreateDocumentClient();

            if (client == null)
            {
                return(null);
            }

            var response = await client.CreateDocumentAsync(collectionUri, goal);

            return(response);
        }
Beispiel #6
0
        public async Task <Models.Goal> CreateAsync(Models.Goal goal)
        {
            if (goal == null)
            {
                return(null);
            }

            goal.SetDefaultValues();

            var documentDbProvider = new DocumentDBProvider();

            var response = await documentDbProvider.CreateGoalAsync(goal);

            return(response.StatusCode == HttpStatusCode.Created ? (dynamic)response.Resource : null);
        }
        public void Setup()
        {
            _goal = Substitute.For <Models.Goal>();

            _request = new HttpRequestMessage()
            {
                Content    = new StringContent(string.Empty),
                RequestUri =
                    new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" +
                            $"Interactions/233d861d-05ca-496e-aee1-6bd47ac13cb2/" +
                            $"ActionPlans/d5369b9a-6959-4bd3-92fc-1583e72b7e51/" +
                            $"Goals")
            };
            _log                       = Substitute.For <ILogger>();
            _resourceHelper            = Substitute.For <IResourceHelper>();
            _httpRequestMessageHelper  = Substitute.For <IHttpRequestMessageHelper>();
            _getGoalHttpTriggerService = Substitute.For <IGetGoalHttpTriggerService>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
        }
        public void Setup()
        {
            _goal = Substitute.For <Models.Goal>();

            _request = new HttpRequestMessage()
            {
                Content    = new StringContent(string.Empty),
                RequestUri =
                    new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" +
                            $"Interactions/aa57e39e-4469-4c79-a9e9-9cb4ef410382/" +
                            $"ActionPlans/d5369b9a-6959-4bd3-92fc-1583e72b7e51/" +
                            $"Goals")
            };

            _log                        = Substitute.For <ILogger>();
            _resourceHelper             = Substitute.For <IResourceHelper>();
            _httpRequestMessageHelper   = Substitute.For <IHttpRequestMessageHelper>();
            _validate                   = Substitute.For <IValidate>();
            _postGoalHttpTriggerService = Substitute.For <IPostGoalHttpTriggerService>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
            _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/");
        }
 public async Task SendToServiceBusQueueAsync(Models.Goal Goals, Guid customerId, string reqUrl)
 {
     await ServiceBusClient.SendPatchMessageAsync(Goals, customerId, reqUrl);
 }
Beispiel #10
0
 public async Task SendToServiceBusQueueAsync(Models.Goal goal, string reqUrl)
 {
     await ServiceBusClient.SendPostMessageAsync(goal, reqUrl);
 }
Beispiel #11
0
 public RangePointerConverter(Models.Goal goal)
 {
     this.goal = goal;
 }