Ejemplo n.º 1
0
        public static Options UpdateOptions(string value, Trails trail)
        {
            var option = trail.Options;

            dynamic update = JObject.Parse(value);

            var distance = update.Distance.Value ?? "";

            if (!string.IsNullOrEmpty(distance.ToString()))
            {
                option.Distance = Convert.ToDouble(update.Distance.Value);
            }

            var peak = update.Peak.Value ?? "";

            if (!string.IsNullOrEmpty(peak.ToString()))
            {
                option.Peak = Convert.ToInt32(update.Peak.Value);
            }

            var elevation = update.Elevation.Value ?? "";

            if (!string.IsNullOrEmpty(elevation.ToString()))
            {
                option.Elevation = Convert.ToDouble(update.Elevation.Value);
            }


            if (!string.IsNullOrEmpty(update.SeasonStart.Value.ToString()))
            {
                option.SeasonStartId = DbAzureHelpers.TryParseIdToGuid(update.SeasonStart.Id.Value);
            }

            if (!string.IsNullOrEmpty(update.SeasonEnd.Value.ToString()))
            {
                option.SeasonEndId = DbAzureHelpers.TryParseIdToGuid(update.SeasonEnd.Id.Value);
            }


            if (!string.IsNullOrEmpty(update.Type.Value.ToString()))
            {
                option.TrailTypeId = DbAzureHelpers.TryParseIdToGuid(update.Type.Id.Value);
            }

            if (!string.IsNullOrEmpty(update.DurationType.Value.ToString()))
            {
                option.TrailDurationTypeId = DbAzureHelpers.TryParseIdToGuid(update.DurationType.Id.Value);
            }

            option.GoodForKids = update.GoodForKids.Value;
            option.DogAllowed  = update.DogAllowed.Value;

            return(option);
        }
Ejemplo n.º 2
0
        public Task <List <References> > GetReferencesAsync(string id)
        {
            var table = Db.GetTableReference("References");
            var guid  = DbAzureHelpers.TryParseIdToGuid(id);

            var query = from entity in table.CreateQuery <References>()
                        where entity.PartitionKey == "References" && entity.TrailId == guid
                        select entity;

            var res = GetListResultOrThrowException(query);

            return(res);
        }
Ejemplo n.º 3
0
        public Task <Users> GetUserAsync(string id)
        {
            var table = Db.GetTableReference("Users");
            var guid  = DbAzureHelpers.TryParseIdToGuid(id);

            var query = from entity in table.CreateQuery <Users>()
                        where entity.PartitionKey == "Users" && entity.Id == guid
                        select entity;

            var res = GetSingleResultOrThrowException(query);

            ThrowExceptionIfObjectNull(res.Result, "Not found user by this id");
            return(res);
        }