예제 #1
0
        public StoreModel GetStore(int storeId, ISystemResponse error)
        {
            StoreModel store = new StoreModel();

            try
            {
                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters.Add("storeId", storeId.ToString());

                string request = WebAPIClient.GetRequest("Stores", "Get", parameters, error);

                if (!string.IsNullOrEmpty(request) && !error.Error)
                {
                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                    StoreResponseModel   response   = serializer.Deserialize <StoreResponseModel>(request);

                    if (response != null && !error.Error && response.store != null)
                    {
                        store = response.store;
                    }
                }
            }
            catch (Exception ex)
            {
                error.Error     = true;
                error.Message   = "No se pudo obtener la informacion de la tienda solicitada";
                error.Exception = ex;
            }

            return(store);
        }
        public IHttpActionResult Get(int storeId)
        {
            ISystemResponse error    = new SystemResponse();
            var             store    = _repository.GetStoreById(storeId, error);
            var             response = new StoreResponseModel {
                store = _modelFactory.Create(store)
            };

            return(Ok(response));
        }
예제 #3
0
        public void TestConstructorSetsAllFields()
        {
            var o = new StoreResponseModel("storeName");

            Assert.That(o, Is.Not.Null);
            Assert.That(o, Has.Property("Name").EqualTo("storeName"));
            Assert.That(o, Has.Property("Commits").EqualTo("storeName/commits"));
            Assert.That(o, Has.Property("Transactions").EqualTo("storeName/transactions"));
            Assert.That(o, Has.Property("Jobs").EqualTo("storeName/jobs"));
            Assert.That(o, Has.Property("Statistics").EqualTo("storeName/statistics"));
        }
예제 #4
0
        public async Task <IActionResult> Put(long id, [FromBody] Store value)
        {
            try
            {
                var result = await _storeProvider.Update(id, value);

                var response = new StoreResponseModel(result);
                return(Ok(response));
            }
            catch (Exception)
            {
                var result = new FailureModel(false, (int)HttpStatusCode.BadRequest, "Bad Request");
                return(BadRequest(result));
            }
        }
예제 #5
0
        public async Task <IActionResult> Get(long id)
        {
            try
            {
                var result = await _storeProvider.GetOne(id);

                var response = new StoreResponseModel(result);
                return(Ok(response));
            }
            catch (Exception)
            {
                var result = new FailureModel(false, (int)HttpStatusCode.BadRequest, "Bad Request");
                return(BadRequest(result));
            }
        }