Пример #1
0
        public async Task <IActionResult> Create([FromBody] CreateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            SalesState modelo = new SalesState
            {
                Description = model.Description,
                CompanyId   = model.CompanyId,
                Enabled     = true
            };


            _context.SalesStates.Add(modelo);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch
            {
                return(BadRequest());
            }

            return(Ok());
        }
Пример #2
0
        public bool UpdateOrderState(int orderId, SalesState salesState)
        {
            string query = "Update Sales Set State = @salesState where id= @id;";

            _sqliteDataProvider.AddParameter("@id", orderId);
            _sqliteDataProvider.AddParameter("@salesState", salesState);
            return(_sqliteDataProvider.ExecuteNonQuery(query) > 0);
        }
Пример #3
0
        public IList <Sales> GetSalesByState(SalesState state)
        {
            const string query = "SELECT * From sales Where State = @state";

            _sqliteDataProvider.AddParameter("@state", state);
            var           dataSet = _sqliteDataProvider.ExecuteDataSet(query);
            IList <Sales> sales   = new List <Sales>();

            foreach (DataRow row in dataSet.Tables[0].Rows)
            {
                sales.Add(CreateSales(row));
            }

            return(sales);
        }