public int Save(SSlike data)
        {
            int result = 0;

            using (IDbCommand cmd = database.sqlConnection.GenerateCommand()) {
                cmd.CommandType = CommandType.Text;
                if (data.RecNo != 0)
                {
                    cmd.CommandText = CommandUpdate();
                    cmd.Parameters.Add(database.sqlConnection.GenerateParameter("@RecNo", data.RecNo));
                }
                else
                {
                    cmd.CommandText = CommandInsert();
                }
                cmd.Parameters.Add(database.sqlConnection.GenerateParameter("@Datum", data.Datum));
                cmd.Parameters.Add(database.sqlConnection.GenerateParameter("@DatumVnosa", data.DatumVnosa));
                cmd.Parameters.Add(database.sqlConnection.GenerateParameter("@Oznaka", data.Oznaka));
                cmd.Parameters.Add(database.sqlConnection.GenerateParameter("@Vnasalec", data.Vnasalec));
                cmd.Parameters.Add(database.sqlConnection.GenerateParameter("@Vrsta", data.Vrsta));
                cmd.Parameters.Add(database.sqlConnection.GenerateParameter("@Vsebina", data.Vsebina));
                cmd.Parameters.Add(database.sqlConnection.GenerateParameter("@Komentar", data.Komentar));
                result = database.sqlConnection.ExecDataTableInt(cmd);
            }
            return(result);
        }
        public bool Delete(SSlike data)
        {
            bool result = false;

            using (IDbCommand cmd = database.sqlConnection.GenerateCommand()) {
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = CommandDelete();
                cmd.Parameters.Add(database.sqlConnection.GenerateParameter("@RecNo", data.RecNo));
                result = database.sqlConnection.ExecDataTableBln(cmd);
            }
            return(result);
        }
        private void StartRecordsHost(string[] oznake)
        {
            List <SSlike> data = birokrat.GetAllSlike(company_year);

            for (int i = 0; i < oznake.Length; i++)
            {
                SSlike slk = data.Where((x) => (x.Oznaka == oznake[i])).ToArray()[0];

                StartingRecord      record = new StartingRecord(company_id, company_year, slk.Oznaka, slk.RecNo.ToString(), slk.DatumVnosa);
                HttpResponseMessage msg    = client.Start(record);
            }
        }
        private SSlike[] InsertNewTestCasesToDatabaseKPAndSlike(string company_year, string TipPoste)
        {
            string directory = Configuration.GetValue <string>("Testing:PicturesDirectory");

            string[] fileArray = Directory.GetFiles(directory, "*.pdf");

            // add new records into the database
            int num_recs = Configuration.GetValue <int>("Testing:NumCases");

            SSlike[] slike = new SSlike[num_recs];
            for (int i = 0; i < num_recs; i++)
            {
                string date = DateTime.Now.ToString("yyyyMMdd");
                slike[i] = TestCaseAdder.AddTestCaseToDatabase(date, (short)i, company_year, fileArray[i], TipPoste);
            }
            return(slike);
        }
        public SSlike Load(int id)
        {
            SSlike result = null;

            using (IDbCommand cmd = database.sqlConnection.GenerateCommand()) {
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = CommandLoad();
                cmd.Parameters.Add(database.sqlConnection.GenerateParameter("@RecNo", id));
                DataTable dtt = database.sqlConnection.ExecDataTable(cmd);
                if (dtt != null && dtt.Rows.Count == 1)
                {
                    result = new SSlike();
                    if (!GDataTypeConverter.ObjectFromDataRow(result, dtt.Rows[0]))
                    {
                        result = null;
                    }
                }
            }
            return(result);
        }
        public SSlike AddTestCaseToDatabase(string datum_vnosa, short zap_st, string year_code, string file_path, string tipposte)
        {
            // want to add a new test case - my rachuns from airbnb

            SPostnaKnjiga pk = new SPostnaKnjiga();

            pk.Datum      = DateTime.Now;
            pk.DatumVnosa = datum_vnosa;
            pk.ZapSt      = zap_st;
            pk.YearCode   = year_code;
            pk.TipPoste   = tipposte;

            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            byte[] arr     = File.ReadAllBytes(file_path);
            string content = Encoding.GetEncoding(1250).GetString(arr);

            SSlike s = new SSlike();

            s.Vsebina    = content;
            s.Oznaka     = pk.DatumVnosa + " " + pk.ZapSt;
            s.YearCode   = year_code;
            s.DatumVnosa = datum_vnosa;

            pk.SyncId = Guid.NewGuid();
            s.SyncId  = Guid.NewGuid();

            birokrat.PostnaKnjiga.Save(pk);
            birokrat.Slike.Save(s);
            SListRequest  lrq    = new SListRequest();
            List <SSlike> slklst = birokrat.Slike.List(lrq).data;

            foreach (var x in slklst)
            {
                if (x.Oznaka == s.Oznaka)
                {
                    return(x);
                }
            }
            return(null);
        }