Ejemplo n.º 1
0
		public async static Task InsertResponseSummary (ResponseSummary responseSummary)
		{
			
				var db = DependencyService.Get<ISQLite> ().GetAsyncConnection ();
				await db.CreateTableAsync<ResponseSummary> ();

				await db.InsertAsync (responseSummary);
			
		}
Ejemplo n.º 2
0
		public async static Task DeleteResponseSummary (ResponseSummary responseSummary)
		{
			
				var db = DependencyService.Get<ISQLite> ().GetAsyncConnection ();

				await db.DeleteAsync (responseSummary);

			
		}
        private ResponseSummary BuildResponseSummary(Response response)
        {
            var obj = new ResponseSummary
            {
                Id      = response.Id,
                Display = response.ShortDisplay ?? response.Display
            };

            return(obj);
        }
Ejemplo n.º 4
0
        public IHttpActionResult Summary([FromODataUri] string formId)
        {
            var summary = new ResponseSummary();

            TableQuery <TableEntityAdapter <Response> > queryResponses = new TableQuery <TableEntityAdapter <Response> >().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, formId));
            var responses = ResponseTable.ExecuteQuery(queryResponses)?.Select(result => result.OriginalEntity);

            TableQuery <TableEntityAdapter <Choice> > queryChoices = new TableQuery <TableEntityAdapter <Choice> >().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, formId));
            var choices = ChoiceTable.ExecuteQuery(queryChoices).Select(result => result.OriginalEntity);

            if (choices != null && choices.Count() != 0)
            {
                foreach (var choice in choices)
                {
                    TableOperation shopRetrieveOperation = TableOperation.Retrieve <TableEntityAdapter <Shop> >("zgc", choice.ShopId);
                    var            shop    = ((TableEntityAdapter <Shop>)ShopTable.Execute(shopRetrieveOperation).Result)?.OriginalEntity;
                    var            newItem = new ResponseSummaryItem()
                    {
                        ShopTitle           = shop?.ShopTitle,
                        Count               = 0,
                        ResponderAvatarUrls = new List <string>()
                    };

                    var choiceResponses = responses.Where(res => res.ChoiceId == choice.Id);
                    newItem.Count = choiceResponses.Count();
                    foreach (var response in choiceResponses)
                    {
                        TableOperation userRetrieveOperation = TableOperation.Retrieve <TableEntityAdapter <User> >("User", response.ResponderId);
                        var            user = ((TableEntityAdapter <User>)UserTable.Execute(userRetrieveOperation).Result)?.OriginalEntity;
                        newItem.ResponderAvatarUrls.Add(user?.AvatarUrl ?? string.Empty);
                    }
                    summary.Items.Add(newItem);
                }
                summary.WinnerTitle = summary.Items.Count() != 0 ? summary.Items.OrderByDescending(item => item.Count).First()?.ShopTitle : string.Empty;
                summary.Total       = summary.Items.Count() != 0 ? summary.Items.Sum(item => item.Count) : 0;
            }
            return(Ok(summary));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///   Adds the current response to the cache if required Only stores by Path and stores the
        ///   response in a KVLite cache.
        /// </summary>
        /// <param name="context">Current context.</param>
        void SetCache(NancyContext context)
        {
            if (context.Response.StatusCode != HttpStatusCode.OK)
            {
                return;
            }

            object cacheSecondsObject;
            if (!context.Items.TryGetValue(ContextExtensions.OutputCacheTimeKey, out cacheSecondsObject))
            {
                return;
            }

            int cacheSeconds;
            if (!int.TryParse(cacheSecondsObject.ToString(), out cacheSeconds))
            {
                return;
            }

            // Disable further caching, as it must explicitly enabled.
            context.Items.Remove(ContextExtensions.OutputCacheTimeKey);

            // The response we are going to cache. We put it here, so that it can be used as
            // recovery in the catch clause below.
            var responseToBeCached = context.Response;

            try
            {
                var cacheKey = context.GetRequestFingerprint();
                var cachedSummary = new ResponseSummary(responseToBeCached);
                _cache.AddTimed(ResponseCachePartition, cacheKey, cachedSummary, _cache.Clock.UtcNow.AddSeconds(cacheSeconds));
                context.Response = cachedSummary.ToResponse();
            }
            catch (Exception ex)
            {
                const string errMsg = "Something bad happened while caching :-(";
                LogManager.GetLogger<CachingBootstrapper>().Error(errMsg, ex);
                // Sets the old response, hoping it will work...
                context.Response = responseToBeCached;
            }
        }
Ejemplo n.º 6
0
		public async Task DeleteResponseSummary (ResponseSummary responseSummary)
		{
			await ResponseSummaryDAL.DeleteResponseSummary(responseSummary);
		}
Ejemplo n.º 7
0
		public  async Task InsertResponseSummary (ResponseSummary responseSummary)
		{
			await ResponseSummaryDAL.InsertResponseSummary(responseSummary);
		}
Ejemplo n.º 8
0
		public async Task ModifyResponseSummary (ResponseSummary responseSummary)
		{
			await ResponseSummaryDAL.ModifyResponseSummary (responseSummary);
		}
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (ActionId != null)
         {
             hashCode = hashCode * 59 + ActionId.GetHashCode();
         }
         if (Amount != null)
         {
             hashCode = hashCode * 59 + Amount.GetHashCode();
         }
         if (Currency != null)
         {
             hashCode = hashCode * 59 + Currency.GetHashCode();
         }
         if (Approved != null)
         {
             hashCode = hashCode * 59 + Approved.GetHashCode();
         }
         if (Status != null)
         {
             hashCode = hashCode * 59 + Status.GetHashCode();
         }
         if (AuthCode != null)
         {
             hashCode = hashCode * 59 + AuthCode.GetHashCode();
         }
         if (ResponseCode != null)
         {
             hashCode = hashCode * 59 + ResponseCode.GetHashCode();
         }
         if (ResponseSummary != null)
         {
             hashCode = hashCode * 59 + ResponseSummary.GetHashCode();
         }
         if (ThreeDS != null)
         {
             hashCode = hashCode * 59 + ThreeDS.GetHashCode();
         }
         if (Risk != null)
         {
             hashCode = hashCode * 59 + Risk.GetHashCode();
         }
         if (Source != null)
         {
             hashCode = hashCode * 59 + Source.GetHashCode();
         }
         if (Customer != null)
         {
             hashCode = hashCode * 59 + Customer.GetHashCode();
         }
         if (ProcessedOn != null)
         {
             hashCode = hashCode * 59 + ProcessedOn.GetHashCode();
         }
         if (Reference != null)
         {
             hashCode = hashCode * 59 + Reference.GetHashCode();
         }
         if (Eci != null)
         {
             hashCode = hashCode * 59 + Eci.GetHashCode();
         }
         if (SchemeId != null)
         {
             hashCode = hashCode * 59 + SchemeId.GetHashCode();
         }
         if (Links != null)
         {
             hashCode = hashCode * 59 + Links.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Returns true if PaymentResponse instances are equal
        /// </summary>
        /// <param name="other">Instance of PaymentResponse to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(PaymentResponse other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     ActionId == other.ActionId ||
                     ActionId != null &&
                     ActionId.Equals(other.ActionId)
                 ) &&
                 (
                     Amount == other.Amount ||
                     Amount != null &&
                     Amount.Equals(other.Amount)
                 ) &&
                 (
                     Currency == other.Currency ||
                     Currency != null &&
                     Currency.Equals(other.Currency)
                 ) &&
                 (
                     Approved == other.Approved ||
                     Approved != null &&
                     Approved.Equals(other.Approved)
                 ) &&
                 (
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                 ) &&
                 (
                     AuthCode == other.AuthCode ||
                     AuthCode != null &&
                     AuthCode.Equals(other.AuthCode)
                 ) &&
                 (
                     ResponseCode == other.ResponseCode ||
                     ResponseCode != null &&
                     ResponseCode.Equals(other.ResponseCode)
                 ) &&
                 (
                     ResponseSummary == other.ResponseSummary ||
                     ResponseSummary != null &&
                     ResponseSummary.Equals(other.ResponseSummary)
                 ) &&
                 (
                     ThreeDS == other.ThreeDS ||
                     ThreeDS != null &&
                     ThreeDS.Equals(other.ThreeDS)
                 ) &&
                 (
                     Risk == other.Risk ||
                     Risk != null &&
                     Risk.Equals(other.Risk)
                 ) &&
                 (
                     Source == other.Source ||
                     Source != null &&
                     Source.Equals(other.Source)
                 ) &&
                 (
                     Customer == other.Customer ||
                     Customer != null &&
                     Customer.Equals(other.Customer)
                 ) &&
                 (
                     ProcessedOn == other.ProcessedOn ||
                     ProcessedOn != null &&
                     ProcessedOn.Equals(other.ProcessedOn)
                 ) &&
                 (
                     Reference == other.Reference ||
                     Reference != null &&
                     Reference.Equals(other.Reference)
                 ) &&
                 (
                     Eci == other.Eci ||
                     Eci != null &&
                     Eci.Equals(other.Eci)
                 ) &&
                 (
                     SchemeId == other.SchemeId ||
                     SchemeId != null &&
                     SchemeId.Equals(other.SchemeId)
                 ) &&
                 (
                     Links == other.Links ||
                     Links != null &&
                     Links.Equals(other.Links)
                 ));
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Sets the <see cref="ResponseSummary"/> to display.
 /// </summary>
 /// <param name="value">The <see cref="ResponseSummary"/> to display.</param>
 public void SetResponseSummary(ResponseSummary value)
 {
     this.responseSummary = value;
 }
Ejemplo n.º 12
0
		public ResponseSummaryViewModel (User selectedUser)
		{
			SelectedUser = selectedUser;

			//get the Member Image
			if (SelectedUser.ImageURL == null || SelectedUser.ImageURL == "") {
				MemberImage = "memberpic.png";

			} else {

				MemberImage = SelectedUser.ImageURL;
			}

			ResponseQuestionList = new ObservableCollection<ResponseSummary> ();


			ResponseSummaryGroupList = new ObservableCollection<ResponseSummaryGroup> ();

			AppointmentSummaryList = new ObservableCollection<AppointmentSummary> ();


			AppointmentSummaryGroupList = new ObservableCollection<AppointmentSummaryGroup> ();



			if (CrossConnectivity.Current.IsConnected) {
				Task.Run (async() => {

					var responseSummaryDBList = await ResponseSummaryDAL.GetResponseSummary (SelectedUser.ProfileID);
					foreach (var responseSummaryDB in responseSummaryDBList) {
						await ResponseSummaryDAL.DeleteResponseSummary (responseSummaryDB);
					}




					var responseSummaryListAPI = await CoachServices.RequestResponseSummary (SelectedUser.ProfileID);
					foreach (var responseSummaryDTO in responseSummaryListAPI) {
						ResponseSummary responseSummary = new ResponseSummary (responseSummaryDTO);
						await ResponseSummaryDAL.InsertResponseSummary (responseSummary);
					}
					var responseSummaryDBList2 = await ResponseSummaryDAL.GetResponseSummary (SelectedUser.ProfileID);
					ResponseQuestionList = new ObservableCollection<ResponseSummary> (responseSummaryDBList2);
					foreach (var sum in ResponseQuestionList) {
						var responseArray = sum.MemberResponse.Split (',');
						for (int i = 0; i < responseArray.Count (); i++) {
							responseArray [i] = responseArray [i].Trim ();
						}
						sum.MemberResponseList = responseArray.ToList ();
					}

					foreach (var rSumm in ResponseQuestionList) {
						ResponseSummaryGroup responseSummaryGroup = new ResponseSummaryGroup (rSumm);
						Device.BeginInvokeOnMainThread (() => {
							ResponseSummaryGroupList.Add (responseSummaryGroup);
						});
					}

					var appointmentSummaryDBList = await AppointmentSummaryDAL.GetAppointmentSummaryList (SelectedUser.ProfileID);
					foreach (var appointmentSummaryDB in appointmentSummaryDBList) {
						await AppointmentSummaryDAL.DeleteAppointmentSummary (appointmentSummaryDB);
					}

					var appointmentSummaryListAPI = await CoachServices.RequestAppointmentSummary (SelectedUser.ProfileID);
					foreach (var appointmentSummaryDTO in appointmentSummaryListAPI) {
						AppointmentSummary appointmentSummary = new AppointmentSummary (appointmentSummaryDTO);
						await AppointmentSummaryDAL.InsertApppointmentSummary (appointmentSummary);
					}
					var appointmentSummaryDBList2 = await AppointmentSummaryDAL.GetAppointmentSummaryList (SelectedUser.ProfileID);
					AppointmentSummaryList = new ObservableCollection<AppointmentSummary> (appointmentSummaryDBList2);

					var distinctAppointmentNames = AppointmentSummaryList.Select(row => row.TypeName).Distinct();

					if(ResponseSummaryGroupList.Count() > 0)
					{
						AppointmentSummaryGroup tourGroup = new AppointmentSummaryGroup(ResponseSummaryGroupList, "Tour");
						Device.BeginInvokeOnMainThread(() => {
							AppointmentSummaryGroupList.Add(tourGroup);
						});
					}

					foreach(var appointmentName in distinctAppointmentNames)
					{
						var appointmentSummaryList = AppointmentSummaryList.Where(row => row.TypeName == appointmentName).ToList();
						AppointmentSummaryGroup appointmentSummaryGroup = new AppointmentSummaryGroup(appointmentSummaryList);
						Device.BeginInvokeOnMainThread(() => {
							AppointmentSummaryGroupList.Add(appointmentSummaryGroup);
						});
					}

				});
			} else {
				DependencyService.Get<ICustomDialog> ().Display ("You are not connected to a network. The displayed data might not be up to date.", "OK");
				Task.Run (async() => {
					var responseSummaryDBList = await ResponseSummaryDAL.GetResponseSummary (SelectedUser.ProfileID);
					ResponseQuestionList = new ObservableCollection<ResponseSummary> (responseSummaryDBList);
					foreach (var sum in ResponseQuestionList) {
						var responseArray = sum.MemberResponse.Split (',');
						for (int i = 0; i < responseArray.Count (); i++) {
							responseArray [i] = responseArray [i].Trim ();
						}
						sum.MemberResponseList = responseArray.ToList ();
					}

					foreach (var rSumm in ResponseQuestionList) {
						ResponseSummaryGroup responseSummaryGroup = new ResponseSummaryGroup (rSumm);
						Device.BeginInvokeOnMainThread (() => {
							ResponseSummaryGroupList.Add (responseSummaryGroup);
						});
					}

					var appointmentSummaryDBList2 = await AppointmentSummaryDAL.GetAppointmentSummaryList (SelectedUser.ProfileID);
					AppointmentSummaryList = new ObservableCollection<AppointmentSummary> (appointmentSummaryDBList2);

					var distinctAppointmentNames = AppointmentSummaryList.Select(row => row.TypeName).Distinct();

					if(ResponseSummaryGroupList.Count() > 0)
					{
						AppointmentSummaryGroup tourGroup = new AppointmentSummaryGroup(ResponseSummaryGroupList, "Tour");
						Device.BeginInvokeOnMainThread(() => {
							AppointmentSummaryGroupList.Add(tourGroup);
						});
					}

					foreach(var appointmentName in distinctAppointmentNames)
					{
						var appointmentSummaryList = AppointmentSummaryList.Where(row => row.TypeName == appointmentName).ToList();
						AppointmentSummaryGroup appointmentSummaryGroup = new AppointmentSummaryGroup(appointmentSummaryList);
						Device.BeginInvokeOnMainThread(() => {
							AppointmentSummaryGroupList.Add(appointmentSummaryGroup);
						});
					}

				});
			}
		}
Ejemplo n.º 13
0
 /// <summary>
 /// Get the display text for a ResponseSummary
 /// </summary>
 /// <param name="responseSummary"></param>
 /// <returns></returns>
 public static string GetErrorDisplayText(this ResponseSummary responseSummary)
 {
     return(string.Concat(" ERROR - ", responseSummary.ToMessagesString()));
 }