Exemplo n.º 1
0
        public bool DeleteLocation(LocationEntity entityObject)
        {
            string sqlStatement = "UPDATE Location SET Deleted=1 WHERE LocationId=@LocationId  " + Environment.NewLine;

            //execute
            Connection.Execute(sqlStatement, new { LocationId = entityObject.LocationId }, Transaction);
            return true;
        }
Exemplo n.º 2
0
 public bool DeleteLocation(LocationEntity entityObject)
 {
     //execute
     using (var db = VinaGerman.Database.VinagermanDatabase.GetDatabaseInstance())
     {
         try
         {
             db.OpenConnection();
             return db.Resolve<ILocationDB>().DeleteLocation(entityObject);
         }
         finally
         {
             db.CloseConnection();
         }
     }
 }
Exemplo n.º 3
0
        public LocationEntity AddOrUpdateLocation(LocationEntity entityObject)
        {
            string sqlStatement = "";
            //if insert
            if (entityObject.LocationId > 0)
            {
                sqlStatement += "UPDATE Location SET  " + Environment.NewLine +
                "Address=@Address," + Environment.NewLine +
                "Description=@Description," + Environment.NewLine +
                "CompanyId=@CompanyId," + Environment.NewLine +
                "Deleted=@Deleted" + Environment.NewLine +
                "WHERE LocationId=@LocationId " + Environment.NewLine +
                "SELECT @LocationId AS LocationId " + Environment.NewLine;
            }
            else
            {
                sqlStatement += "INSERT INTO Location(  " + Environment.NewLine +
                "Address," + Environment.NewLine +
                "Description," + Environment.NewLine +
                "CompanyId," + Environment.NewLine +
                "Deleted)" + Environment.NewLine +
                "VALUES (" + Environment.NewLine +
                "@Address," + Environment.NewLine +
                "@Description," + Environment.NewLine +
                "@CompanyId," + Environment.NewLine +
                "@Deleted)" + Environment.NewLine +
                "SELECT SCOPE_IDENTITY() AS LocationId" + Environment.NewLine;
            }

            //execute
            entityObject.LocationId = Connection.ExecuteScalar<int>(sqlStatement, new
            {
                LocationId = entityObject.LocationId,
                Phone = entityObject.Address,
                Description = entityObject.Description,
                CompanyId = entityObject.CompanyId,
                Address = entityObject.Address,
                Deleted = (entityObject.Deleted ? 1 : 0)
            }, Transaction);
            return entityObject;
        }