示例#1
0
        public async Task <IActionResult> Save([FromBody] FlavorView flavorView)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(CustomResponse(ModelState));
                }

                var flavor = _mapper.Map <Flavor>(flavorView);
                if (flavor.Id == 0)
                {
                    await _flavorRepository.Insert(flavor);
                }
                else
                {
                    await _flavorRepository.Update(flavor);
                }
            }
            catch (Exception ex)
            {
                NotifyError(ex.Message);
            }
            return(CustomResponse());
        }
示例#2
0
        public async Task CreatePortuguesa()
        {
            var entry = new FlavorView
            {
                Name  = "Portuguesa",
                Price = 45.00
            };
            var payload = System.Text.Json.JsonSerializer.Serialize(entry);
            var client  = new MenuProvider()._client;

            var response = await client.PostAsync("/api/v1/flavor/save", new StringContent(payload, Encoding.UTF8, "application/json"));

            response.EnsureSuccessStatusCode();
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
        }