Exemplo n.º 1
0
        public async Task InsertItemAsync(string inputModelJson)
        {
            ItemInputModel inputModel = JsonConvert.DeserializeObject <ItemInputModel>(inputModelJson);

            string currentDate = DateTime.Now.ToString("dd.MM.yyyy");
            long   categoryId  = inputModel.CategoryId;
            string name        = inputModel.Name;

            string insertStatement = $"insert into item(is_del, created_on, category_id, name)values(0,'{currentDate}', {categoryId}, '{name}')";

            await CommandExecuter.ExecuteNonQuaryAsync(insertStatement);

            double price = inputModel.Price;

            CenaInputModel cenaInputModel = new CenaInputModel
            {
                Cena = price,
            };

            string cenaInputModelJson = JsonConvert.SerializeObject(cenaInputModel);

            await cenaService.InsertCenaAsync(cenaInputModelJson);
        }
Exemplo n.º 2
0
        public async Task InsertCenaAsync(string inputModelJson)
        {
            CenaInputModel inputModel = JsonConvert.DeserializeObject <CenaInputModel>(inputModelJson);

            double cenaValue = inputModel.Cena;

            string insertStatement = $"insert into cena(is_del, cena_value)values(0, {cenaValue})";

            await CommandExecuter.ExecuteNonQuaryAsync(insertStatement);

            ItemService itemService = new ItemService();

            long itemId = await itemService.GetLastItemIdAsync();

            long cenaId = await GetLastCenaIdAsync();

            CenaItemInputModel cenaItemInputModel = new CenaItemInputModel
            {
                CenaId = cenaId,
                ItemId = itemId,
            };

            await InsertCenaItemAsync(cenaItemInputModel);
        }