Esempio n. 1
0
        public string GetOrganizationList()
        {
            Logger.Log.Info($"GetOrganizationList got request");
            string connectionString = ConfigurationManager.AppSettings["DBConnectionString"];
            OrganizationDBOperator organizationDBOperator = new OrganizationDBOperator(connectionString);

            List <Organization> organizations = organizationDBOperator.GetOrgList();

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.DateFormatString = "d MMMM, yyyy";
            string responce = JsonConvert.SerializeObject(organizations, settings);

            Logger.Log.Info($"GetOrganizationList return {organizations?.Count} organizations");
            return(responce);
        }
        internal Contact ContactFromDataReader(SqlDataReader reader)
        {
            Contact result = new Contact();

            result.ID   = (int)FieldByName(reader, "ID");
            result.Name = (string)FieldByName(reader, "Name");
            result.Name.Replace(" ", String.Empty);
            result.Surname = (string)FieldByName(reader, "Surname");
            result.Surname.Replace(" ", String.Empty);
            result.MiddleName = (string)FieldByName(reader, "MiddleName");
            result.MiddleName.Replace(" ", String.Empty);
            var birthDate = FieldByName(reader, "BirthDate");

            if ((birthDate != null) && (birthDate != DBNull.Value))
            {
                result.BirthDate = Convert.ToDateTime(FieldByName(reader, "BirthDate"));
            }

            result.Gender = Convert.ToChar(FieldByName(reader, "Gender"));
            result.Phone  = (string)FieldByName(reader, "Phone");
            result.Phone.Replace(" ", String.Empty);
            result.TaxNumber = (string)FieldByName(reader, "TaxNumber");
            result.TaxNumber.Replace(" ", String.Empty);
            result.Position = (string)FieldByName(reader, "Position");
            result.Position.Replace(" ", String.Empty);
            var JobID = (FieldByName(reader, "OrganizationID"));

            if ((JobID != null) && (JobID != DBNull.Value))
            {
                string connectionString            = ConfigurationManager.AppSettings["DBConnectionString"];
                OrganizationDBOperator orgOperator = new OrganizationDBOperator(connectionString);
                Organization           job         = orgOperator.GetOrganizationByID((int)JobID);
                result.Job = job;
            }
            return(result);
        }