Пример #1
0
        public async Task <bool> PostResidentRep(IResidents res, int id)
        {
            zahtjev = new SqlCommand("insert into stanovnici values (@id, @ime, @prezime, @pbr, @spol)", konekcija);
            zahtjev.Parameters.AddWithValue("@id", id);
            zahtjev.Parameters.AddWithValue("@ime", res.Ime);
            zahtjev.Parameters.AddWithValue("@prezime", res.Prezime);
            zahtjev.Parameters.AddWithValue("@pbr", res.Pbr);
            zahtjev.Parameters.AddWithValue("@spol", res.Spol);
            try
            {
                if (konekcija.State == ConnectionState.Closed)
                {
                    konekcija.Open();
                }
                await zahtjev.ExecuteNonQueryAsync();
            }
            catch (SqlException Ex)
            {
                return(false);
            }
            finally
            {
                if (konekcija.State == ConnectionState.Open)
                {
                    konekcija.Close();
                }
            }

            return(true);
        }
Пример #2
0
        public async Task <bool> PostResidentRep(IResidents resident)
        {
            command = new SqlCommand("insert into stanovnici values (@id, @ime, @prezime, @pbr, @spol)", connection);
            command.Parameters.AddWithValue("@id", resident.Id);
            command.Parameters.AddWithValue("@ime", resident.Name);
            command.Parameters.AddWithValue("@prezime", resident.Surname);
            command.Parameters.AddWithValue("@pbr", resident.Pbr);
            command.Parameters.AddWithValue("@spol", resident.Gender);
            try
            {
                if (connection.State == ConnectionState.Closed)
                {
                    connection.Open();
                }
                await command.ExecuteNonQueryAsync();
            }
            catch (SqlException Ex)
            {
                return(false);
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }

            return(true);
        }
Пример #3
0
        public static void Configure(HttpConfiguration config, IPayments payments, IResidents residents)
        {
            ObjectFactory.Configure(cfg =>
            {
                cfg.For <IResidents>().Use(residents).Singleton();
                cfg.For <IPayments>().Use(payments).Singleton();
            });

            config.Services.Replace(typeof(IHttpControllerActivator), new StructureMapControllerActivator());
        }
Пример #4
0
 public HardWiredControllerActivator(IResidents residents, IPayments payments)
 {
     this._residents = residents;
     this._payments  = payments;
 }
Пример #5
0
 public ResidenceControllerTests()
 {
     _residents           = new ResidentsInMemory();
     _singleResident      = _residents.Get(2734);
     _residenceController = new ResidenceController(_residents);
 }
Пример #6
0
 public async Task <bool> PostResident(IResidents resident)
 {
     return(await repository.PostResidentRep(resident));
 }
Пример #7
0
 public ResidenceController(IResidents residents)
 {
     _residents = residents;
 }