예제 #1
0
        /// <inheritdoc />
        public async Task <Failable <Barrier> > AddBarrierAsync(Barrier barrierToAdd, string base64Picture, Solution barrierSolution)
        {
            const string settingsName = "BarrierClientBaseAddressAdd";

            try
            {
                if (barrierToAdd == null || string.IsNullOrEmpty(barrierToAdd.Title ?? barrierToAdd.Postcode) ||
                    barrierToAdd.Longitude == 0 || barrierToAdd.Latitude == 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(barrierToAdd));
                }

                var requestData = new BarrierRequestData
                {
                    Description = barrierToAdd.Description,
                    Longitude   = barrierToAdd.Longitude,
                    Latitude    = barrierToAdd.Latitude,
                    Picture     = base64Picture,
                    Postcode    = barrierToAdd.Postcode,
                    Solution    = barrierSolution?.Text,
                    Title       = barrierToAdd.Title
                };

                return(await PerformBarrierRequest <Barrier>(settingsName, requestData, HttpMethod.Post));
            }
            catch (Exception e)
            {
                return(new Failable <Barrier>(e));
            }
        }
예제 #2
0
        /// <inheritdoc />
        public async Task <Failable <Barrier> > ModifyBarrierAsync(string barrierId, string title, string base64Picture,
                                                                   string description)
        {
            const string settingsName = "BarrierClientBaseAddressModify";

            try
            {
                if (string.IsNullOrEmpty(barrierId))
                {
                    throw new ArgumentNullException(nameof(barrierId));
                }

                var requestData = new BarrierRequestData
                {
                    Id          = barrierId,
                    Description = description,
                    Picture     = base64Picture,
                    Title       = title
                };

                return(await PerformBarrierRequest <Barrier>(settingsName, requestData, HttpMethod.Put));
            }
            catch (Exception e)
            {
                return(new Failable <Barrier>(e));
            }
        }