Beispiel #1
0
        public bool Modify(Incident model)
        {
            try
            {
                using (IDbConnection connection = Connection())
                {
                    string sqlCommandText = "usp_IncidentUpdate";
                    using (IDbCommand command = Command(connection, sqlCommandText, CommandType.StoredProcedure))
                    {
                        DAO.AddParameter(command, "Id", model.ID);
                        DAO.AddParameter(command, "Time", model.Time);
                        DAO.AddParameter(command, "Description", model.Description);
                        DAO.AddParameter(command, "Address", model.Address);
                        DAO.AddParameter(command, "AddressAdditional", model.AddressAdditional);
                        DAO.AddParameter(command, "StationResponseId", model.StationResponseId);
                        DAO.AddParameter(command, "ReporterId", model.ReporterId);
                        DAO.AddParameter(command, "Emergency", model.Emergency);
                        DAO.AddParameter(command, "Latitude", model.Latitude);
                        DAO.AddParameter(command, "Longitude", model.Longitude);

                        command.ExecuteNonQuery();
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            throw new NotImplementedException();
        }
Beispiel #2
0
        public bool Modify(Vehicle model)
        {
            try
            {
                using (IDbConnection connection = Connection())
                {
                    string sqlCommandText = "usp_VehicleUpdate";
                    using (IDbCommand command = Command(connection, sqlCommandText, CommandType.StoredProcedure))
                    {
                        DAO.AddParameter(command, "Id", model.ID);
                        DAO.AddParameter(command, "LicensePlate", model.LicensePlate);
                        DAO.AddParameter(command, "LastPosition", model.LastPosition);
                        DAO.AddParameter(command, "VehicleTypeId", model.VehicleTypeId);
                        DAO.AddParameter(command, "StationId", model.StationId);
                        DAO.AddParameter(command, "IsAvailable", model.IsAvailable);
                        command.ExecuteNonQuery();
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            throw new NotImplementedException();
        }
Beispiel #3
0
        public bool Modify(IncidentVehicle model)
        {
            try
            {
                using (IDbConnection connection = Connection())
                {
                    string sqlCommandText = "usp_IncidentVehicleUpdate";
                    using (IDbCommand command = Command(connection, sqlCommandText, CommandType.StoredProcedure))
                    {
                        DAO.AddParameter(command, "Id", model.ID);
                        DAO.AddParameter(command, "IncidentId", model.IncidentId);
                        DAO.AddParameter(command, "VehicleId", model.VehicleId);
                        DAO.AddParameter(command, "Time", model.Time);
                        command.ExecuteNonQuery();
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            throw new NotImplementedException();
        }
        public bool Modify(StationResponse model)
        {
            try
            {
                using (IDbConnection connection = Connection())
                {
                    string sqlCommandText = "usp_StationResponseUpdate";
                    using (IDbCommand command = Command(connection, sqlCommandText, CommandType.StoredProcedure))
                    {
                        DAO.AddParameter(command, "Id", model.ID);
                        DAO.AddParameter(command, "ResponseId", model.ResponseId);
                        DAO.AddParameter(command, "StationId", model.StationId);
                        DAO.AddParameter(command, "NumberOfVehicles", model.NumberOfVehicles);
                        DAO.AddParameter(command, "VehicleTypeId", model.VehicleTypeId);
                        command.ExecuteNonQuery();
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            throw new NotImplementedException();
        }
        public bool Add(Employee model)
        {
            try
            {
                using (IDbConnection connection = Connection())
                {
                    String sql = "dbo.usp_Employee_Insert";
                    using (IDbCommand command = Command(connection, sql, CommandType.StoredProcedure))
                    {
                        DAO.AddParameter(command, "prmPersonalNo", model.PersonalNo);
                        DAO.AddParameter(command, "prmName", model.Name);
                        DAO.AddParameter(command, "prmSurname", model.Surname);
                        DAO.AddParameter(command, "prmBirthdate", model.Birthdate);
                        DAO.AddParameter(command, "prmGender", model.Gender);
                        DAO.AddParameter(command, "prmCityId", model.CityId);
                        DAO.AddParameter(command, "prmEmail", model.Email);
                        DAO.AddParameter(command, "prmPhone", model.Phone);
                        DAO.AddParameter(command, "prmMobile", model.Mobile);
                        DAO.AddParameter(command, "prmIsPasiv", model.IsPasiv);
                        DAO.AddParameter(command, "prmInsBy", model.InsertBy);



                        var result = command.ExecuteNonQuery();
                        return(result >= 0);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Beispiel #6
0
 public bool Remove(int id)
 {
     try
     {
         using (IDbConnection connection = Connection())
         {
             string sqlCommandText = "usp_IncidentDelete";
             using (IDbCommand command = Command(connection, sqlCommandText, CommandType.StoredProcedure))
             {
                 DAO.AddParameter(command, "Id", id);
                 command.ExecuteNonQuery();
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }
        public UserAccount Get(int id)
        {
            using (IDbConnection connection = Connection())
            {
                UserAccount user = null;
                String      sql  = "usp_UserAccount_GetById";
                using (IDbCommand command = Command(connection, sql, CommandType.StoredProcedure))
                {
                    DAO.AddParameter(command, "userId", id);

                    using (IDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            user = ToObject(reader);
                        }
                    }

                    return(user);
                }
            }
        }
Beispiel #8
0
        public List <Vehicle> GetStationVehicles(int stationId)
        {
            using (IDbConnection connection = Connection())
            {
                List <Vehicle> vehicles = null;
                String         sql      = "usp_VehicleSelectByStation";
                using (IDbCommand command = Command(connection, sql, CommandType.StoredProcedure))
                {
                    DAO.AddParameter(command, "StationId", stationId);
                    using (IDataReader reader = command.ExecuteReader())
                    {
                        vehicles = new List <Vehicle>();
                        while (reader.Read())
                        {
                            vehicles.Add(ToObject(reader));
                        }
                    }

                    return(vehicles);
                }
            }
        }
        public IEnumerable <StationResponse> GetByStation(int stationId)
        {
            using (IDbConnection connection = Connection())
            {
                List <StationResponse> stationResponses = null;
                String sql = "usp_StationResponseSelectByStation";
                using (IDbCommand command = Command(connection, sql, CommandType.StoredProcedure))
                {
                    DAO.AddParameter(command, "StationId", stationId);
                    using (IDataReader reader = command.ExecuteReader())
                    {
                        stationResponses = new List <StationResponse>();
                        while (reader.Read())
                        {
                            stationResponses.Add(ToObject(reader));
                        }
                    }

                    return(stationResponses);
                }
            }
        }
Beispiel #10
0
        public bool Add(VehicleType model)
        {
            try
            {
                using (IDbConnection connection = Connection())
                {
                    string sqlCommandText = "usp_VehicleTypeInsert";
                    using (IDbCommand command = Command(connection, sqlCommandText, CommandType.StoredProcedure))
                    {
                        DAO.AddParameter(command, "name", model.Name);
                        command.ExecuteNonQuery();
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            throw new NotImplementedException();
        }
Beispiel #11
0
        public Station Get(int id)
        {
            using (IDbConnection connection = Connection())
            {
                Station station = null;
                String  sql     = "usp_StationSelect";
                using (IDbCommand command = Command(connection, sql, CommandType.StoredProcedure))
                {
                    DAO.AddParameter(command, "Id", id);

                    using (IDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            station = ToObject(reader);
                        }
                    }

                    return(station);
                }
            }
        }
        public UserAccount Login(string username, string password)
        {
            using (IDbConnection connection = Connection())
            {
                UserAccount user = null;
                String      sql  = "usp_Authenticate";
                using (IDbCommand command = Command(connection, sql, CommandType.StoredProcedure))
                {
                    DAO.AddParameter(command, "username", username);
                    DAO.AddParameter(command, "password", password);

                    using (IDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            user = ToObject(reader);
                        }
                    }

                    return(user);
                }
            }
        }
 public bool Add(UserAccount model)
 {
     try
     {
         using (IDbConnection connection = Connection())
         {
             string sqlCommandText = "usp_UserAccount_Insert";
             using (IDbCommand command = Command(connection, sqlCommandText, CommandType.StoredProcedure))
             {
                 DAO.AddParameter(command, "username", model.Username);
                 DAO.AddParameter(command, "password", model.Password);
                 DAO.AddParameter(command, "name", model.Name);
                 DAO.AddParameter(command, "surname", model.Surname);
                 DAO.AddParameter(command, "roleId", model.RoleId);
                 command.ExecuteNonQuery();
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Beispiel #14
0
        public bool Modify(Country model)
        {
            try
            {
                using (IDbConnection connection = Connection())
                {
                    string sqlCommandText = "usp_CountryUpdate";
                    using (IDbCommand command = Command(connection, sqlCommandText, CommandType.StoredProcedure))
                    {
                        DAO.AddParameter(command, "Id", model.ID);
                        DAO.AddParameter(command, "Code", model.Code);
                        DAO.AddParameter(command, "Name", model.Name);
                        command.ExecuteNonQuery();
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            throw new NotImplementedException();
        }